First of all you need to set up LAMP on your Ubuntu machine. If you have not installed LAMP please install it. Read my blog Installing LAMP Stack on Ubuntu and Debian in Just 3 Steps to install LAMP and proceed with the further steps.
There are two methods to download WordPress:
1. cd ~/ 2. wget http://wordpress.org/latest.tar.gz 3. tar xzvf latest.tar.gz
You should have a wordpress named directory in your home directory (or where you prompted when downloading the zip file and extracted it.)
PHP has the capability to extend the language by installing different extension modules according to your needs and requirements. In this step we’ll install two PHP extension modules name gd and libssh2-php.
sudo apt-get update sudo apt-get install php5-gd libssh2-php
If you further want to learn about installing and learning about some PHP Extension Modules then read my blog Understanding Root Directory, Testing PHP Engine and Installing PHP Extensions on Ubuntu
Open your terminal and run the following commands one by one:
1. mysql -u root -p 2. CREATE DATABASE wordpress; 3. quit
Note: for this section I suppose your wordpress directory is in your home directory.
Our wordpress directory contains a file named wp-config-sample.php. Save it as wp-config.php and open it in gedit. Run the following command to do so.
1. cp wordpress/wp-config-sample.php wordpress/wp-config.php 2. gedit wordpress/wp-config.php
1. define('DB_NAME', 'wordpress'); 2. define('DB_PASSWORD', 'yourpassword');
On your localhost you would not like to be asked for the FTP Server related information when installing themes and plug-ins. To avoid this and directly download the plug-ins and themes include the following snippet of code in the ‘wp-config.php’ as shown underlined in the picture below:
Our database and configuration file is ready, now it’s time to copy our wordpress directory to the our root directory to browse the wordpress site on our localhost. Run the following command to copy wordpress directory to the root directory:
sudo rsync -avP wordpress/ /var/www/html/wordpress/
Now, we need to change the permission of the ‘wordpress‘ directory. Prompt to the wordpress directory in the root directory we just copied and run the following command:
sudo chown -R username:www-data *
This command will assign the control of our wordpress directory to www-data user. This is a user web servers used to access the files. In this way the server would be able to write directly to our wordpress directory.
We need to create a directory named uploads inside wp-content directory to hold our uploaded files such as images, videos and etc. Run the following command to do so:
sudo mkdir wp-content/uploads
Our uploads directory needs to change the permission so that the web server itself could write to this directory:
sudo chown-R :www-data wp-content/uploads
Now our web server would be able to write in this directory.
Now we ready to browse our wordpress’ web interface to do a bit more configuration and log into it. Type http://localhost/wordpress and you’ll see the following page:
Fill the required information in the form as shown above and click Install WordPress button. You’ll be asked to log in with a Success Message as show below:
You’ve successfully installed WordPress on your Ubuntu machine. You can start your work immediately but if you are not happy with the default WordPress URL style and want to change then you need to do a bit more configuration. To learn about it read my blog Configuring the Permalinks in WordPress on Ubuntu.