Sujay Kundu

Sujay Kundu

Sujay Kundu is a Certified Web developer and Digital Marketing Expert. He is currently working as Nodejs Developer at Katerra. Know more about him..

Setting up Wordpress on Linode VPS using Ubuntu 16.04

Posted on May 1, 2019

In this tutorial on how to install wordpress on Ubuntu 16.04 LTS Linode VPS Server. Follow this guide step by step if your VPS doesnot provides a cPanel to install the LAMP Stack or Wordpress directly.

  1. Login to your server using the terminal
# ssh root@

It will ask password for the root server

// Enter Password

  1. Once you are inside. We need to create directory for our website
root@localhost:~# cd ..
root@localhost:~# cd var/www
root@localhost:~# mkdir
root@localhost:~# cd
  1. Now we are ready to install wordpress, for wordpress we have some prerequisites like Apache Web Server and Mysql Server

Install Wordpress

Step 1. Install Apache Web Server

root@localhost:~# apt-get install apache2

After the installation is complete, you should start and enable Apache to start automatically upon server reboot with:

root@localhost:~# systemctl start apache2
root@localhost:~# systemctl enable apache2

To check the status of your Apache server and make sure it is up and running, you can run the following command

root@localhost:~# systemctl status apache2

To verify that Apache is running, you can also open your web browser and enter your server IP address, (e.g. http://your_server_ip_address). If Apache is successfully installed you should see the Apache default welcome page. (yourserverip_address will look something like

Step 3. Install the MySQL Database Server

The next step is to install the MySQL database server which will be used for the data storage of your WordPress site. MySQL is one of the most popular database management systems. To install MySQL on your system, execute the following command and press Y to continue:

root@localhost:~# apt-get install mysql-server

During the installation, you will be asked to enter a password for the MySQL root user. Make sure you enter a strong password.

In order to improve the security of your MySQL server, we recommend that you run the mysqlsecureinstallation script by typing the following command:

root@localhost:~# mysql_secure_installation

This script will help you to perform important security tasks like setting up a root password, disable remote root login, remove anonymous users etc.

After you have answered all the questions you can now go ahead and start the database server and enable it to automatically start upon boot, with:

root@localhost:~# systemctl start mysql
root@localhost:~# systemctl enable mysql

Step 4. Install PHP

You proceed with this tutorial for installing PHP 7.1 Setting up PHP 7.1 on Ubuntu 16.04

Step 5. Install phpMyAdmin

Once Apache, PHP and MySQL are installed, we can go ahead and install phpMyAdmin, The package is included in the official Ubuntu 16.04 repository and it can be easily installed with the command below:

root@localhost:~# apt-get install phpmyadmin

phpMyAdmin will be installed along with its dependencies and all necessary PHP modules.

When you will be prompted to select a web server to configure, hit the space bar to select Apache2 and Enter to confirm and continue

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Configuring phpmyadmin tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
x Please choose the web server that should be automatically configured to run phpMyAdmin.  x
x                                                                                          x
x Web server to reconfigure automatically:                                                 x
x                                                                                          x
x    [ ] apache2                                                                           x
x    [ ] lighttpd                                                                          x
x                                                                                          x
x                                                                                          x
x                                                                                      x
x                                                                                          x

On the next screen, select YES to configure a database for phpMyAdmin with dbconfig-common

qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Configuring phpmyadmin qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
x                                                                                                           x
x The phpmyadmin package must have a database installed and configured before it can be used.               x
x  This can be optionally handled with dbconfig-common.                                                     x
x                                                                                                           x
x If you are an advanced database administrator and know that you want to perform this configuration        x
x  manually, or if your database has already been installed and configured, you should refuse this option   x
x Details on what needs to be done should most likely be provided in /usr/share/doc/phpmyadmin.             x
x                                                                                                           x
x Otherwise, you should probably choose this option.                                                        x
x                                                                                                           x
x Configure database for phpmyadmin with dbconfig-common?                                                   x
x                                                                                                           x
x                                                                                                  x
x                                                                                                           x

Step 6. Set the password for the phpMyAdmin User

and finally set a password for the ‘phpmyadmin’ user in MySQL

With this step, the installation of phpMyAdmin is completed.


Step 7. Test and verify phpMyAdmin installation

You can access it at http://yourIPaddress/phpmyadmin and logi with your MySQL username and password.

Finally phpMyAdmin is installed !

With this last step, our LAMP stack installation and configuration has been completed.

Step 8. Intall Wordpress

We can now move on to the Wordpress Installation. We will download and place the Wordpress Installation in the default web server document root directory (/var/www/html)

Let’s move to this directory with:

# cd /var/www/html

And Download the latest Wordpress installation from the official with wget:

# wget -c

Then, extract the file with:

# tar -xzvf latest.tar.gz

All the WordPress files will be now placed in the wordpress directory in /var/www/html/wordpress

This will extract all the wordpress files in wordpress folder

So we need to rename this wordpress folder to match our domain, otherwise the wordpress will be installed to So to use wordpress with we need to rename wordpress.

To rename :

# mv /var/www/html/wordpress /var/www/html/

This will create a new folder “” and inside it will be with the extracted wordpress files.

We also need to set the correct permissions of this directory so our Apache web server can access these files. To give ownership of the WordPress files to our Apache web server, run the following command:

# chown -R www-data:www-data /var/www/html/

Step 6: Create a database for Wordpress

Now, we will create our MySQL database for our Wordpress site. Login to your MySQL server with the following command and enter your MySQL root password:

# mysql -u root -p

To create a new databas for our Wordpress installation, run the following commands:


You can replace the database name (YOURDBNAME) and the MySQL user name (YOURNAME) with your own names. Also, make sure to replace “YOURPASSWORD” with an actual, strong password.

Once the database is created, we will need to add this information to the WordPress configuration file.

Make sure you are inside the /var/www/html/ directory and run the following command to rename the sample configuration file:

root@localhost:~# mv wp-config-sample.php wp-config.php

Now open the wp-config.php file with your favourite text editor, for example:

# nano wp-config.php

And update the database settings, replacing databasenamehere, usernamehere and passwordhere with your own details:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_db');

/** MySQL database username */
define('DB_USER', 'wordpress_user');

/** MySQL database password */

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Save and exit the file.

Restart your Apache and MySQL server with:

systemctl restart apache2
systemctl restart mysql

Now we need to connect our domain with the server.If you have a valid domain name, and you want to use it to access your Wordpress, you will need to create a bew Apache Virtual Host File.

# nano /etc/apache2/sites-available/

And add the following content to the file ( you can replace with your actual domain name):

<VirtualHost *:80>

DocumentRoot /var/www/html/

ErrorLog ${APACHE_LOG_DIR}/yourdomain.com_error.log
CustomLog ${APACHE_LOG_DIR}/yourdomain.com_access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


Then we need to enable the virtual host we have just created, run the following commands: (there are two ways to do so) :

Either run this command :

# a2ensite


Another alternative way to do this is by creating a symbolic link for your virtual host in /etc/apache2/sites-enabled:

# ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

Once you enable the virtual host, using either of above methods, you will need to restart the Apache web server:

root@localhost:~# systemctl restart apache2

Step - Connect the domain to ip address

In order to connect our domain to our wordpress, we need to change the DNS settings for our domain to redirect to our servers ip address.

We need to create a A record and point it to servers IP Address

should change your DNS setting something like this

TYPE     NAME         VALUE                TTL

A         @      YOUR_SERVER_IP_ADDRESS    600s

CNAME     www          @                    1hr

Now the domain is connected, and should be up and running the Wordpress Setup on your domain !