How to Install WordPress on Ubuntu 12.04 LTS

Let’s be honest, sometimes we don’t necessarily want to start a site from scratch, especially a blog. There’s so many blogging platforms out there, why reinvent the wheel? Arguably the most well known, WordPress, is very easy to install on Ubuntu 12.04 LTS.

First things first, you will need to install WordPress and MySQL (if it’s not already installed):

sudo apt-get install wordpress mysql-server

If you don’t already have a LAMP server setup, you will when this is done as WordPress depends on Apache and PHP (and necessarily modules). MySQL server is not a dependency (I assume because WordPress can run on different databases) so we’ll install it as well. Come to think of it, this could very well be considered a one line solution to setting up a LAMP box.

WordPress itself gets installed to /usr/share/wordpress. Depending on if you are going to be running a single WordPress blog or multiples ones you may link to or copy the directory to a public directory. By default, Apache uses the /var/www directory as your document root. We can link the WordPress code to this directory:

sudo ln -s /usr/share/wordpress /var/www/wordpress

You can adjust the directory accordingly for your needs. Once linked your blog should be available from http://your-servers-ip/wordpress (assuming you didn’t rename the symlink). But, if you try to access it now you will get an error about missing / unreadable configuration files.

Luckily, WordPress comes with scripts to handle setting up our database and configuring the install for us. Be sure to replace your-servers-ip with your server’s IP or the fully qualified domain name for the blog you’re setting up.

sudo sh /usr/share/doc/wordpress/examples/setup-mysql -n wordpress your-servers-ip

Now that the configuration file is created, let’s go ahead and chown all of the files to be owned by www-data the user that runs Apache:

sudo chown www-data /var/www/wordpress -R

Now you can visit your site (http://your-servers-ip/wordpress if you followed this to a T) and you will be presented with the WordPress installation page. Fill out the form and you will be on your way to a working WordPress blog. A word of caution, installing WordPress from the repositories on 12.04 LTS will leave you with WordPress version 3.3.1 and no easy way to update due to local changes to the source. I’m unsure how secure this install of WordPress actually is but know that a lot of folks may favor using the most up to date version of WordPress. If there’s any interest I’ll put together another post about doing a manual install of WordPress on Ubuntu 12.04 LTS.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.