Install WordPress with NGINX PHP7 PHPMyAdmin on Ubuntu

Install WordPress on NGINX PHP7 with PHPMyAdmin Ubuntu16.04
Here is this article we are going to see how we can install WordPress on NGINX with latest and super fast PHP7 with PHPMyAdmin on Ubuntu 16.04 which is newest ubuntu distribution as of now. We will use MariaDB in replacement of MySQL for database uses and will also install Postfix service to basic internal contact form support. Here is a quick list what we are going to use…

  • Ubuntu 16.04 LTS
  • NGINX (Latest version 1.9.15)
  • PHP7.0-FPM (Lightweight PHP)
  • MariaDB (Latest version 10.0.24)
  • PHPMyAdmin (For easy database access and management)
  • Postfix (Basic: Needed for contact forms to work)

Let’s setup a VPS or Dedicated machine which is running on Ubuntu 16.04 LTS, I will suggest LTS only because they have a long term support and stable enough to secure your machine. I personally like DigitalOcean as it is best and leading cloud hosting company based on Fast SSD hard drive which makes things get processed super fast.

Update the Server for Security Patches

Install NGINX

Install PHP7

Now here we need to secure the PHP7.0 since it has a small loop for hackers (don’t be panic) by default for which we need to edit PHP.ini file. We can use any of text editor like nano or vim. In our case we are using my favorite editor nano.

Now find “cgi.fix_pathinfo” without quotation mark. Use Ctrl+W to activate search function in nano editor. Now you will see that its value is set to 1 by default like this cgi.fix_pathinfo=1, so change its value to 0 like this: cgi.fix_pathinfo=0 and save it via Ctrl+O.

Install MariaDB

Since we need to tough the security loopholes let’s make MySQL more secure…

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
– Dropping test database…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Now here we have successfully installed MariaDB. Since managing database from command line interface is time consuming we are going to install PHPMyAdmin here which will let you manage database from a Graphical User Interface.

Install PHPMyAdmin

While setup you will be asked to choose web server (Apache or Lighttpd) where we will choose none (use tab to navigate) and and select Okay. Then we will be asked for configuring database we will chose Yes there and then we will be asked for password for accessing PHPMyAdmin.

Since root user is disabled in this setup we need to create another root user which we can use to login in PHPMyAdmin, here is how to setup a new root user.

Here user can be any user you want to choose and use a strong password for that user.

PHPMyAdmin will be accessible from http://IP_or_DomainName/phpmyadmin just make sure that you have pointed your domain name in advance while accessing PHPMyAdmin by domain name.

Install Postfix

Without Postfix we won’t be able to interact with email functions like forget password email and contact us forms so we need to install one client software and postfix is one which we used here and while setup we do not have to configure anything here just hit okay and let all the value set to default.

Configure NGINX’s Server Blocks

Now delete everything using control+k and paste the following configuration which I have made easy to use.

Do not forget to change the domain name from above configurations. I have used non-www as well as www version of domain name because we can set anyone default in WordPress itself in Settings » General under WordPress Address (URL) and Site Address (URL) sections.

At the end restart all the services once.

Now the most difficult past…

Install WordPress

Now the WordPress Download… and further configs.

Now we have WordPress files ready and now need to connect it with a Database.

  1. Open PHPMyAdmin in a browser and create a database over there. Enter into that database and move to Privileges Tab and click on Add User.
  2. In login information give a username to database, set host to localhost and give a password. (Better you use a Password Generator option there)
  3. Not down Database name, Username and Password. (We need to add them in wp-config.php file)
  4. Under Database for user section Check/Tick on Grant all privileges on database “DATABASE_NAME”.
  5. Now click on Go. (Do not check/tick anything under Global privileges section)

Now we have database ready. Let’s connect WordPress to Database.

Edit database name, username and password; once done save the file. Now go ahead in run WordPress setup from browser via IP or Domain Name if you have pointed that in advanced.

Finally we have installed WordPress on NGINX PHP7 with PHPMyAdmin on latest Ubuntu 16.04.