Install lemp on CentOS
Generally, the Nginx system architecture is used for large website construction environments, which is more vulnerable to threads and pressures than Apache. However, Apache environments are sufficient for general blogs and websites. In previous articles, whether it is an LNMP one-key installation package, LEMP one-key package, and amh web panel, it is a website environment built using NGINX.
In this article, the old left sort out an article based on the latest CentOS7 system, set up and apply Nginx/PHP-FPM 5.6/MySQL 5.5 applicable website environment, if you also like to toss, you can try the following content. The article is translated from outside China and has been tested completely.
1. Install the EPEL and REMI library files
Rpm-Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
Rpm-Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
2. Install Nginx
Yum install nginx-y
Start and set startup
Systemctl start nginx
Systemctl enable nginx
Set firewall to enable port 80
Firewall-cmd -- zone = public -- add-port = 80/tcp -- permanent $ sudo firewall-cmd -- reload
Now NGINX has been installed. You can open the IP address browser and see the prompt for successful NGINX installation.
Third, install MariaDB 5.5
Yum -- enablerepo = remi, remi-php56 install mariadb-server mariadb-y
Start and set startup
Systemctl start mariadb
Systemctl enable mariadb
Set database security
/Usr/bin/mysql_secure_installation
Execute the above script and follow the prompts to set database security and delete anonymous users.
NOTE: running all parts of this script is recommended for all MariaDB
Servers in production use! Please read each step carefully!
In order to log into MariaDB to secure it, we'll need the current
Password for the root user. If you 've just installed MariaDB, and
You haven't set the root password yet, the password will be blank,
So you shoshould just press enter here.
Enter current password for root (enter for none ):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
Root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables ..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
To log into MariaDB without having to have a user account created
Them. This is intended only for testing, and to make the installation
Go a bit smoother. You shoshould remove them before moving into
Production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root shoshould only be allowed to connect from 'localhost'. This
Ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
Access. This is also intended only for testing, and shocould be removed
Before moving into a production environment.
Remove test database and access to it? [Y/n] y
-Dropping test database...
... Success!
-Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
Will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you 've completed all of the above steps, your MariaDB
Installation shoshould now be secure.
Thanks for using MariaDB!
4. install PHP-fpm 5.6
Yum -- enablerepo = remi, remi-php56 install php-fpm php-common php-mysql php-opcache php-pear php-gd php-devel php-mbstring php-mcrypt php-cli php-pdo php-xml-y
Start and start
Service php-fpm start
Chkconfig php-fpm on
5. Configure Nginx
Now we have installed nginx, mariadb, and php-fpm. We need to configure Nginx.
A-configure the/etc/nginx. conf file
User nginx;
Worker_processes 1;
Worker_processes indicates the number of CPU cores of the current VPS/server. We can use grep ^ processor/proc/cpuinfo | wc-l to detect and modify the number.
B-check to start sendfile, tcp_nopush, gzip, and add the INDEX. php file.
Sendfile on;
Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
Gzip on;
Index. php index.html index.htm;
6. Add site and setting file
Vi/etc/nginx/conf. d/laozuo_org.conf
When adding a site, we 'd better determine it by domain name, so that we can check and remember.
Server {
Listen your_public_ip_address: 80;
Server_name www.laozuo.org;
Root/var/www/www.laozuo.org;
Index. php index.html index.htm;
Charset UTF-8;
Location /{
}
Location =/robots.txt {allow all; access_log off; log_not_found off ;}
Location =/favicon. ico {allow all; access_log off; log_not_found off ;}
Error_page 401/401 .html;
Error_page 403/403 .html;
Error_page 404/404 .html;
Error_page 500 502 503 x.html;
Location ~ \. Php $ {
Root/var/www/www.laozuo.org;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_intercept_errors on;
Fastcgi_buffer_size 4 K;
Fastcgi_buffers 128 4 k;
Fastcgi_connect_timeout 50;
Fastcgi_send_timeout 40;
Fastcgi_read_timeout 40;
Try_files $ uri = 404;
Fastcgi_split_path_info ^ (. + \. php) (/. +) $;
Include fastcgi_params;
}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
}
Enter the corresponding configuration file.
If you do not have the/var/www/www.laozuo.org folder, you must grant the ADD and Configure permissions.
Mkdir/var/www/www.laozuo.org
Chmod 777/var/www/www.laozuo.org
Finally, we start Nginx
Systemctl restart nginx
If it cannot be started, you can use "systemctl status nginx. service" to check the problem and modify it accordingly.
To sum up, we can upload programs in the created folder. If you need a database such as MYSQL, we can install it separately. You can also refer to the article "Debian installation LEMP (Linux/Nginx/MySQL/PHP) build site building environment" for installation.