• Compute
    Compute

    Configure a popular Linux OS or use popular developer Tools

  • Cloud hosting
    Cloud hosting

    Host a VPS in the Cloud in seconds

  • Collaborate, CMS, CRM`s
    Collaborate, CMS, CRM`s

    Collaborate with these popular CMS, CRM & collaboration tools

  • Database & E-Commerce
    Database & E-Commerce

    Create a database or an E-Commerce environment in seconds

Installing and Configuring NGINX with phpMyAdmin

In this guide, we're going to briefly cover installing and configuring NGINX alongside phpMyAdmin.


First off, we want to ensure that our system is up to date and on the latest packages. We are starting with a fresh VPS in this guide, however, you will be able to achieve this on an existing system as well. 

Please ensure that you have a proper backup solution in case things end up going awry when attempting to update an existing server. 

The command below will update your packages and then upgrade them to the latest version. The -flag will automatically accept these changes. You can choose to leave this off if you'd like to manually inspect what will be upgraded before the operation proceeds.


( We recommend doing this as a user other than "root" however if you understand the security implications of using the root account, you may proceed with it. If you need help setting up a new non-root user, please visit --> https://help.skysilk.com/support/solutions/articles/9000126208-how-to-create-new-users-and-grant-sudo-privileges-to-users-on-linux )


(Root user does not need to add sudo to these commands. It is only required if you are using the guide above and running the commands as a user other than root. We will be proceeding as if using a non-root user)


sudo apt update && sudo apt upgrade -y


Next, we will install NGINX, mysql-server, gcc, make, autoconf, libc-dev, pkg-config, php-fpm and finally libmcrypt-dev, again utilizing the -y flag to automatically accept the changes:


sudo apt install nginx php7.2-fpm php-dev mysql-server gcc make autoconf libc-dev pkg-config php-pear -y

sudo apt install libmcrypt-dev -y

sudo pecl channel-update pecl.php.net

sudo pecl install mcrypt-1.0.1

When "libmcrypt prefix? [autodetect] :" comes up, press enter

sudo apt install phpmyadmin


When the prompt for phpMyAdmin comes up asking to select Apache2 or Lighttpd - press tab to select OK and press enter.


Press Yes to configure the database for phpMyAdmin. 


You can choose a phpMyAdmin MySQL password now, or let it randomly generate one for you. It's your choice here.


Now we're going to make a symlink from the phpMyAdmin directory to our web directory.


(Customize /var/www/html to your specific working directory setup. If you use /var/www/domain.com/public_html, put that here)


sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin


Getting close to the end here! Now we need to modify the default Nginx config file.


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


Our config will look like this, be sure to modify it to fit your needs!


server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.php  index.html index.htm index.nginx-debian.html;

        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

}


Save that file and then we will restart Nginx and php7.2-fpm.



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

sudo systemctl restart nginx
sudo systemctl restart php7.2-fpm


If all goes well, you should be able to access your phpMyAdmin installation at: <server_ip_here/phpmyadmin> or <domain.com/phpmyadmin>


If you get a 404 error, verify that you have created the symlink above by doing the following:


cd /var/www/html

ls


 You should have a link named phpmyadmin in this folder. (It may be highlighted depending on your terminal)


Congratulations! We have set up a basic installation of phpMyAdmin with Nginx. To further secure your install, we advise reading up on the official documentation --> https://www.phpmyadmin.net/security/  and  https://docs.nginx.com/nginx/admin-guide/security-controls/ 



Join our Private Discord Chat to chat with, as well as find community assistance from other Verified SkySilk Users:
https://invite.gg/SkySilk  


CLICK TO DEPLOY AN UBUNTU LINUX VPS

   

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.