How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04
How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04
In this tutorial, we will learn how to install LEMP stack on Ubuntu 16.04.
Step 1: Update Package Lists
Before we start, let's update the package lists.
sudo apt-get update
sudo apt-get upgrade
Step 2: Install Nginx
To install Nginx, run the following command:
sudo apt-get install nginx
Step 3: Install MySQL
To install MySQL, run the following command:
sudo apt-get install mysql-server mysql-client
Step 4: Secure MySQL Installation
After installing MySQL, you should secure it by running the following command:
sudo mysql_secure_installation
Step 5: Install PHP and PHP Modules
To install PHP and PHP modules, run the following command:
sudo apt-get install php-fpm php-mysql
Step 6: Configure Nginx to Use PHP-FPM
To configure Nginx to use PHP-FPM, create a new server block by running the following command:
sudo nano /etc/nginx/sites-available/default
Then, add the following lines to the configuration file:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
Save and close the file.
Step 7: Restart Nginx
To apply the changes, restart Nginx by running the following command:
sudo systemctl restart nginx
Step 8: Test PHP
To test PHP, create a new PHP file in the web root directory by running the following command:
sudo nano /var/www/html/info.php
Then, add the following line to the file:
<?php phpinfo(); ?>
Save and close the file.
Now, open a web browser and enter the following URL:
http://localhost/info.php
If PHP is working properly, you should see a page with PHP configuration information.
Conclusion
In this tutorial, we have learned how to install LEMP stack on Ubuntu 16.04.
Keywords: LEMP stack, Ubuntu
Комментарии
Отправить комментарий