{"id":1446,"date":"2011-08-21T22:03:04","date_gmt":"2011-08-21T21:03:04","guid":{"rendered":"http:\/\/www.haydnwilliams.com\/blog\/?p=1446"},"modified":"2022-04-11T21:34:01","modified_gmt":"2022-04-11T20:34:01","slug":"uhs5-lamp-web-server-wordpress","status":"publish","type":"post","link":"https:\/\/www.haydnwilliams.com\/blog\/uhs5-lamp-web-server-wordpress\/","title":{"rendered":"UHS5 &#8211; LAMP web server + WordPress"},"content":{"rendered":"<p>The process is cover<a title=\"Apache MySQL PHP - Ubuntu Documentation\" href=\"https:\/\/help.ubuntu.com\/community\/ApacheMySQLPHP\" target=\"_blank\" rel=\"noopener\">ed in quite a lot of good detail<\/a> in the Ubuntu Documentation, but I&#8217;ve summarised the main steps below for those who just want to get up and running with the basics.<\/p>\n<h2>Apache<\/h2>\n<p>We can again use apt-get, this time to install <a title=\"Apache HTTP Server - apache.org\" href=\"http:\/\/httpd.apache.org\/\" target=\"_blank\" rel=\"noopener\">Apache HTTP server<\/a>. It&#8217;s version 2 which is available now, hence the command is:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install apache2<\/pre>\n<p>The marvellous apt-get takes care of installing all dependancies too, so anything else we might need to run apache just gets added without us having to worry about it. Once the install process is finished, navigate to <a title=\"Localhost\" href=\"http:\/\/localhost\" target=\"_blank\" rel=\"noopener\">http:\/\/localhost<\/a> and make sure that you can see the default Apache page.<\/p>\n<p>To make the pages visible from other machines on the local network, you&#8217;ll need to edit <strong>\/etc\/apache2\/sites-available\/default<\/strong>.\u00a0Find the line:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">Allow from 127.0.0.0\/255.0.0.0 ::1\/128<\/pre>\n<p>and add the IP addresses of other local machines onto the end. Although all our PCs have static IP addresses, I used a wildcard so that things like my iPhone and visiting friend&#8217;s PCs can also access the server. I therefore changed the line from the above to:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">Allow from 127.0.0.0\/255.0.0.0 ::1\/128 192.168.1.*<\/pre>\n<p>The pages served by default, in my case at least, were stored in <strong>\/var\/www<\/strong>. If you want to run more than one website through Apache, a <a title=\"Configure Apache, MySQL on zaphu.com\" href=\"http:\/\/www.zaphu.com\/2007\/08\/21\/ubuntu-lamp-server-guide-configure-apache-mysql-and-cgi-bin\/\" target=\"_blank\" rel=\"noopener\">guide on zaphu.com<\/a> describes how to add a new site and activate it.<\/p>\n<h2>PHP<\/h2>\n<p><a title=\"PHP: Hypertext Preprocessor\" href=\"http:\/\/php.net\/\" target=\"_blank\" rel=\"noopener\">PHP<\/a> is pretty easy to install:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install php5<\/pre>\n<p>That&#8217;s it! The system will probably re-start Apache for you at the appropriate places, but if you want to check whether it&#8217;s successfully integrated PHP5 support into Apache, then running the following will give you an answer as to whether or not the relevant module has been enabled:<\/p>\n<pre>&gt;sudo\u00a0a2enmod\u00a0php5<\/pre>\n<h2>MySQL<\/h2>\n<p>To install <a title=\"MySQL\" href=\"http:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>, just run:<\/p>\n<pre>sudo apt-get install mysql-client mysql-server<\/pre>\n<p>During the setup procedure, you&#8217;ll be asked to choose a password for the &#8216;root&#8217; account. Once that&#8217;s installed, ensure you&#8217;ve got support for MySQL in PHP:<\/p>\n<pre>sudo apt-get install php5-mysql<\/pre>\n<p>And finally, if you want a GUI admin tool, then MySQL Administrator does a fine job (although it seems to have been replaced by <a title=\"MySQL Workbench\" href=\"http:\/\/www.mysql.com\/products\/workbench\/\" target=\"_blank\" rel=\"noopener\">MySQL Workbench<\/a> now, but I couldn&#8217;t find that using apt-get), or you can use <a title=\"PHPMyAdmin\" href=\"http:\/\/www.phpmyadmin.net\/home_page\/index.php\" target=\"_blank\" rel=\"noopener\">PHPMyAdmin<\/a> to do it in your browser:<\/p>\n<pre>sudo apt-get install mysql-admin sudo apt-get install phpmyadmin<\/pre>\n<p>If you want to check the server&#8217;s working OK, log in to it using the root account we set up during installation:<\/p>\n<pre>mysql -u root -p<\/pre>\n<p>Obviously the next thing you&#8217;ll do is set about creating a new user account and locking down the &#8216;root&#8217; account, right? Good, I thought so.<\/p>\n<h2><strong>WordPress<\/strong><\/h2>\n<p>You can <a title=\"Wordpress >> Download&#8221; href=&#8221;http:\/\/wordpress.org\/download\/&#8221; target=&#8221;_blank&#8221;>download<\/a> the <a title=\"Wordpress\" href=\"http:\/\/wordpress.org\/\" target=\"_blank\" rel=\"noopener\">WordPress<\/a> installation files and manually unpack them if you want, but I chose to install by checking out the latest stable version from the WordPress repository using Subversion. This will make it very easy to upgrade in future, by just &#8216;switching&#8217; to the newest tag release. Note that this assumes you&#8217;ve already installed Subversion on your system &#8211; if not, please see my post detailing this first. Installing WordPress in this manner is something else that&#8217;s incredibly easy &#8211; just one command. Make sure you run this command from whatever directory you want WordPress to be installed into &#8211; apache2 sets the default web directory to be <strong>\/var\/www<\/strong>, so I&#8217;d suggest starting there. The command to checkout (&#8220;co&#8221;) a specific version of WordPress (3.1.3 in this case) is:<\/p>\n<pre>sudo svn co http:\/\/core.svn.wordpress.org\/tags\/3.1.3 .<\/pre>\n<p>Note the trailing full-stop, which specifies that the files should be checked out to the current directory. This whole process is discussed in more depth in the <a title=\"Installing \/ Updating Wordress with Subversion - wordpress.org\" href=\"http:\/\/codex.wordpress.org\/Installing\/Updating_WordPress_with_Subversion\" target=\"_blank\" rel=\"noopener\">relevant page<\/a> of the official WordPress.org documentation. Once you&#8217;ve installed the actual files, you&#8217;ll need to set up a database for WordPress to use. I&#8217;d include the command here but unfortunately each time I type it in, my WordPress installation thinks I&#8217;m trying a SQL injection attack and I get locked out of my own domain! There&#8217;s plenty of documentation out and about which covers this though. Set up a user for the blog too, which has the necessary permissions to work with the database you&#8217;ve created. Finally, copy<strong> wp-config-sample.php<\/strong> to a new file called <strong>wp-config.php<\/strong> and set up the values as required. You can view the site by navigating to <a title=\"Localhost\" href=\"http:\/\/localhost\" target=\"_blank\" rel=\"noopener\">http:\/\/localhost<\/a> and answering a couple of questions to complete the installation, but don&#8217;t forget to change the &#8220;WordPress URL&#8221; in the settings screen to something like &#8220;http:\/\/myshinynewserver&#8221;, otherwise you may find that the site is served up with references to &#8220;localhost&#8221; in, instead of your server. After that, you should be good to go. Except, that is, if you&#8217;re afflicted by&#8230;<\/p>\n<h3><span style=\"text-decoration: underline;\">The WordPress Blank Screen of Death<\/span><\/h3>\n<p>I carried out all the steps above, but when I tried to view my shiny new blog, all I got was a blank page. The HTML source for the page was blank too. There are hundreds of <a title=\"fullof.bs\" href=\"http:\/\/fullof.bs\/is-your-new-wordpress-26-install-giving-you-a-blank-white-screen-heres-how-to-fix-it\/\" target=\"_blank\" rel=\"noopener\">different<\/a> <a title=\"Blank Page on install page of wordpress - whatilearned2day\" href=\"http:\/\/whatilearned2day.wordpress.com\/2011\/03\/02\/blank-page-on-install-page-of-wordpress-resetting-the-forgotten-root-password-for-mysql\/\" target=\"_blank\" rel=\"noopener\">explanations<\/a>, <a title=\"Solution to WordPress Blank Screen of Death - colinmcnulty.com\" href=\"http:\/\/www.colinmcnulty.com\/blog\/2008\/07\/08\/solution-to-wordpress-blank-screen-of-death\/\" target=\"_blank\" rel=\"noopener\">articles<\/a> and <a title=\"Upgrading WordPress and Blank Page - simos.info\" href=\"http:\/\/simos.info\/blog\/archives\/706\" target=\"_blank\" rel=\"noopener\">blog<\/a> <a title=\"Fixing Blank, Empty or White WordPress Pages after Upgrade - hightechdad.com\" href=\"http:\/\/www.hightechdad.com\/2009\/06\/10\/fixing-blank-empty-or-white-wordpress-pages-after-upgrade\/\" target=\"_blank\" rel=\"noopener\">posts<\/a> which offer advice on how to rectify it. None of them worked for me. I did however, find that in my case there was a very simple solution. I enabled debugging in WordPress by adding the following line to <strong>wp-config.php<\/strong>:<\/p>\n<pre>define(&#039;WP_DEBUG&#039;, true);<\/pre>\n<p>This gave me the following message when I checked the subsequent output in <strong>\/var\/log\/apache2\/error.log<\/strong>:<\/p>\n<pre> [error] [client 127.0.0.1] PHP Parse error:\u00a0 syntax error, unexpected &#039;:&#039; in \/var\/www\/wp-config.php on line 25<\/pre>\n<p>Line 25 is the line which contains the password for the relevant MySQL database. All of my passwords are generated by the <a title=\"GRC Ultra High Security Password Generator\" href=\"https:\/\/www.grc.com\/passwords.htm\" target=\"_blank\" rel=\"noopener\">GRC Ultra High Security Password Generator<\/a>, and include symbols. This didn&#8217;t pose any problems when I set up the user account with MySQL Administrator, but it did include a colon which was enough to completely confuse PHP. This was preventing the system connecting to the database and causing the blank screen of death. I amended the password so it didn&#8217;t contain a colon any more, and suddenly everything instantly worked again. Once you&#8217;ve found your error, don&#8217;t forget to turn debugging off again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The process is covered in quite a lot of good&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[606,607,605,164,608,647,646,249,645,644,651,652,653,649,648,650,654],"class_list":["post-1446","post","type-post","status-publish","format-standard","hentry","category-it","tag-apache","tag-apache2","tag-home-server","tag-lamp","tag-mysql","tag-mysql-administrator","tag-mysql-workbench","tag-php","tag-screen-of-death","tag-wordpress","tag-wordpress-blank-screen","tag-wordpress-blank-screen-of-death","tag-wordpress-no-source","tag-wordpress-respository","tag-wordpress-subversion","tag-wordpress-svn","tag-wordpress-white-page"],"_links":{"self":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/comments?post=1446"}],"version-history":[{"count":0,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1446\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/media?parent=1446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/categories?post=1446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/tags?post=1446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}