LEMP is a combination of operating system and open-source software stack. The acronym LEMP is derived from first letters of Linux, Nginx HTTP Server, MariaDB database, and PHP/Perl/Python
First install epel-relese package
#yum install epel-release
Now install nginx
# yum install nginx -y
# service nginx start
# vi /etc/nginx/nginx.conf
worker_processes 1;
# vi /etc/nginx/conf.d/default.conf
--------------------------------------------------------------------------
server {
listen 80;
server_name your sever ip;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
## Uncomment or Add the following lines
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
-------------------------------------------------------------------------
Now restart nginx service
# service nginx restart
Now install mysql-server
#yum install mysql-server
#/usr/bin/mysql_secure_installation
set username and password for mysql snd start mysql service
# service mysqld start
Install php-fpm and other php-modules
# yum install php php-common php-fpm php-mysql -y
# service php-fpm start
# vi /etc/php.ini
-----------------------------------------------------------------------
[...]
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0
[...]
------------------------------------------------------------------------
# vi /etc/php-fpm.d/www.conf
[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[...]
-----------------------------------------------------------------------
#service php-fpm restart
To test php:
# vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
# service nginx restart
Now try from your browser http://yourip/info.php
First install epel-relese package
#yum install epel-release
Now install nginx
# yum install nginx -y
# service nginx start
# vi /etc/nginx/nginx.conf
worker_processes 1;
# vi /etc/nginx/conf.d/default.conf
--------------------------------------------------------------------------
server {
listen 80;
server_name your sever ip;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
## Uncomment or Add the following lines
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
-------------------------------------------------------------------------
Now restart nginx service
# service nginx restart
Now install mysql-server
#yum install mysql-server
#/usr/bin/mysql_secure_installation
set username and password for mysql snd start mysql service
# service mysqld start
Install php-fpm and other php-modules
# yum install php php-common php-fpm php-mysql -y
# service php-fpm start
# vi /etc/php.ini
-----------------------------------------------------------------------
[...]
; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0
[...]
------------------------------------------------------------------------
# vi /etc/php-fpm.d/www.conf
[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[...]
-----------------------------------------------------------------------
#service php-fpm restart
To test php:
# vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
# service nginx restart
Now try from your browser http://yourip/info.php