How to Install WordPress 5 On Ubuntu 16.10/16.04 Using LAMP Stack

For those who cannot afford the hustles of developing websites from scratch, there are now several content management systems (CMSs) such as WordPress that you can take advantage of to setup blogs as well as complete websites with a few clicks.

WordPress is a powerful, free and open-source, highly pluggable and customizable CMS that is being used by millions around the world to run blogs and fully functional websites.

It is easy to install and learn, especially for persons who do not have prior website design and development knowledge. With millions of plugins and themes available, developed by an active and dedicated community of fellow users and developers, that you can utilize to tailor your blog or website to work and look just the way you want.

Suggested Read: How to Setup WordPress with LAMP + Postfix as Send-Only Mail Notifications

Requirements:

  1. A dedicated VPS with a registered domain name, I suggest you to go for Bluehost hosting, which offers 50% off, one Free Domain name and Free SSL.

In this post, we shall run through the various steps you can follow, to install the latest version of WordPress 5.3 on Ubuntu 18.10-18.04, Ubuntu 16.10-16.04 and Linux Mint 18-19 with LAMP (Linux, Apache, MySQL and PHP) stack.

Install LAMP on Ubuntu and Linux Mint

First, we shall uncover the various steps for installation of LAMP stack before progressing to install WordPress.

Step 1: Install Apache Web Server

To install Apache web server, issue the command below:

$ sudo apt-get install apache2 apache2-utils 

We need to enable Apache2 web server to start at system boot time, as well start the service as follows:

$ sudo systemctl enable apache2
$ sudo systemctl start apache2

To test whether the server is running, open your web browser and enter http://server_address. The Apache2 default index page will be displayed in case the web server is up and running.

Apache Default Page Under Ubuntu 16.04

Apache Default Page Under Ubuntu 16.04

Note: The Apache default root directory is /var/www/html, all your web files will be stored in this directory.

Step 2: Install MySQL Database Server

Next, we need to install MySQL database server by running the command below:

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

If you want to install MariaDB, you can install it using following command.

$ sudo apt-get install mariadb-server mariadb-client

During the package installation, you will be prompted to set the root user password for mysql as seen in the image below. Choose a good and secure password, then hit the OK button twice to proceed further.

Set MySQL root Password

Set MySQL root Password

The database server deployment is not yet secure, for this reason, issue the following command to harden it’s security:

$ sudo mysql_secure_installation 

Firstly, you will be asked to install the ‘validate_password’ plugin, so type in Y/Yes and press Enter, and also choose the default password strength level. On my system, I already installed it.

Importantly, if you do not want to change the root password, then type N/No when prompted to do so. Answer Y/Yes for the rest of the subsequent questions.

Step 3: Install PHP and Modules

Last but not least, we shall install PHP and a few modules for it to work with the web and database servers using the command below:

$ sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd  

Furthermore, to test if php is working in collaboration with the web server, we need to create a info.php file inside /var/www/html.

$ sudo vi /var/www/html/info.php

And paste the code below into the file, save it and exit.

<?php 
phpinfo();
?>

When that is done, open your web browser and type in the this address http://server_address/info.php. You should be able to view the php info page below as a confirmation.

PHP 7.0 Information

PHP 7.0 Information

Step 4: Install WordPress CMS

Download the latest WordPress package and extract it by issuing the commands below on the terminal:

$ wget -c http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz

Then move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:

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

Next, set the correct permissions on the website directory, that is give ownership of the WordPress files to the web server as follows:

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

Step 5: Create WordPress Database

Execute the command below and provide the root user password, then hit Enter to move to the mysql shell:

$ mysql -u root -p 

At the mysql shell, type the following commands, pressing Enter after each line of a mysql command. Remember to use your own, valid values for database_name, databaseuser, and also use a strong and secure password as databaseuser_password:

mysql> CREATE DATABASE wp_myblog;
mysql> GRANT ALL PRIVILEGES ON wp_myblog.* TO 'your_username_here'@'localhost' IDENTIFIED BY 'your_chosen_password_here';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Go the /var/www/html/ directory and rename existing wp-config-sample.php to wp-config.php:

$ sudo mv wp-config-sample.php wp-config.php

then update it with your database information under the MySQL settings section (refer to the highlighted boxes in the image below):

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** 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', '');

Afterwards, restart the web server and mysql service using the commands below:

