|NO.Z.00006|——————————|^^构建^^|——|Nginx&Nginx.V1.16&企业级LNMP&Yum.V2|

犀渠玉剑良家子,白马金羁侠少年。这篇文章主要讲述|NO.Z.00006|——————————|^^构建^^|——|Nginx&Nginx.V1.16&企业级LNMP&Yum.V2|相关的知识,希望能为你提供帮助。
一、从0开始构建LNMP WEB平台,主要有两种方式;

### --- 从0开始构建LNMP WEB平台,主要有两种方式;~~~YUM二进制方式 ~~~MAKE源码编译方式 ~~~此处我们基于YUM二进制方式(网络源的形式,服务器能够上外网,配置局域网YUM源) ~~~构建LNMP的操作

一、部署nginx:
### --- 添加Epel-release扩展源[root@localhost ~]# yum -y install epel-release [root@localhost ~]# ll /etc/yum.repos.d/|grep -aw epel -rw-r--r-- 1 root root951 Oct32017 epel.repo -rw-r--r-- 1 root root 1050 Oct32017 epel-testing.repo

### --- 安装nginx软件包: ### --- 显示Complete!表示安装成功;[root@localhost ~]# yum -y install nginx

### --- 检测nginx软件包是否安装成功[root@27ba4cba71d5 ~]# rpm -qa |grep nginx nginx-filesystem-1.14.1-9.module_el8.0.0+184+e34fea82.noarch nginx-mod-http-perl-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 nginx-mod-mail-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 nginx-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 nginx-all-modules-1.14.1-9.module_el8.0.0+184+e34fea82.noarch nginx-mod-http-xslt-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 nginx-mod-stream-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64 nginx-mod-http-image-filter-1.14.1-9.module_el8.0.0+184+e34fea82.x86_64

### --- 查看端口和进程[root@27ba4cba71d5 ~]# systemctl start nginx.service [root@27ba4cba71d5 ~]# ps -ef |grep nginx [root@27ba4cba71d5 ~]# netstat -tunlp |grep -aw 80 tcp00 0.0.0.0:800.0.0.0:*LISTEN258/nginx: master p tcp600 :::80:::*LISTEN258/nginx: master p

二、部署Mariadb:
### --- 安装Mariadb:[root@27ba4cba71d5 ~]# yum -y install mariadb-server mariadb mariadb-devel

### --- 检测Mariadb安装是否成功:rpm -qa |grep mariadb

### --- 查看Mariadb进程和端口号;[root@27ba4cba71d5 ~]# systemctl start mariadb.service [root@27ba4cba71d5 ~]# ps -ef |grep mysql mysql45210 08:04 ?00:00:00 /usr/libexec/mysqld --basedir=/usr root5181210 08:04 ?00:00:00 grep --color=auto mysql [root@27ba4cba71d5 ~]# netstat -tunlp |grep -aw 3306 tcp600 :::3306:::*LISTEN452/mysqld

三、部署php:
### --- 安装php[root@27ba4cba71d5 ~]# yum -y install php php-devel php-fpm php-mysql

### --- 检测PHP是否安装成功:[root@27ba4cba71d5 ~]# rpm -qa |grep php

### --- 查看PHP进程及端口号 ### --- 此时没有查到9000端口[root@27ba4cba71d5 ~]# systemctl start php-fpm.service [root@27ba4cba71d5 ~]# ps -ef |grep php [root@27ba4cba71d5 ~]# netstat -tunlp|grep -aw 9000

四、根据如上LNMP部署指令操作,LNMP平台部署完成,查看其进程
### --- 根据如上LNMP部署指令操作,LNMP平台部署完成,查看其进程[root@27ba4cba71d5 ~]# ps -ef |grep -wE "nginx|mysqld|php" root25810 07:52 ?00:00:00 nginx: master process /usr/sbin/nginx nginx2592580 07:52 ?00:00:00 nginx: worker process nginx2602580 07:52 ?00:00:00 nginx: worker process mysql45210 08:04 ?00:00:03 /usr/libexec/mysqld --basedir=/usr root59810 08:14 ?00:00:00 php-fpm: master process (/etc/php-fpm.conf) apache5995980 08:14 ?00:00:00 php-fpm: pool www apache6005980 08:14 ?00:00:00 php-fpm: pool www apache6015980 08:14 ?00:00:00 php-fpm: pool www apache6025980 08:14 ?00:00:00 php-fpm: pool www apache6035980 08:14 ?00:00:00 php-fpm: pool www root6471210 08:23 ?00:00:00 grep --color=auto -wE nginx|mysqld|php

五、nginx和php-fpm进行配置整合
### --- 要讲nginx和php-fpm进行配置整合,实现nginx检测到用户请求PHP动态网页时, ### --- nginx会将用户的请求通过CGI网关协议发送给后端PHP-FPM解释器取出来, ### --- nginx.conf配置代码如下:### --- nginx配置: [root@localhost nginx]# location /// 第二步 roothtml; index index.php index.html index.htm; // 加上nginx.php表示引导页。location ~ \\.php$ root/usr/share/nginx/html; // 更改发布目录;第一步 fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; // 添加$document_root; 表示发布目录//第三步 fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params;

### --- 查看nginx.conf文件并去掉#号空行。[root@localhost nginx]# grep -vE "#|^$" nginx.conf worker_processes1; events worker_connections1024; http includemime.types; default_typeapplication/octet-stream; sendfileon; keepalive_timeout65; // 以上为全局配置 server// 以下为server主机的配置 listen80; server_namelocalhost; location /// location /是正常匹配,处于正则匹配后执行。 roothtml; index index.php index.html index.htm; error_page500 502 503 504/50x.html; location = /50x.html roothtml; location ~ \\.php$// location ~是正则匹配,是优先匹配, root/usr/share/nginx/html; fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; // 指定发布目录的变量,绝对路径也可以:/usr/share/nginx/html; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params;

六、更改完成之后:
### --- 重启nginx服务[root@27ba4cba71d5 nginx]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@27ba4cba71d5 nginx]# nginx -s reload

七、nginx、php-fpm发布目录;/usr/share/nginx/html,在该目录创建index.php,代码内容如下。
### --- nginx、php-fpm发布目录; ### --- /usr/share/nginx/html,在该目录创建index.php,代码内容如下。[root@27ba4cba71d5 nginx]# vim /usr/share/nginx/html/index.php < ?php phpinfo(); ?>

|NO.Z.00006|——————————|^^构建^^|——|Nginx&Nginx.V1.16&企业级LNMP&Yum.V2|

文章图片
八、通过LNMP发布网站:
### --- 我们只需要把我们打开发包解压到发布目录就可以了:[root@localhost ~]# ls anaconda-ks.cfgweb.html.tar [root@localhost ~]# tar -zxvf web.html.tar /usr/share/nginx/html

|NO.Z.00006|——————————|^^构建^^|——|Nginx&Nginx.V1.16&企业级LNMP&Yum.V2|

文章图片
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warmd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor 【|NO.Z.00006|——————————|^^构建^^|——|Nginx&Nginx.V1.16&企业级LNMP&Yum.V2|】

    推荐阅读