WordPress is a free and open source blogging software, which has the capability to be used as a content management system (CMS) as well. One of the reasons why WordPress is so popular is the ease of installations across the various platforms and the official website has a famous 5 minute install article on WordPress. Before you start installing WordPress on Linux, you should know what exactly we are going to do.
Please note that we would be using Ubuntu 13.04 32-bit desktop edition for the tutorial. Most commands are going to be similar on all linux based systems. However, some of them might be different (apt-get install on Ubuntu, but yum install of Fedora for instance.)
Requirements(PHP, MySQL, Apache):
WordPress needs a web server to run and render web pages dynamically. We are going to use Apache, one of the most popular web servers available today and comes installed in Linux by default. Next, WordPress is written in PHP, which is a server side scripting language, designed specifically for web development. To store your website’s data, WordPress uses MySQL, again one of the most popular relational database management systems in the world.
To run the commands in Linux, you need to open the terminal. In most modern versions of Linux, you can do so by pressing Ctrl + Alt + T.
Installing the Pre Requisites:
As mentioned above, Apache2 comes pre-installed on most modern Linux distributions. However, in case you don’t have Apache2, you can download it from the official website. Alternately, you can install it using the inbuilt installer in Linux by running the command.
sudo apt-get install apache2
The second pre-requisite is PHP. You can download a stable version of PHP from the official website and follow the instructions for install there. Alternately, an easier way to install PHP is by running the following command.
sudo apt-get install php5
You need to install an additional module in PHP5 to run MySQL commands there. You can do it by running.
sudo apt-get install php5-mysql
After installing PHP, the last step is to install MySQL. One way is to download it and follow the instructions there to install it. However, a better way is to run the following command.
sudo apt-get install mysql-server
During installation you would be asked for a password for the user ‘root’. Note that it is very important that you do not forget this password as the root user has all privileges.
Downloading and extracting WordPress:
Your next step would be to head over to the WordPress site and download the WordPress software. After downloading the zip file, you need to extract it in your apache home directory. By default, the path is /var/www/
However, you can change it to your home folder (for eg. /home/your-username/) by opening the file /etc/apache2/sites-enabled/000-default, and changing the value of Document Root to /home/your-username/.
After extracting it, head over to http://127.0.0.1/wordpress to check if you did it correctly. You should be greeted by an error.
Creating a database in MySQL:
Most probably, your server will not be able to create the file by itself owing to a lack of permissions in Linux granted to Apache2, you need to create it manually.
Open MySQL by running the following:
mysql -u root -p
You would be prompted for the password. Enter the password you created during installation.
After you have successfully opened MySQL, create a new database for your wordpress installation by running the following:
create database wordpress;
Setting up WordPress:
After successfully creating the database, click ‘Let’s Go’ to begin.
Enter the database name, the username of MySQL and the password. For security purposes, you can create a new user in MySQL and grant all privileges of the wordpress database to that user.
After WordPress has successfully create a database connection, you would be given a confirmation in the next page. If there are any errors, click ‘Try Again’ and double check the data that you entered.
On successfully creating a connection with the database, you need to click ‘Run the Install’ to start creating the necessary tables for WordPress (don’t worry, that happens in the background).
Put a site title, set the admin user, put a password, set your email (double check your email) and click “Install WordPress”.
You have successfully installed your site. Go to http://127.0.0.1/wordpress/ to double check that it is working.
To login as an admin and manage settings go to http://127.0.0.1/wordpress/wp-admin/
Linux is an operating system which relies heavily on permissions. Apache2 might not have write permissions on your site directory. This can prevent you from changing files or their contents from within the web browser. This involves including and not limited to, the inability of installing themes and plugins. To remove these restrictions, you need to give write permissions to the apache2 user.
In ubuntu, the apache user has the name of ‘www-data’, which means you need to give permissions of write access of your wordpress folder to www-data (or transfer the ownership to www-data). Go inside your wordpress directory and run the following.
sudo chown -R www-data ./
sudo chmod -R g+w ./
Alternately, you can replace “./” by the path to your WordPress folder.