Linux for WordPress Developers – Part 1

David Nash wordpress Leave a Comment

I’ve used Linux for years, and I think it’s perfect for any WordPress developer. When the site is live, chances are it’ll be running on a Linux server. So it makes sense to do your WordPress development on the same system that will be running your finished site.

Not only does it cut down on nasty last-minute surprises, it also means that when those surprises do arise, you’ll know what to do when they do occur.

I’ve run Ubuntu for a while and think it’s pretty good. I use it for the same reason I develop with WordPress – Ubuntu has the biggest user base and the best chance of your issues being already solved by someone else.

I’m running Ubuntu 15.04, with all software updated automatically. (There’s a newer version of Ubuntu out but I like to wait for other people to work out the kinks 🙂 )

Let’s look at the different elements involved in running WordPress on a Linux system.

Web server

I use Apache. WordPress requires PHP and MySQL, which I also have installed. I use subdomains so that I can offer my clients access to what I’m working on so they can give feedback.

I visit my web host cpanel and add a C-NAME to point from eg demo.davidnash.com.au to the external IP of my router (I have a static IP, you may want to look into dynamic DNS services). I configure my router to pass any traffic on the web port (Port 80) through to my laptop.

Then I add the new domain to my /etc/hosts file:

127.0.0.1	localhost demo.davidnash.com.au demo2.davidnash.com.au

Now my system knows that when a program wants something from demo.davidnash.com.au it should look at the IP 127.0.0.1.

Here’s an example Apache config file I have for the demo site:

<VirtualHost *:80>
	ServerName demo.davidnash.com.au 
	DocumentRoot /var/www/demo

	
		Options -Indexes +FollowSymLinks +Multiviews
		AllowOverride All 
		Order allow,deny
		allow from all
	
	

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

I have this saved in /etc/apache/sites-available/demo.davidnash.com.au.conf. I create a soft link in sites-enabled too so that Apache knows it should run.

The in /var/www/demo I have the standard .htaccess file with a little extra to password protect it:

AuthName "Hello?" 
AuthType Basic 
AuthUserFile /a-secret-place/.htpasswd 
require valid-user

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress

then in /a-secret-place/.htpasswd I have this:

test:R4HNAwY9Ihzxw

Then when I send the client the link to demo.davidnash.com.au they need to enter test/test as the username and password to access the site (in reality my passwords are better than this). One of the main reasons I password protect the files is to doubly ensure that search engines won’t index them.

But first things first – installing WordPress. I create a folder /var/www/demo and download the latest version from WordPress. I extract the file into my demo directory.

Then in my browser I go to demo.davidnash.com.au I’m presented with the WordPress installation wizard.

In Part 2 I’ll discuss setting up a MySQL database for WordPress.

Leave a Reply

Your email address will not be published. Required fields are marked *