If you are a Linux user, specifically Ubuntu, and want to install WordPress on your system, then this tutorial is for you. In this article, we will guide you step-by-step on how to install WordPress on Ubuntu. Please note that this installation is valid for all flavors of Ubuntu including 10.02 LTS and later.
Before we begin, let’s understand the software and environment we will be using. We will use LAMP to install WordPress on Ubuntu. LAMP is an acronym for an open-source software bundle consisting of Linux, Apache, MySQL, and PHP.
Apache is the web server software that we’re going to use. We could’ve used LiteSpeed or NGINX but they are quite complicated to set up. MySQL is our database software. PHP is an open-source web scripting language that is widely used to build and run dynamic web pages.
For this tutorial, we are using 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.
Let’s get started with the installation process.
Step 1: Installing Apache
The first step is to install Apache. Open the terminal and type the following command:
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
Step 2: Installing MySQL
The next step is to install MySQL. Open the terminal and type the following command:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation, you’ll be 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:
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.
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.
Step 3: Installing PHP
The next step is to install PHP. Open the terminal and type the following command:
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:
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 the content of the info.php file:
“Awesomeness has no charge” – Po the Panda
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.
Step 4: 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 log in 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 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 owners. 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) mysql> exit 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 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, set up 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!