Install Phpmyadmin Nginx Ubuntu 16.04 Php 7


Install Phpmyadmin Nginx Ubuntu 16.04 Php 7

Introduction to PhpMyAdmin

PhpMyAdmin is a web-based tool that enables the users to manage their MySQL databases. It also provides a graphical interface allowing users to manage databases, create/modify tables, manage user accounts as well as execute SQL statements. It is written in PHP and may be used on Apache or IIS web servers.

It is a software package that is installed on web servers and enables users to manage databases, create/modify tables, manage user accounts, execute SQL statements, and more. It is used by many webmasters and developers to manage their websites and databases.

In this article, we will explain you how to install phpMyAdmin on Ubuntu 16.04 server with Nginx and PHP 7.0 support.

Prerequisites for Installing phpMyAdmin

Before starting with the installation process, you need to have the following packages installed on your Ubuntu 16.04 server:

  • Nginx web server
  • MySQL or MariaDB database server
  • PHP 7.0 processor

Downloading and Installing phpMyAdmin

The first step is to download the phpMyAdmin package. You can download the latest version of phpMyAdmin from its official website. You can use the following command to download the file:


wget https://files.phpmyadmin.net/phpMyAdmin/4.6.2/phpMyAdmin-4.6.2-all-languages.tar.gz

Once the download is complete, extract the tar archive by running the following command:


tar xzf phpMyAdmin-4.6.2-all-languages.tar.gz

This will extract the files and create a phpMyAdmin folder containing the phpMyAdmin files.

Now, you need to configure Nginx so that it can serve phpMyAdmin files. You can do this by creating a new server block configuration file for phpMyAdmin in the ‘/etc/nginx/sites-available/’ directory.


sudo nano /etc/nginx/sites-available/phpmyadmin

Now add the following lines in the file:


server {
listen 80;
server_name example.com;
root /usr/share/phpMyAdmin;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}

Save and close the file, then enable the configuration by creating a symbolic link.


sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/

Now, check the Nginx configuration for any syntax errors:


sudo nginx -t

If the syntax is correct, you should see the following output:


nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If the configuration syntax is correct, restart the Nginx service to apply the changes:


sudo systemctl restart nginx

Configuring phpMyAdmin

Once Nginx is configured, you need to configure phpMyAdmin. To do this, you need to edit the phpMyAdmin configuration file ‘config.inc.php’. If the file does not exist, you can create it using the following command:


sudo nano /usr/share/phpMyAdmin/config.inc.php

Now add the following lines to the file:


// Servers configuration
$i = 0;

// First server
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';

Save and close the file. The configuration file allows for two different authentication types. The ‘config’ type is used for access control via a username and password in the ‘config.inc.php’ file.

Now, you need to create a MySQL user which will be used to access the phpMyAdmin Panel. You can do this by logging into the MySQL server as the root user and running the following command:


CREATE USER 'phpmyadminuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadminuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Replace ‘password’ with the desired password for the user.

Now, you are ready to access the phpMyAdmin web interface. Open your web browser and type the URL ‘http://example.com/phpmyadmin/’ to access the phpMyAdmin login page. Enter the username and password of the user you created earlier to log in.

Conclusion

In this tutorial we have explained how to install phpMyAdmin on an Ubuntu 16.04 server with Nginx and PHP 7.0. We have also explained how to configure Nginx and phpMyAdmin. We hope it has been helpful for you.

FAQs

  • Q. What does phpMyAdmin do?

    A. PhpMyAdmin is a web-based tool that enables the users to manage their MySQL databases. It also provides a graphical interface allowing users to manage databases, create/modify tables, manage user accounts as well as execute SQL statements.

  • Q. How do I access phpMyAdmin?

    A. You can access the phpMyAdmin login page by entering the URL ‘http://example.com/phpmyadmin/’ in your web browser. You will need to enter the username and password of the user created earlier to log in.

  • Q. How do I configure Nginx for phpMyAdmin?

    A. You can configure Nginx for phpMyAdmin by creating a new server block configuration file for phpMyAdmin in the ‘/etc/nginx/sites-available/’ directory. You can then enable the configuration by creating a symbolic link.

Thank you for reading this article. For more information about how to configure and use phpMyAdmin, please refer to the official documentation or read other articles.