Setting Phpmyadmin Di Nginx Debian 9


Setting Phpmyadmin Di Nginx Debian 9

Introduction

Nginx is a popular web server created for Unix-like operating systems like Debian. It is used for many web-related activities such as serving up webpages, hosting web applications, providing authentication and security, and acting as a reverse proxy for webapplications. One popular application for use with Nginx is phpMyAdmin, an administrative Web interface to manage MySQL databases. This article will show you how to install and configure phpMyAdmin on a Debian 9 system with Nginx.

Prerequisites

Before you can install and use phpMyAdmin, you must have an Nginx web server configured and running on Debian 9. If you don’t have Nginx installed already, please refer to our guide on How to install and configure Nginx on Debian 9 for instructions.

In addition, you’ll need to have a MySQL or MariaDB database server installed and running. If you don’t have a database server setup, please refer to our guide on How to install and configure MySQL on Debian 9 for instructions.

Install Phpmyadmin

The phpMyAdmin package is available in the official Debian repositories. To install it, log in to your server as the root user, and then issue the following apt command.

# apt-get install phpmyadmin

When prompted, select “apache2” as the server that should be automatically configured to run phpMyAdmin. Select “yes” for the dbconfig-common package configuration.

You will be prompted to enter an administrative password for the database that will be used by phpMyAdmin to store its information. Enter a secure password and press enter or tab key to proceed to the next step.

Once the installation is complete, you need to make some adjustments to the configuration files to get phpMyAdmin to work correctly.

Configure phpMyAdmin with Nginx

Once phpMyAdmin is installed, you’ll need to configure it for use with Nginx. Begin by creating a new Nginx configuration file for phpMyAdmin.

# nano /etc/nginx/sites-available/phpmyadmin.example.com

Next, add the following content to the newly created file.

[server]

server_name phpmyadmin.example.com;

root /usr/share/phpmyadmin;

index index.php index.html index.htm;

location / {

try_files $uri $uri/ =404;

}

location ~ .php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

}

]

Save the file and exit the text editor. To enabled the newly created configuration file, issue the following command.

# ln -s /etc/nginx/sites-available/phpmyadmin.example.com /etc/nginx/sites-enabled/

Now, you’ll need to create a self-signed SSL certificate for your domain.

# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Next, configure Nginx to use the newly created certificate.

# nano /etc/nginx/sites-available/phpmyadmin.example.com

Add the following content to the file.

server {

listen 443 ssl;

server_name phpmyadmin.example.com;

ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;

ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

root /usr/share/phpmyadmin;

index index.php index.html index.htm;

location / {

try_files $uri $uri/ =404;

}

location ~ .php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

}

}]

Save the file and exit the text editor. Then, check if the syntax of your configuration is correct. To do that, issue the following command.

# nginx -t

If the command returns no errors, restart the Nginx service to apply the changes.

# systemctl restart nginx

Configure and test Phpmyadmin

Now that phpMyAdmin is configured, we need to create the configuration file to make it accessible from the web. To do that, create a new phpMyAdmin configuration file with the following command.

# nano /usr/share/phpmyadmin/config.inc.php

Add the following content to the file.

$cfg['blowfish_secret'] = 'sEyjfX#{9HYmZq*8^a';
$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['allow_no_password'] = true;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

Save the file and exit the text editor. Now, you can access phpMyAdmin by browsing to https://phpmyadmin.example.com you should be greeted by the phpMyAdmin login page.

Conclusion

Now you have a working phpMyAdmin installation running on your Debian 9 system with Nginx. You can use phpMyAdmin to manage your MySQL or MariaDB databases. There are more options available for configuring phpMyAdmin; please refer to the official phpMyAdmin documentation for a more in-depth guide.

FAQs

  • Q: What is required to install phpMyAdmin on Debian 9 with Nginx?
  • A: You must have an Nginx web server and a MySQL or MariaDB database server installed and running on your system.

  • Q: How do I access phpMyAdmin from the web?
  • A: You can access phpMyAdmin by browsing to https://phpmyadmin.example.com.

Thank you for reading this article. Please feel free to read other articles on our website to learn more about setting up Nginx and other web services on your Debian 9 system.

Leave a Reply

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