$ sudo systemctl restart apache2.service 
$ sudo systemctl restart mysql.service 

Open your web browser, then enter your server address: http://server-address to get the welcome page below. Read through the page and click on “Let’s go!” to proceed further and fill all requested on screen information .

WordPress Installation Wizard

WordPress Installation Wizard

Hoping that everything went on just fine, you can now enjoy WordPress on your system. However, to express any concerns or ask questions concerning the steps above or even provide additional information that you think has not been included in this tutorial, you can use the feedback section below to get back to us.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

183 Responses

  1. Artem says:

    Hi, everything worked well thanks, but when I’m in WordPress and go to customize the site I’m shown the Apache2 Ubuntu Default Page :( and not the site.

    Hope you can help me.
    Thanks

  2. Kim says:

    I stopped at step 2 (with this error) in this guide :(

    The following packages have unmet dependencies:
    mariadb-server : Depends: mariadb-server-10.1 (>= 1:10.1.40-0ubuntu0.18.04.1) but it is not going to be installed
    E: Unbale to correct problems, you have held broken packages.
    

    Do you have any solution to solve this error?

    Thanks, Kim

    • Ravi Saive says:

      @Kim,

      Run the following command to fix these dependencies.

      $ sudo apt-get install -f
      
      • Kim says:

        After running the command: "sudo apt-get install -f".

        I tried to run the command: "sudo apt-get install mariadb-server mariadb-client" again. But still got the same error.

        Is there other things that can solve this problem ??

        Thanks, Kim

        • Ravi Saive says:

          @Kim,

          First remove the installed MariaDB using the following commands.

          $ sudo apt-get remove --purge mariadb-server
          $ sudo apt-get autoremove
          $ sudo apt-get autoclean
          

          Once removed, try to install MariaDB again.

          $ sudo apt-get install mariadb-server mariadb-client
          
  3. Lester says:

    When i try the http://server-address – it shows me the Apache Ubuntu default page, did I miss something?, I was able to access the config file thru http://server-address/wp-admin/setup-config.php.

  4. James says:

    I followed the instructions and this worked great! Built it on an EC2 Instance ion AWS and shut it down over night. When i restarted the server in the morning, It no longer starts the WP site. I have checked the services to ensure Apache and mySQL services are running.

    I’m not a Linux engineer, but what else do i need to check to get it started?

    It all installed fine :(
    Thanks

  5. seth Brunt says:

    Had some issue at the PHP install a bit, but followed these instructions and got it working :-)

  6. dr2234 says:
    #  mysql -u root -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    

    Cannot go any further..

  7. Freeman Phiri says:

    Help please I am stuck on step 3 and I am getting the following error messages:

    E: Couldn't find any package by glob 'php7.0-mysql'
    E: Couldn't find any package by regex 'php7.0-mysql'
    E: Unable to locate package libapache2-mod-php7.0
    E: Couldn't find any package by glob 'libapache2-mod-php7.0'
    E: Couldn't find any package by regex 'libapache2-mod-php7.0'
    E: Unable to locate package php7.0-cli
    E: Couldn't find any package by glob 'php7.0-cli'
    E: Couldn't find any package by regex 'php7.0-cli'
    E: Unable to locate package php7.0-cgi
    E: Couldn't find any package by glob 'php7.0-cgi'
    E: Couldn't find any package by regex 'php7.0-cgi'
    E: Unable to locate package php7.0-gd
    E: Couldn't find any package by glob 'php7.0-gd'
    

    What should I do?

    • Ravi Saive says:

      @Freeman,

      Are you sure you are using Ubuntu 16.10 or 16.04? please confirm this first. If you are using older Ubuntu 14.04, then PHP 7 is not available from the standard Ubuntu repositories (2016-01-02).

      You could use the PPA ppa:ondrej/php.

      $ sudo apt-add-repository ppa:ondrej/php
      $ sudo apt-get update
      $ sudo apt-get install php7.0
      
  8. Catypus says:

    You forgot to delete index.html – Did you test your steps? Ubuntu 16!

  9. Ajay says:

    Hello,

    I have setup vista CP + WP but i am getting issue to edit files through ftp and can’t upload images in admin.

  10. cheerupchuck_ says:

    I am having issues with restarting mysql. It says it failed because the control process exited with error code.

Leave a Reply to cheerupchuck_ Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.