Install Nginx Phpmyadmin Ubuntu 18.04


Install Nginx Phpmyadmin Ubuntu 18.04

Introduction to Nginx, PHP, and Ubuntu

Nginx is an open-source, high-performance web server written in C and used to serve static and dynamic webpages. It is an ideal web server for sites with high traffic. PHP is an open-source, general-purpose scripting language used for web development. It is one of the most popular languages used for web development and can be used to build dynamic and interactive websites. Ubuntu is a Debian-based Linux distribution and is the most popular Linux distribution for web servers and open-source software.

How to Install Nginx and PHP on Ubuntu 18.04

Nginx and PHP can be easily installed on Ubuntu 18.04 using the apt package manager. To do this, first, open a terminal and update the package list:

sudo apt-get update

Once the package list has been updated, install Nginx with the following command:

sudo apt-get install nginx

To install PHP, use the following command:

sudo apt-get install php-fpm php-mysql

Once both Nginx and PHP are installed, you will need to enable them in order for them to work properly. To do this, use the following commands:

sudo systemctl enable nginx

sudo systemctl enable php7.0-fpm

How to Install phpMyAdmin on Ubuntu

PhpMyAdmin is a web-based administration tool used to manage MySQL databases. To install phpMyAdmin, first, open a terminal and update the package list:

sudo apt-get update

Next, install the phpMyAdmin package with the following command:

sudo apt-get install phpmyadmin

Once the installation is complete, you need to configure phpMyAdmin to be used with Nginx and PHP. To do this, open the phpMyAdmin configuration file with the following command:

sudo nano /etc/phpmyadmin/config.inc.php

Once the file is open, add the following lines to the end of the file:

$cfg['Servers'][$i]['auth_type'] = 'config';

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['user'] = 'root';

$cfg['Servers'][$i]['password'] = 'password';

Create a Nginx Virtual Host File

Once you have installed Nginx, PHP, and phpMyAdmin, you need to configure the Nginx Web server to use them. To do this, you need to create a virtual host file for the Nginx server. To do this, open a terminal and create the virtual host file with the following command:

sudo nano /etc/nginx/sites-available/example.com

Once the file is open, add the following lines to the file:

server {

listen 80;

server_name example.com;

root /var/www/example.com/html;

index index.php index.html;

location / {

try_files $uri $uri/ =404;

}

location ~ .php$ {

include snippets/fastcgi-php.conf;

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

}

}

Enable the Nginx Virtual Host File

Once you have created the Nginx virtual host file, you need to enable it. This can be done using the following two commands:

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

sudo nginx -t

Once the virtual host file has been enabled, you need to restart the Nginx server. To do this, use the following command:

sudo systemctl restart nginx

Test the Setup

Once you have completed the installation and configuration of Nginx, PHP, and phpMyAdmin, you can test your setup by opening a web browser and navigating to http://localhost. If you see the phpMyAdmin login page, then the setup has been successful.

Conclusion

In this article, we have shown how to install Nginx, PHP and phpMyAdmin on Ubuntu 18.04. We have also explained how to configure them and how to test the setup. It is important to keep the software up to date in order to avoid vulnerabilities and improve performance. You can use the apt package manager or other tools such as composer to update the software on your server.

Frequently Asked Question

  • How to check if Nginx and PHP are installed correctly?
    You can check if Nginx and PHP have been installed correctly by opening a web browser and navigating to http://localhost and seeing if the phpMyAdmin login page is displayed.
  • Do I need to update the software regularly?
    Yes, it is important to keep the software up to date in order to avoid security vulnerabilities and improve performance.

Thank you for reading this article. We hope you found it helpful. Please read our other articles for more information.

Leave a Reply

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