Ubuntu Install Nginx Php7.2 Mysql


Ubuntu Install Nginx Php7.2 Mysql

What is Nginx?

Nginx is an open source web server that is very popular for powering web applications such as WordPress and Drupal. It is also used as a proxy for other web services such as email and FTP. It has a simple configuration architecture, and can quickly be deployed by novice web administrators. It also has outstanding request performance, and it can handle more requests per second than other web servers.

What is PHP?

PHP is a server-side scripting language, most commonly used for web development. It is extremely popular, and is supported by almost all web hosting services. It is also very easy to learn, as there is a lot of online support and documentation available for free. It has a wide range of features, and can be used to create dynamic websites which can interact with databases such as MySQL.

What is PHP 7.2?

PHP 7.2 is the most recent major version of PHP. It has improved performance over previous versions, as well as providing new features such as improved password hashing and native support for multibyte strings. It also has significant security improvements, and is the recommended version for anyone running a web application.

What is MySQL?

MySQL is a relational database management system which is widely used for powering web applications. It stores data in tables, and provides access to the data through SQL queries. It is very robust, and can handle large datasets with ease. It also provides a range of features such as replication and clustering.

How to Install Nginx, PHP 7.2, and MySQL on Ubuntu?

The following steps outline how to install Nginx and PHP 7.2 on Ubuntu, and how to configure them to work together. MySQL needs to be installed separately, but can be configured to work together with Nginx and PHP. It is assumed that Ubuntu is already installed.

  1. Update the system. Enter the following in the Terminal:
    sudo apt update && sudo apt upgrade

  2. Install Nginx. Enter the following in the Terminal:
    sudo apt install nginx

  3. Test that Nginx was installed. Enter the following in the Terminal:
    sudo systemctl status nginx

  4. Install PHP 7.2. Enter the following in the Terminal:
    sudo apt install php7.2 php7.2-fpm php7.2-mysql php-common php7.2-cli php7.2-common php7.2-mbstring php7.2-gd php7.2-intl php7.2-xml php7.2-zip

  5. Test that PHP 7.2 was installed. Enter the following in the Terminal:
    php -v

  6. Install MySQL. Enter the following in the Terminal:
    sudo apt install mysql-server

  7. Test that MySQL was installed. Enter the following in the Terminal:
    sudo mysql

  8. Update the Nginx config file. Enter the following in the Terminal:
    sudo vim /etc/nginx/sites-available/default

  9. Add the following lines to the Nginx config file:
    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name your_servername;
    location / {
    try_files $uri $uri/ =404;
    }
    location ~ .php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }
    location ~ /.ht {
    deny all;
    }
    }
  10. Restart Nginx. Enter the following in the Terminal:
    sudo /etc/init.d/nginx restart

Conclusion

It is possible to quickly and easily install Nginx, PHP 7.2, and MySQL on Ubuntu. The above steps provide a guide on how to do this. It is advisable to keep the system up to date, and to use secure passwords for all services when setting up the Apache, MySQL, and PHP configuration.

FAQs:

Q. What is Nginx?

A. Nginx is an open source web server, popular for powering web applications such as WordPress and Drupal.

Q. What is PHP?

A. PHP is a server-side scripting language, most commonly used for web development.

Q. What is MySQL?

A. MySQL is a relational database management system which is widely used for powering web applications.

Q. How do I install Nginx, PHP 7.2, and MySQL on Ubuntu?

A. The steps outlined in this article can be followed to install Nginx, PHP 7.2, and MySQL on Ubuntu.

Thank you for reading this article. Please read other articles for further information.

Leave a Reply

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