How to Install LAMP and WordPress on Ubuntu

LAMP (Linux, Apache, MySQL and PHP) is a package name for the installation of Apache server, MySQL database and PHP performed on a Linux machine. Similar packages (also available as application) named as WAMP and MAMP are available for Windows and Mac operating systems respectively. To install and use a server based application like WordPress (for development and testing purpose) on a local machine, you need to first install these packages on the machine. Recently, I installed LAMP and WordPress on couple of Ubuntu machines and here is what I did.

WordPress and LAMP in Ubuntu

Installing LAMP first!

Open the terminal on Ubuntu. Execute below commands to complete the tasks mentioned,

1. Install Apache

sudo apt-get install apache2

2. Install MySQL

sudo apt-get install mysql-server

3. Install PHP

sudo apt-get install php5 libapache2-mod-php5

4. Restart Apache Server

sudo service apache2 restart

Now open any web browser e.g. Firefox and open the URL http://localhost and it should show a message saying ‘It Works’.

Install WordPress

As the Apache server is running on your Ubuntu machine, now it is time to go ahead and start with the installation of WordPress on localhost. Follow the steps below,

1. Download the latest version of WordPress


Unzip the same,

tar -xzvf latest.tar.gz

Unzipped folder ‘wordpress’ should appear inside the Home directory of Ubuntu.

Create Database and User

For the installation of WordPress, you need to create a database in MySQL and also assign a username and associated password with full authority of that database to the user.

Login to MySQL shell to execute MySQL commands from terminal,

mysql -u root -p

Execute below commands one by one on terminal,

CREATE USER wordpressuser@localhost;
SET PASSWORD FOR wordpressuser@localhost=
IDENTIFIED BY 'password';

Now you are out of MySQL shell. It’s time to move on.

Create wp-config.php file (Configuration File)

WordPress packages comes with wp-config-sample.php and by editing the content of this file, we can create wp-config.php. Execute following command on terminal to create a copy of the sample file.

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Open wp-config.php for editing,

sudo nano ~/wordpress/wp-config.php

Update Database, Username and Password in wp-config.php file then save and exit.

Time to move the ‘wordpress’ folder to /var/www/ folder. Execute following command on terminal.

sudo rsync -avP ~/wordpress/ /var/www/

Change permission for the folder ‘wordpress’. first go inside the folder,

cd /var/www/

Give read-write permission to the Apache user,

sudo chown username:www-data /var/www -R
sudo chmod g+w /var/www -R

Done. Go ahead and open the URL http://localhost/wordpress/wp-admin on browser.

If you are seeing the error message as “Your PHP installation appears to be missing the MySQL extension which is required by WordPress“, then go ahead and execute the following command on terminal,

sudo apt-get install php5-mysql

Restart Apache server,

sudo service apache2 restart

Re-open the URL http://localhost/wordpress/wp-admin on your browser and see if the WordPress installation page opens.

Installing GD Library

WordPress uses GD libraries for few functionalities and that’s why it is recommended to install GD library as well. Execute the below command on terminal to install the same.

sudo apt-get install php5-gd

Your WordPress installation must be up and running on LAMP Ubuntu. Go ahead and start the development + testing tasks on your awesome Ubuntu system.


Install phpMyAdmin to manage the Database

Execute this command on terminal,

sudo apt-get install phpMyAdmin

After that, you need to modify the apache2.conf file available inside the /etc/apache2/ folder. Use terminal to do the same,

sudo gedit /etc/apache2/apache2.conf

Now add the following piece of line at the bottom of this apache2.conf file,

Include /etc/phpmyadmin/apache.conf

Restart the Apache server,

sudo service apache2 restart

Well, now you have WordPress installed on LAMP server running on Ubuntu and you can see the database through http://localhost/phpmyadmin URL in browser.

Sanjeev Mishra is a professional blogger and an Internet Marketing Consultant based in India. He has built the Internet Techies to provide you updates in technology and web application area.