banner
深海小涛

深海小涛

混吃等死卖萌打滚的小废物
twitter
github
telegram

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.

Installation#

Nginx#

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!

MySQL#

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

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum install MariaDB-server MariaDB-client
service mariadb start
mysql_secure_installation

MySQL is set up!

php#

First, install two Yum sources:

CentOS/RHEL 7.x:#

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:#

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
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!

Configuration#

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/echoteen.com.conf
server {
listen 80;
server_name www.echoteen.com echoteen.com;  #your website domain
access_log off;
index index.html index.htm index.php;
root /home/wwwroot/echoteen.com;  #your website file path
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;
        }
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!

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