How To Install and Secure phpMyAdmin with Nginx on an Ubuntu 14.04 Server
How To Install and Secure phpMyAdmin with Nginx on an Ubuntu 14.04 Server
phpMyAdmin is a free and open-source administration tool for managing MySQL and MariaDB databases. Nginx is a high-performance web server that can also be used as a reverse proxy. In this tutorial, you will learn how to install and secure phpMyAdmin with Nginx on an Ubuntu 14.04 server.
Step 1: Update the Server
The first step is to update the server to the latest software packages. You can do this by running the following command:
sudo apt-get update
Step 2: Install Nginx
You can install Nginx on Ubuntu 14.04 by running the following command:
sudo apt-get install nginx
Once the installation is complete, start the Nginx service by running:
sudo service nginx start
Step 3: Install phpMyAdmin
You can install phpMyAdmin on Ubuntu 14.04 by running the following command:
sudo apt-get install phpmyadmin
During the installation process, you will be prompted to select a web server. Choose Nginx and press Enter. You will also be prompted to configure the database for phpMyAdmin. Choose Yes and enter the root password for MySQL.
Step 4: Configure Nginx for phpMyAdmin
Now that phpMyAdmin is installed, you need to configure Nginx to serve the phpMyAdmin files. Open the Nginx default configuration file by running:
sudo nano /etc/nginx/sites-available/default
Find the server block and add the following lines:
location /phpmyadmin {
alias /usr/share/phpmyadmin/;
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Save and close the file. Then, restart Nginx by running:
sudo service nginx restart
Step 5: Secure phpMyAdmin
By default, phpMyAdmin is not secured and can be accessed by anyone with the correct URL. To secure phpMyAdmin, you need to create an Nginx password file and configure Nginx to use it. You can do this by running the following commands:
sudo apt-get install apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd username
Replace "username" with a username of your choice. You will be prompted to enter and confirm a password. Once you have created the password file, open the Nginx configuration file again by running:
Комментарии
Отправить комментарий