We’ve covered how to install WordPress on a Mac and Windows environment. So why should our favorite Linux based OS be left out? Here’s a tutorial that will show you how to install WordPress on Ubuntu. Please note that this installation is valid for all flavors of Ubuntu including 10.02 LTS and later. (If you’re using an even older version, its time for an upgrade!)
For a greater part of the installation process, we’re going to use an excellent terminal based editor called Nano. Chances are your already have it installed. In case you don’t, you can install it by typing the following command in the terminal:
sudo apt-get install nano
There are a lot of codes to be copy pasted. I would recommend copy-pasting them instead of typing them. You could use Ctrl+Shift+V to directly paste the content of the clipboard onto the terminal.
Knowing your Software and Environment
We’re going to use LAMP to install WordPress on Ubuntu. LAMP is an acronym for an open-source software bundle consisting Linux, Apache, MySQL and PHP.
- Apache: This is the web server software that we’re going to use. We could’ve used LiteSpeed or NGINX but they are quite complicated to setup.
- MySQL: This is our database software.
- PHP: It is an open source web scripting language that is widely use to build and run dynamic web pages.
As for our tutorial’s OS environment, I’m running Ubuntu 12.04 LTS x86, with all software updated to their latest version. You are free to use any flavors of Ubuntu, be it Lubuntu, Kubuntu or Mubuntu – the process should be the same. To update your software to the latest version, open the terminal and type:
sudo apt-get update
Installing and configuring the Software:
sudo apt-get install apache2
Press Y and let the installation roll. The following lines mark the end of a successful installation:
Setting up apache2-mpm-worker (2.2.22-1ubuntu1.2) ... * Starting web server apache2 [ OK ] Setting up apache2 (2.2.22-1ubuntu1.2) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation, you’ll asked to set a root password for MySQL.
Enter something that’s easy to memorize. Let us use “qwerty” as our password. Once the installation completes, we should activate the database using the following command:
The following piece of information comes pretty handy in case we forget our password.
sourav@ubuntu:~$ sudo mysql_install_db<br /> [sudo] password for sourav:<br /> Installing MySQL system tables...<br /> OK<br /> Filling help tables...<br /> OK</p> <p>To start mysqld at boot time you have to copy<br /> support-files/mysql.server to the right place for your system</p> <p>PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !<br /> To do so, start the server, then issue the following commands:</p> <p>/usr/bin/mysqladmin -u root password 'new-password'<br /> /usr/bin/mysqladmin -u root -h ubuntu password 'new-password'</p> <p>Alternatively you can run:<br /> /usr/bin/mysql_secure_installation</p> <p>which will also give you the option of removing the test<br /> databases and anonymous user created by default. This is<br /> strongly recommended for production servers.</p> <p>See the manual for more instructions.</p> <p>You can start the MySQL daemon with:<br /> cd /usr ; /usr/bin/mysqld_safe &</p> <p>You can test the MySQL daemon with mysql-test-run.pl<br /> cd /usr/mysql-test ; perl mysql-test-run.pl</p> <p>Please report any problems with the /usr/scripts/mysqlbug script!
This marks the end of MySQL database installation.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-gd php5-xmlrpc php5-curl
It is necessary to add php to the directory index, to serve the relevant php index files. This is the first time we’re going to use nano.
sudo nano /etc/apache2/mods-enabled/dir.conf
This opens nano in the same terminal window. Overwrite the contents of the dir.conf file with the following text:
<IfModule mod_dir.c><br /> DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm<br /> </IfModule>
Press Ctrl+O to save and Ctrl+X to exit nano.
Now we create a test php file to make sure everything is running fine:
sudo nano /var/www/info.php
This should be content of the info.php file:
<?php<br /> <h3 align="center">"Awesomeness has no charge" - Po the Panda</h3><br /> phpinfo();<br /> ?>
Restart the Apache web server by typing the following command:
sudo service apache2 restart
Open your browser and type the following URL:
And you should get something like this:
This concludes our preliminary setup.
Setting up WordPress
Part 1: Download and installation
Run the following commands in the terminal.
cd /var/www<br /> sudo wget http://wordpress.org/latest.tar.gz<br /> sudo tar -xzvf latest.tar.gz
This set of commands downloads and extracts the WordPress files inside the www directory (that’s the base directory of the Apache webserver). The installation of WordPress is accessible under http://localhost/wordpress.
Part 2. Creating a new MySQL database
We will now create a new MySQL database called “wpubuntu”. Remember we set the root password to “qwerty” in our tutorial. Let us login to the MySQL terminal:
mysql -u root -p
Enter your root password and the MySQL terminal should open, which is indicated by the prompt “mysql>”.
Next, we type the MySQL command for creating a new database:
CREATE DATABASE wpubuntu;
And finally we exit the MySQL terminal by entering:
Here is an overview of the entire process:
sourav@ubuntu:/var/www$ mysql -u root -p<br /> Enter password:<br /> Welcome to the MySQL monitor. Commands end with ; or \g.<br /> Your MySQL connection id is 44<br /> Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)</p> <p>Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.</p> <p>Oracle is a registered trademark of Oracle Corporation and/or its<br /> affiliates. Other names may be trademarks of their respective<br /> owners.</p> <p>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</p> <p>mysql> CREATE DATABASE wpubuntu;<br /> Query OK, 1 row affected (0.00 sec)</p> <p>mysql> FLUSH PRIVILEGES;<br /> Query OK, 0 rows affected (0.00 sec)</p> <p>mysql> exit<br /> Bye
Now you have successfully created a new MySQL database ready to be used by WordPress.
Part 3. Configuring WordPress
Open the following URL in your browser:
You should see this image:
Click on Create Configuration File, followed by Let’s Go in the next step. In the 3rd step, enter the details as follows:
Database Name: wpubuntu<br /> User Name: root<br /> Password: qwerty (or whatever password you've used for the root user)<br /> Database Host: localhost<br /> Table Prefix: pxa_
Click on Submit. If you’ve followed the steps correctly, you should get this message:
In the following step, setup your site title, user and password. I would recommend un-checking the “Allow search engines to index this site” box since we don’t want our offline/experimental site to be crawled by search engines.
And voilà, you have a fully working offline installation of WordPress on Ubuntu!