A step of mounting Nginx
Nginx available in the default Debian repository. Use the following command to update the package index and install Nginx:
sudo apt update
sudo apt install nginx
After the installation process is complete, Nginx service will start automatically.
Step two, the installation MariaDB
With the release of Debian 9, MySQL replacement MariaDB is the default database system. By running the following command to install MariaDB:
sudo apt install mariadb-server
After installation is complete, execute mysql_secure_installation order to improve the security of MySQL:
sudo mysql_secure_installation
You will be asked to set a root password, remove anonymous users, restrict the root user to access the local computer and delete the test database. You should answer all questions "Yes."
Step three, install PHP
Debian 9 comes with PHP version 7.0. To install PHP FPM and the most common PHP module type:
sudo apt install php-fpm php-opcache php-cli php-gd php-curl php-mysql
Step four, configure Nginx to handle PHP pages
Now that we have all the components are installed LEMP, we can edit Nginx virtual host configuration file and add the following line to Nginx can handle PHP files:
server { # . . . other code location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }
Do not forget to restart Nginx service for the change to take effect:
sudo systemctl restart nginx