<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP &#8211; Sandy Scott&#039;s Web Spot</title>
	<atom:link href="https://www.sandyscott.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sandyscott.net</link>
	<description>My little corner of the web</description>
	<lastBuildDate>Fri, 05 Jun 2020 11:28:52 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Server Setup 6: WordPress Pre-requisites</title>
		<link>https://www.sandyscott.net/2020/05/server-setup-4-wordpress-pre-requisites/</link>
					<comments>https://www.sandyscott.net/2020/05/server-setup-4-wordpress-pre-requisites/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Thu, 21 May 2020 14:13:22 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=484</guid>

					<description><![CDATA[WordPress is a very flexible platform, but there are a few key pieces that are essential for it to run: A websever We installed Apache in an earlier post so that&#8217;s covered, though we will need some extra modules. PHP This is the programming language WordPress is built in and...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/server-setup-4-wordpress-pre-requisites/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>WordPress is a very flexible platform, but there are a few key pieces that are essential for it to run:</p>



<ul class="wp-block-list"><li>A websever<ul><li>We installed Apache in an earlier post so that&#8217;s covered, though we will need some extra modules.</li></ul></li><li>PHP<ul><li>This is the programming language WordPress is built in and runs on, so our server needs to have it installed.</li></ul></li><li>A Database<ul><li>We&#8217;ll install MariaDB, which is powerful &amp; popular solution.</li></ul></li></ul>



<p>The full details are on the WordPress website, and we&#8217;ll refer back to this for the specifics in a bit: <a href="https://make.wordpress.org/hosting/handbook/handbook/server-environment/">https://make.wordpress.org/hosting/handbook/handbook/server-environment/</a></p>



<p>First, lets install PHP</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install php</pre></div>



<p>It&#8217;s worth paying some attention to what apt is actually doing at his point:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sandy@waldorf:/var/www/test$ sudo apt install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libapache2-mod-php7.3 libsodium23 php-common php7.3 php7.3-cli php7.3-common php7.3-json
  php7.3-opcache php7.3-readline psmisc
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php7.3 libsodium23 php php-common php7.3 php7.3-cli php7.3-common php7.3-json
  php7.3-opcache php7.3-readline psmisc
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,377 kB of archives.
After this operation, 17.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]
</pre></div>



<p>In the list of packages that will be installed, <code>php7.3</code> has been selected. This is the current stable version of PHP, and is the default in Debian 10. Also, <code>libapache2-mod-php7.3</code> will be installed &#8211; this is the Apache module that lets it run php code when to create the web pages you see.</p>



<p>We can test this with the <code>phpinfo();</code> function, which does a similar thing to the http://test.example.org/server-info page we created in the previous post.</p>



<p>Create a file called phpinfo.php in the folder for the test website:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /var/www/test/phpinfo.php</pre></div>



<p>Type in this line:</p>



<pre class="wp-block-code"><code>&lt;?php phpinfo(); ?></code></pre>



<p>Now visit <a href="http://test.example.org/phpinfo.php">http://test.example.org/phpinfo.php</a>. You should get a long page full of information that looks like this:</p>



<figure class="wp-block-image size-full is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-19.png"><img fetchpriority="high" decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-19.png" alt="" class="wp-image-485" width="521" height="246" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-19.png 1041w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-19-300x141.png 300w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-19-1024x483.png 1024w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-19-768x362.png 768w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-19-150x71.png 150w" sizes="(max-width: 521px) 100vw, 521px" /></a></figure>



<p>All of the headings on this page after <strong>HTTP Headers Information</strong> and before <strong>Additional Modules</strong> are the modules that PHP has loaded and can be used by php webpages on your server.</p>



<p>If we compare that list of modules, to the list of extensions required by WordPress, we might find some gaps. This is the list from my server:</p>



<figure class="wp-block-table php-wp-modulecompattable"><table class="has-fixed-layout"> <thead> <tr> <th>Required by WordPress</th> <th>Installed on myserver</th> </tr> </thead> <tbody> <tr class="php-wp-module-notrequired"> <td> </td> <td>calendar</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>Core</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>ctype</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>curl</td> <td></td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>date</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>dom</td> <td></td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>exif</td> <td>exif</td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>fileinfo</td> <td>fileinfo</td> </tr> <tr class="php-wp-module-notrequired"> <td></td> <td>filter</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>ftp</td> </tr> <tr> <td></td> <td></td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>gettext</td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>hash</td> <td>hash</td> </tr> <tr class="php-wp-module-notrequired"> <td></td> <td>iconv</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>imagick</td> <td></td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>json</td> <td>json</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>libxml</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>mbstring</td> <td></td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>mysqli</td> <td></td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>openssl</td> <td>openssl</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>pcntl</td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>pcre</td> <td>pcre</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>PDO</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>Phar</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>posix</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>readline</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>Reflection</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>session</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>shmop</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>sockets</td> </tr> <tr class="php-wp-module-requiredandpresent"> <td>libsodium* (the documentation is slightly out of date, sodium replaces libsodium)</td> <td>sodium</td> </tr> <tr class="php-wp-module-notrequired"> <td></td> <td>SPL</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>standard</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>sysvmsg</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>sysvsem</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>sysvshm</td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>tokenizer</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>xml</td> <td></td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>Zend OPcache</td> </tr> <tr class="php-wp-module-requiredbutmissing"> <td>zip</td> <td></td> </tr> <tr class="php-wp-module-notrequired"> <td> </td> <td>zlib</td> </tr> </tbody> </table> </figure>



<p>So the missing ones are:</p>



<ul class="wp-block-list"><li>curl</li><li>dom</li><li>imagick</li><li>mbstring</li><li>mysqli</li><li>xml</li><li>zip</li></ul>



<p>So we&#8217;ll install them. The package names take the form of <code>php-</code> or <code>php7.3-</code>  and then the module name. The <code>dom</code> module is provided within the <code>php-xml</code> package. <code>mysqli </code>is in <code>php-mysql</code>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install php-curl php-imagick php7.3-mbstring php-mysql php-xml php-zip</pre></div>



<p>For some reason, some of these need to be enabled manually,  the others just work.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo phpenmod -s apache2 curl mbstring mysqli</pre></div>



<p>Restart the webserver:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo systemctl restart apache2</pre></div>



<h2 class="wp-block-heading">Database</h2>



<p>The Database holds all of the live content in your wordpress blog, like the posts and comments. It also has all of the user information.</p>



<p>We&#8217;ll install mariadb</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install mariadb-server</pre></div>



<p>Now we&#8217;ll use a ready-made script to set basic security options. You&#8217;ll need to create a strong password for root user for the database server (not the same as the root user of the system).</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mysql_secure_installation</pre></div>



<p>Say yes to all of the options, entering the database server root password when prompted.</p>



<p>Now create the actual worpress database in the database server. Start by logging into the database with the mysql command line client, and enter the password when prompted.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mysql -u root -p</pre></div>



<pre class="wp-block-code"><code>sandy@waldorf:/etc/php/7.3/apache2$ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 57
Server version: 10.3.22-MariaDB-0+deb10u1 Debian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB &#91;(none)]></code></pre>



<p>You&#8217;re now logged into a special command line that&#8217;s just for working on the database server. This command creates the database &#8211; the name could be anything &#8211; just remember it for later. I&#8217;ve called mine <code>wp_db</code>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;sql&quot;,&quot;mime&quot;:&quot;text/x-sql&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;SQL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;sql&quot;}">CREATE DATABASE wp_db;</pre></div>



<p>Then next command creates the user that WordPress will use to access this database. It also sets their password and gives them access to the database. Fill in your own values for <code>wp_db</code>, <code>wp_usr </code>and <code>password</code>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;sql&quot;,&quot;mime&quot;:&quot;text/x-sql&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;SQL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;sql&quot;}">GRANT ALL PRIVILEGES ON wp_db.* TO &quot;wp_usr&quot;@&quot;localhost&quot; IDENTIFIED BY &quot;password&quot;;</pre></div>



<p>Now force the database to reload that user information and exit:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;sql&quot;,&quot;mime&quot;:&quot;text/x-sql&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;SQL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;sql&quot;}">FLUSH PRIVILEGES;
EXIT</pre></div>



<p>This is what the whole interraction looks like on my system:</p>



<pre class="wp-block-code"><code>sandy@waldorf:/etc/php/7.3/apache2$ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 57
Server version: 10.3.22-MariaDB-0+deb10u1 Debian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB &#91;(none)]> CREATE DATABASE wp_db;
Query OK, 1 row affected (0.001 sec)

MariaDB &#91;(none)]> GRANT ALL PRIVILEGES ON wp_db.* TO "wp_usr"@"localhost" IDENTIFIED BY "password";
Query OK, 0 rows affected (0.001 sec)

MariaDB &#91;(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

MariaDB &#91;(none)]> EXIT
Bye</code></pre>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/server-setup-4-wordpress-pre-requisites/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
