Install WordPress On Ubuntu 16.04 LAMP

Have you just planned to start a website with WordPress? Do you need some information about how can you make your WordPress site run on Ubuntu 16.04(Xenial Xerus) or later? Here is, How to Install WordPress on Ubuntu 16.04 with LAMP stack.

WordPress is a popular open source content management system with over 2.5 billion installs. It also comes with a lot of plugin and themes that make it easy for beginners to enhance site functionality and customize the visual parts of a website. WordPress can be also used to make a fully featured and powerful website with a lot of functionality.

It is also easy to install and learn. If you are an absolute beginner and want to start your first website from scratch, Start with WordPress. Here in this tutorial, we will show you how to install WordPress on Ubuntu 16.04 with LAMP (Linux, Apache, MySQL, PHP) stack.


In order to start WordPress installation with LAMP on Ubuntu 16.04, We need a few things to prepare.

  • Ubuntu 16.04 server installation: You need to setup Ubuntu 16.04 (Xenial Xerus) on your VPS server. In my case, I’m going to use Vultr’s $5 instance with Ubuntu 16.04 x64 as server type.
  • Domain (Optional): You also need a registered domain name pointing your server IP address where you want your WordPress installation goes live.
  • SSH Access: Make sure that you have root access to your server using SSH. In Windows, you can access your server through SSH using putty.

Install LAMP On Ubuntu 16.04 (Xenial Xerus)

The very first step in WordPress installation after basic Ubuntu 16.04 server configuration is Installing Apache, MySQL, and PHP. To do so, Follow the instructions below and If you already have LAMP stack installed on your server, Click here to jump directly to the WordPress installation steps:

Install Apache Web Server

Apache is a most widely used open source web server software.

In order to run any kind of web application that server files over HTTP like WordPress, Drupal or Joomla, require a web server software that use HTTP to process the request and serve files. Most of the WordPress hosting provider use Apache web server software. However, WordPress can run on other web server software like Nginx or Lighttpd as well.

To install Apache web server execute the command below:

sudo apt-get install apache2

Now direct your web browser to your server IP or domain and you should see the default page of Apache like below:

Apache Default Webpage

If you see the page after browsing your server IP, That’s mean Apache is working.

Install MySQL Database Server

WordPress uses MySQL database management system to store and organize data. In this step, We will install MySQL database in Ubuntu 16.04.

In order to install MySQL database, Issue the following command:

sudo apt-get -y install mysql-server mysql-client

Above the command will start installing MySQL database server on your Ubuntu 16.04. It also needs some info like root user password that will be prompted during MySQL server package installation.

MySQL root user password

Type a secure password when prompted and hit enter twice to proceed further.

The MySQL database server is installed. Now you need to secure the installation by executing the command below into your terminal:

sudo mysql_secure_installation

During the session, you will be asked to enter MySQL root user password that you have set during installation and other security settings like:

  • VALIDATE PASSWORD PLUGIN: Firstly you will be asked for install the VALIDATE PASSWORD PLUGIN that check your password strength. In my case, I’ve chosen not to setup this plugin. If you want to install VALIDATE PASSWORD PLUGIN type y and choose the password strength level.
  • Change the password for root: You will also be asked for change the root user password. Answer n for no at this prompt to leave root user password unchanged.
  • Remove anonymous users: In this prompted answer y for yes and hit enter to remove some anonymous users.

At this point, The MySQL server has been installed and now we can move ahead for further steps.

Install PHP 7 and PHP Extensions

WordPress is written using PHP scripting language. You must have PHP installed on your Ubuntu 16.04 server to run WordPress.

Here is the command/code to install PHP 7 and some popular PHP extension that you may need to enhance your WordPress capabilities:

sudo apt-get install php php-curl php-gd php-mbstring libapache2-mod-php php-mcrypt php-mysql php-xml php-xmlrpc

You can also install additional PHP extension using apt-get as demonstrated above.

After that, we need to restart Apache web server to leverage these new installations. To restart Apache:

sudo service apache2 restart

At this point, We need to create a info.php file to test if PHP is working in collaboration with your Ubuntu 16.04 web server. To do that, follow the process next.

Create a info.php file in your web root directory /var/www/html/:

sudo nano /var/www/html/info.php

Now paste the below content to info.php:


Exit the editor by pressing Ctrl + x. You will be asked to save the modified file, simply type y and hit enter to save the changes.

Once you have done with the info.php file, open your browser and visit http://your-server-ip/info.php. You should be able to view the PHP information page like this:

PHP Information Page

Now you have LAMP stack installed on your Ubuntu 16,04.

Install WordPress

Now you are ready to start with WordPress installation. Below are the steps of WordPress installation.

Step 1: Create MySQL Database

As I wrote earlier, WordPress uses MySQL database to store and organize data. In an earlier step, We have installed MySQL database server, Now we need to create a database for WordPress.

To create MySQL database, issue the following command and type root user password when prompted for and hit enter:

mysql -u root -p

After that, you should be on the MySQL shell.

Note: We are going to create MySQL wp_database, database_username and database_password. Make sure to use your own DB name, DB User and a secure DB password.

Let’s create a database:

CREATE DATABASE wp_database;

Create a user and grant permission:

GRANT ALL PRIVILEGES ON wp_database.* TO 'database_username'@'localhost' IDENTIFIED BY 'database_password';

Flush privileges and exit from MySQL shell


Step 2: Download and extract WordPress

tar -xzvf latest.tar.gz

Move the extracted files to Apache server’s root web directory:

sudo rsync -av wordpress/* /var/www/html/

Now we need to set appropriate permission to the web directory:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

We are now ready to process further step.

Step 3: Start WordPress Installer

At this step, We are going to run WordPress installer.

Visit your server IP or domain using a web browser and you will get a WordPress installer page asking you for language selection.

WordPress Installer Welcome page

Select the language of your WordPress installation and click Continue button.

The welcome screen will show up, like this:

Welcome to the WordPress installation

Click on the Let’s go! button and provide MySQL database connection information that you have created in step 1.

WordPress Database Connection Details

You should leave Database Host and Table prefix field at its default and click on the Submit button to process further.

Run The Install

Click on Run the install button and you will be asked for provide site information like Site Title, User details etc.

WordPress site information

Once you entered site information and user details, Click on the Install WordPress button to finish the installation.

WordPress install Success

If you don’t receive any fatal error, You should get a success message like above. Click on the Login button to log in your WordPress site.

That’s it, Now you have a WordPress installed on Ubuntu 16.04 server.

Hopping, Everything went as shown here. If you have received any error, please let us know using the comments below. Also don’t forget to let us know your feedback, suggestion or questions concerning any of the steps above.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive website improvement tips and tutorials.


We'll periodically send useful information, tips & tutorials to improve your website performance, conversion optimization, SEO and design tweaks to make your website better.

Thank you for signing up!

Please check your email and click the link provided to confirm your subscription.

Powered by Rapidology
  • serg
    August 11, 2017 at 12:54 pm

    not working

Post a Comment