LEMP stack stands for Linux, Nginx, MySQL, MariaDB, MongoDB, PHP, Perl, Python & phpMyAdmin. LEMP is bunch of opensource software which is developed by different organization.
install-lemp-server-linux-nginx-mysql-php-in-linux-mint-17-ubuntu-14-04-debian-7-6
What is NGINX ?
NGINX stands for engine-x is a free, open-source, high-performance HTTP server and reverse proxy, as well as an mail (IMAP/POP3) proxy server. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. Currently 146 million websites use NGINX to deliver super-fast web experiences. The big companies like (WordPress, facebook, GitHub & cloudflare, etc..) using nginx. For more details about Nginx
What is PHP-FPM ?
PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. For more details about PHP-FPM
Remove Existing LAMP stack
If you are planning to install NGINX, I advise you to remove your existing LEMP stack. Use the below single command to purge everything.
magesh@magesh-desktop:~$ sudo apt-get purge apache2* php5* mysql*
Then recheck once if anything still available. Use the below commands.
magesh@magesh-desktop:~$ dpkg -l | grep apache*
magesh@magesh-desktop:~$ dpkg -l | grep php5*
magesh@magesh-desktop:~$ dpkg -l | grep mysql*
1) Nginx Installation
By default you will get Nginx 1.4.6 version from Ubuntu repository but current stable version is Nginx 1.6.2, So you need to add Ubuntu PPA repository to get latest stable version of Nginx on your system. use the below commands to do it.
# Add repository to your system #
magesh@magesh-desktop:~$ add-apt-repository ppa:nginx/stable
# Update your repository in your system #
magesh@magesh-desktop:~$ apt-get update
# Install nginx now #
magesh@magesh-desktop:~$ apt-get install nginx
Step : 1 Nginx Version checking
mageshm@mageshm:~$ nginx -v
nginx version: nginx/1.6.2
2) Nginx Index page
Open your web browser and navigate to http://localhost/ or http://your-server-ip-address/ or http://127.0.0.1/
3) Nginx 6.1.2 Configuration
Need to make lots of changes on your Nginx default config file to make it Nginx work properly.
Step : 1 Open /etc/nginx/nginx.conf file on your favorite text editor and change worker_processes values according your CPU count. For CPU count use lscpu command. I’m having 4 CPU’s that’s why i added 4.
magesh@magesh-desktop:~$ /etc/nginx/nginx.conf
GNU nano 2.2.6 File: /etc/nginx/nginx.conf
worker_processes 4;
Step : 2 Open default Virtual host configuration file /etc/nginx/sites-available/default on your favorite text editor and uncomment below lines. Also add/modify below colored lines on your file. I have removed all the unwanted lines from this file for clear explanation. Add your FQDN (server.2daygeek.com) instead of us.
magesh@magesh-desktop:~$ /etc/nginx/sites-available/default
GNU nano 2.2.6 File: /etc/nginx/sites-available/default
# Web root location & port listening #
server
{
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name server.2daygeek.com;
# Redirect server error pages to the static page #
location /
{
try_files $uri $uri/ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root /usr/share/nginx/html;
}
# Pass the PHP scripts to FastCGI server #
location ~ \.php$
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
Step : 3 Reload Nginx configuration
mageshm@mageshm:~$ sudo service nginx reload
* Reloading nginx configuration nginx [ OK ]
Step : 4 Run nginx configuration test
mageshm@mageshm:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Step : 5 Restart Nginx
mageshm@mageshm:~$ sudo service nginx restart
* Restarting nginx nginx [ OK ]
4) MySQL installation
Use the below command to install MySQL. MySQL is a opensource relational database management system (RDBMS) which is supporting database access.
mageshm@mageshm:~$ sudo apt-get install mysql-server mysql-client
While installing MySQL server, it will ask you to set root password for MySQL.
Confirm the root password for MySQL.
5) PHP-FPM & PHP modules installation
Use the below command to install PHP-FPM & PHP modules. PHP initially called Personal Home Page, now it is called asHypertext Preprocessor. PHP is a opensource software which is designed for web development purpose. It is used for server-side scripting language as well as general-purpose programming language.
mageshm@mageshm:~$ sudo apt-get install php5 php5-fpm php5-mysql php5-cli php5-curl php5-gd php5-mcrypt
Step : 1 Configure PHP
We need to make small change in php.ini file to make it work php-fpm properly. open /etc/php5/fpm/php.ini file on your favorite text editor and find cgi.fix_pathinfo= then uncomment it and change from 1 to 0.
magesh@magesh-desktop:~$ /etc/php5/fpm/php.ini
GNU nano 2.2.6 File: /etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
Step : 2 By default PHP-FPM listens the socket on /var/run/php5-fpm.sock and its not effective one. So we need to change the listening settings on /etc/php5/fpm/pool.d/www.conf. From listen = /var/run/php5-fpm.sock to listen = 127.0.0.1:9000. Just open the file /etc/php5/fpm/pool.d/www.conf and do it.
magesh@magesh-desktop:~$ sudo nano /etc/php5/fpm/pool.d/www.conf
GNU nano 2.2.6 File: /etc/php5/fpm/pool.d/www.conf
;listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9000
Step : 3 phpinfo file creation
magesh@magesh-desktop:~$ sudo nano /usr/share/nginx/html/phpinfo.php
GNU nano 2.2.6 File: /usr/share/nginx/html/phpinfo.php
<?php
phpinfo();
?>
Step : 4 Restart PHP-FPM
magesh@magesh-desktop:~$ sudo service php5-fpm restart
php5-fpm stop/waiting
php5-fpm start/running, process 15463
Step : 5 Restart Nginx
mageshm@mageshm:~$ sudo service nginx restart
* Restarting nginx nginx [ OK ]
Open your web browser and navigate to http://localhost/phpinfo.php or http://your-server-ip-address/phpinfo.php or http://127.0.0.1/phpinfo.php
install-lemp-server-linux-nginx-mysql-php-in-linux-mint-17-ubuntu-14-04-debian-7-6-5
We are preparing all articles in-depth to understand by all level/stage Linux administrators. If the article is useful for you, then please spend less than a minute to share your valuable comments in our commenting section.
Không có nhận xét nào:
Đăng nhận xét