Aliyun CentOS7.3 Build LNMP Manually

**

1. Turn off firewalls and selinux
---------------

**

Close Firewall

[root@localhost ~]# systemctl stop firewalld.service

selinux

[root@localhost ~]# vim  /etc/sysconfig/selinux
 Find SELINUX=enforcing and change enforcing to disabled 
[root@localhost ~]# setenforce 0
**

2. Install nginx
---------

**

wget download install nginx package

[root@localhost ~]# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Establish a yum repository for nginx

[root@localhost ~]#  rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

install & start nginx

[root@localhost ~]# yum install -y nginx
[root@localhost ~]# systemctl start nginx.service
**

3. Install mysql
----------

**

Download repo resources

[root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

Install mysql-community-release-el7-5.noarch.rpm

[root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

Install MySQL &Set User Rights &Restart

[root@localhost ~]# sudo yum install -y  mysql-server
[root@localhost ~]# sudo chown -R root:root /var/lib/mysql
[root@localhost ~]# systemctl restart mysql.service

Log in to MySQL and change your password (you can set it yourself after all installation is complete):

[root@localhost ~]# mysql -u root
mysql > use mysql;
mysql > update user set password=password('123456') where user='root';
mysql > flush privilgegs;
mysql > exit;
**

3.PHP7 Installation
-------

**

rpm install php corresponding yum resources

[root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

install php7.0

[root@localhost ~]# yum install -y php70w

Install Extensions

[root@localhost ~]# yum install -y  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_64

Install php fpm

[root@localhost ~]# ​yum install -y php70w-fpm

**

Modify Configuration

**
nginx profile modification: can be done directly inNginx.confModify, for fear of bad modification, I create a new.conf file in con.d.

user  nginx;

worker_processes auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
        default_type  application/octet-stream;

        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        #limit_conn_zone $binary_remote_addr zone=perip:10m;
        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

        server_tokens off;
        access_log off;




    server
        {
            listen 80 default_server;
            server_name "Domain name can also be ip";
            index index.html index.htm index.php;
            root  /forest/www(Change to your own directory for placing code: Custom);

            #error_page   404   /404.html;


        location ~ [^/]\.php(/|$)
        {
            try_files $uri =404;
           # fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }


            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }

            location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }

            location ~ .*\.(js|css)?$
            {
                expires      12h;
            }

            location ~ /\.
            {
                deny all;
            }

            access_log  /home/access.log;
        }

    # Load additional configurations
    #include vhost/*.conf;

}

Modify php-fpm configuration file

[root@localhost ~]# vim /etc/php-fpm.d/www.conf
 Find the change so
    user =nginx
​    group=nginx

Prevent a test file in the set root directory

echo 'HELLO VAN!';

**

Start Server

**

[root@localhost ~]# systemctl start nginx.service

View Server Status

[root@localhost ~]# systemctl status nginx 

Start PHP-FPM

[root@localhost ~]# systemctl start php-fpm.service
[root@localhost ~]# systemctl status php-fpm.service 

Enter ip or a bound domain name in the browser and OK!

Ah Moh finally wrote it

Tags: Nginx MySQL RPM PHP

Posted on Sat, 04 Jul 2020 11:44:33 -0400 by lajocar