Introduction
Note :- Update and upgrade your server first.
1. First of all install Nginx web server :-
2. Now we will install Mysql database server :-
3. We need to install PHP now :-
Configure the PHP processor.
Please do Comments, Like and Share.
LEMP stands for Linux ,Nginx, Mysql and PHP. The word LEMP describes that Linux operating system, with an Nginx web server. The backend data will be stored Mysql database and the dynamic data will be processed by PHP.
In this tutorial we will see how to install and configure LEMP on AWS EC2 instance. I have taken new AWS-EC2 instance.
Note :- Update and upgrade your server first.
1. First of all install Nginx web server :-
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install nginx
2. Now we will install Mysql database server :-
sudo apt-get install mysql-server -y
It will ask you for the password during the installation so enter the strong password of your choice and make note of it.
As you can see in the above image we have successfully installed Mysql database server and created the test database.
3. We need to install PHP now :-
We now have Nginx installed to serve our pages and MySQL installed to store and manage our data. However, we still don't have anything that can generate dynamic content. We can use PHP for this.
Since Nginx does not contain native PHP processing like some other web servers, we will need to install php-fpm, which stands for "fastCGI process manager". We will tell Nginx to pass PHP requests to this software for processing.
We can install this module and will also grab an additional helper package that will allow PHP to communicate with our database backend. The installation will pull in the necessary PHP core files. Do this by typing:-
sudo apt-get install php-fpm php-mysql -y
Configure the PHP processor.
We have php-fpm component installed. we have to configure it in the below file so that our nginx web server will be able to process it.
sudo vim /etc/php/7.0/fpm/php.ini
Find the text :
- cgi.fix_pathinfo=1 and uncomment it and change it "0" zero.
Restart php-fpm service to take effect.
sudo systemctl restart php7.0-fpm
4. Configure the Nginx to use PHP-Processor.
sudo vim /etc/nginx/sites-available/default
First, we need to add index.php as the first value of our index directive so that files named index.php are served, if available, when a directory is requested.
We can modify the server_name directive to point to our server's domain name or public IP address.
For the actual PHP processing, we just need to uncomment a segment of the file that handles PHP requests by removing the pound symbols (#) from in front of each line. This will be the location ~\.php$ location block, the included fastcgi-php.conf snippet, and the socket associated with php-fpm.
We will also uncomment the location block dealing with .htaccess files using the same method. Nginx doesn't process these files. If any of these files happen to find their way into the document root, they should not be served to visitors.
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 54.202.16.3; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~ /\.ht { deny all; } }
Restart the nginx service to check
sudo service nginx restart
Create the info.php file in /var/www/html with root user and check in the web browser.
As you can see in the above image we have successfully installed the LEMP server.
Please do Comments, Like and Share.
23:21
Tags :
AWS
,
Linux
,
Ubuntu-16.04
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments