Build lnmp

The installation package compilation takes a long time, and if your server configuration is lower, it may take even longer, or the server may crash! However, today we introduce a method that can directly install the latest LNMP on your server!

This article uses centos7.1 as an example.



Go to the official website and download the package required for your platform.

For example, if you are using CentOS, click on CentOS, and then select the rpm package based on your system version and the desired nginx version!

64-bit is x86_64, and 32-bit is i386!

After locating the desired nginx version, right-click and copy the link address.

Then go back to your ssh and enter:

rpm -ivh your copied link
nginx -v

Then nginx is installed!


For MySQL, I recommend using mariadb, which has the same usage as MySQL, it's just a name change for us!

Install using yum.

vi /etc/yum.repos.d/MariaDB.repo

name = MariaDB
baseurl =
yum install MariaDB-server MariaDB-client
service mariadb start

MySQL is set up!


First, install two Yum sources:

CentOS/RHEL 7.x:#

rpm -Uvh
rpm -Uvh

CentOS/RHEL 6.x:#

rpm -Uvh
rpm -Uvh
yum list php*

Note that you must install the combination of MySQL and the php-fpm module! Otherwise, your website won't run!

Install php7#

yum -y install php70w php70w-cli php70w-common php70w-fpm php70w-gd php70w-mysql
service php-fpm start
chkconfig php-fpm on

The specific modules and versions depend on your program. It is recommended to use php5.6 because php7 is not very compatible yet, otherwise, you may encounter unexpected bugs!

At this point, LNMP has been successfully installed, usually in less than two minutes from start to finish!


First, unify the user running the web server:

sed -i 's/user = apache/user = nginx/' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/group = nginx/' /etc/php-fpm.d/www.conf

Then create your website configuration file in /etc/nginx/conf.d:

vi /etc/nginx/conf.d/
server {
listen 80;
server_name;  #your website domain
access_log off;
index index.html index.htm index.php;
root /home/wwwroot/;  #your website file path
location ~ \.php$ {
            root           html;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
    expires 30d;
    access_log off;
location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;

For WordPress and other applications that require rewrite rules, you can directly add the rewrite rules here. Specific rules can be found by searching on Baidu. Then service nginx restart service php-fpm restart.

Finally, bind your domain name and you can access it directly!

This way, you can quickly build your own web server, with customizable features and versions, simple and convenient! It greatly saves server disk space and memory! It is not as brainless as a one-click installation package, and you can't solve problems when they arise!

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.