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.
[email protected]:~$ sudo mysql_install_db [sudo] password for sourav: Installing MySQL system tables... OK Filling help tables... OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h ubuntu password ‘new-password’
Alternatively you can run:
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
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> DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm </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 <h3 align="center">"Awesomeness has no charge" - Po the Panda</h3> phpinfo(); ?>
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 sudo wget http://wordpress.org/latest.tar.gz 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:
[email protected]:/var/www$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 44 Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> CREATE DATABASE wpubuntu;
Query OK, 1 row affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
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 User Name: root Password: qwerty (or whatever password you've used for the root user) Database Host: localhost 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!