日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

LNMP架構(gòu)概述

什么是LNMP

LNMP是一套技術(shù)的組合,L=linux、N=Nginx、M~=MySQL、P~=php


LNMP架構(gòu)是如何工作的

首先Nginx服務(wù)是不能處理動態(tài)請求,那么當(dāng)用戶發(fā)起動態(tài)請求時, Nginx又是如何進(jìn)行處理的。

當(dāng)用戶發(fā)起http請求,請求會被Nginx處理,如果是靜態(tài)資源請求Nginx則直接返回,如果是動態(tài)請求Nginx則通過fastcgi協(xié)議轉(zhuǎn)交給后端的PHP程序處理,具體如下圖所示

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?


Nginx與Fast-CGO詳細(xì)工作流程

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

1.用戶通過http協(xié)議發(fā)起請求,請求會先抵達(dá)LNMP架構(gòu)中的Nginx

2.Nginx會根據(jù)用戶的請求進(jìn)行判斷,這個判斷是有Location進(jìn)行完成

3.判斷用戶請求的是靜態(tài)頁面,Nginx直接進(jìn)行處理

4.判斷用戶請求的是動態(tài)頁面,Nginx會將該請求交給fastcgi協(xié)議下發(fā)

5.fastgi會將請求交給php-fpm管理進(jìn)程, php-fpm管理進(jìn)程接收到后會調(diào)用具體的工作進(jìn)程warrap

6.warrap進(jìn)程會調(diào)用php程序進(jìn)行解析,如果只是解析代碼php直接返回

7.如果有查詢數(shù)據(jù)庫操作,則由php連接數(shù)據(jù)庫(用戶 密碼 IP)發(fā)起查詢的操作

8.最終數(shù)據(jù)由*mysql->php->php-fpm->fastcgi->nginx->http->user

LNMP架構(gòu)環(huán)境部署

使用官方倉庫安裝Nginx

[root@nginx ~]# cat /etc/yum.repos.d/nginx.repo 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
 
#安裝Nginx
[root@nginx ~]# yum install nginx -y

修改nginx用戶

[root@nginx ~]# groupadd www -g 666
[root@nginx ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
#修改nginx配置文件
[root@nginx ~]# sed -i '/^user/c user www;' /etc/nginx/nginx.conf

啟動Nginx加入開機(jī)自啟

[root@nginx ~]# systemctl start nginx
[root@nginx ~]# systemctl enable nginx

使用第三方擴(kuò)展源安裝php7.1

# 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
[root@nginx ~]# yum remove php-mysql-5.4 php php-fpm php-common
#配置第三方源
[root@nginx ~]# vim /etc/yum.repos.d/php.repo
[php-webtatic]
name = PHP Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
[root@nginx ~]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb

配置php-fpm用戶與Nginx的運(yùn)行用戶保持一致

[root@nginx ~]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf 
[root@nginx ~]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf

啟動php-fpm加入開機(jī)自啟

[root@nginx ~]# systemctl start php-fpm
[root@nginx ~]# systemctl enable php-fpm

安裝Mariadb數(shù)據(jù)庫

[root@nginx ~]# yum install mariadb-server -y

啟動Mariadb加入開機(jī)自動

[root@nginx ~]# systemctl start mariadb
[root@nginx ~]# systemctl enable mariadb

給Mariadb配置登陸密碼

[root@nginx ~]# mysqladmin password 'Zls123.com'
[root@nginx ~]# mysql -uroot -pZls123.com

LNMP架構(gòu)環(huán)境配置

在將Nginx與PHP集成過程中,需要先了解Fastcgi代理配置語法

1.設(shè)置fastcgi服務(wù)器的地址,該地址可以指定為域名或IP地址,以及端口

Syntax: fastcgi_pass address;
Default: —
Context: location, if in location
 
#語法示例
fastcgi_pass localhost:9000;
fastcgi_pass unix:/tmp/fastcgi.socket;

2.設(shè)置fastcgi默認(rèn)的首頁文件,需要結(jié)合fastcgi_param一起設(shè)置

Syntax: fastcgi_index name;
Default: —
Context: http, server, location

3.通過fastcgi_param設(shè)置變量,并將設(shè)置的變量傳遞到后端的fastcgi服務(wù)器

Syntax: fastcgi_param parameter value [if_not_empty];
Default: —
Context: http, server, location
 
#語法示例
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /code$fastcgi_script_name;

4.通過圖形方式展示fastcgi_index與fastcgi_param作用

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

5.最終Nginx連接Fastcgi服務(wù)器配置如下

[root@nginx ~]# cat /etc/nginx/conf.d/php.conf 
server {
 listen 80;
 server_name php.driverzeng.com;
 location / {
 root /code;
 index index.php index.html;
 }
 location ~ .php$ {
 root /code;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name
 }
}

6.在/code目錄下創(chuàng)建info.php文件,測試能否通過瀏覽器訪問,訪問成功如下圖

[root@nginx ~]# cat /code/info.php
<?php
 phpinfo();
?>
Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

按照剛才的配置,頁面打開一片空白。

[root@nginx ~]# cat /etc/nginx/conf.d/php.conf 
server {
 listen 80;
 server_name php.driverzeng.com;
 location / {
 root /code;
 index index.php index.html;
 }
 location ~ .php$ {
 root /code;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
}
Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

7.在/code目錄下創(chuàng)建mysqli.php文件,填入對應(yīng)的數(shù)據(jù)庫IP、用戶名、密碼

[root@nginx ~]# cat /code/mysqli.php
<?php
 $servername = "localhost";
 $username = "root";
 $password = "Zls123.com";
 // 創(chuàng)建連接
 $conn = mysqli_connect($servername, $username, $password);
 // 檢測連接
 if (!$conn) {
 die("Connection failed: " . mysqli_connect_error());
 }
 echo "小哥哥,php可以連接MySQL...";
?>
<img style='width:100%;height:100%;' src=https://www.driverzeng.com/zenglaoshi/php_mysql.png>
Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

部署博客產(chǎn)WordPress

1)配置Nginx虛擬主機(jī)站點(diǎn),域名為blog.driverzeng.com

#1.nginx具體配置信息
[root@nginx ~]# cat /etc/nginx/conf.d/wordpress.conf
server {
 listen 80;
 server_name blog.driverzeng.com;
 root /code/wordpress;
 index index.php index.html;
 
 location ~ .php$ {
 root /code/wordpress;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
}

2)重啟nginx服務(wù)

[root@nginx ~]# systemctl restart nginx

3)獲取wordpress產(chǎn)品,解壓并部署wordress

[root@nginx ~]# mkdir /code
[root@nginx ~]# cd /code
[root@nginx code]# wget https://cn.wordpress.org/wordpress-5.0.3-zh_CN.tar.gz
#永遠(yuǎn)下載最新版
[root@nginx code]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@nginx ~]# tar xf wordpress-5.0.3-zh_CN.tar.gz
[root@nginx ~]# chown -R www.www /code/wordpress/

4)由于wordpress產(chǎn)品需要依賴數(shù)據(jù)庫,所以需要手動建立數(shù)據(jù)庫

[root@nginx ~]# mysql -uroot -pZls123.com
mysql> create database wordpress;
mysql> exit

5)通過瀏覽器訪問wordpress,并部署該產(chǎn)品

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?


思考問題:上傳文件報錯413,如何解決?

提示:nginx上傳大小的限制


部署知乎產(chǎn)品Wecenter

1.配置Nginx虛擬主機(jī)站點(diǎn),域名為zh.driverzeng.com

#1.nginx具體配置信息
[root@http-server ~]# cat /etc/nginx/conf.d/zh.conf
server {
 listen 80;
 server_name zh.driverzeng.com;
 root /code/zh;
 index index.php index.html;
 
 location ~ .php$ {
 root /code/zh;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
}
 
 
#2.重啟nginx服務(wù)
[root@http-server ~]# systemctl restart nginx

2.下載Wecenter產(chǎn)品,部署Wecenter并授權(quán)

官方下載地址:TP

[root@web02 ~]# wget http://ahdx.down.chinaz.com/201605/WeCenter_v3.2.1.zip
[root@web02 ~]# unzip WeCenter_3-2-1.zip
[root@web02 ~]# mv WeCenter_3-2-1/ /code/zh
[root@web02 ~]# chown -R www.www /code/zh/

3.由于wecenter產(chǎn)品需要依賴數(shù)據(jù)庫, 所以需要手動建立數(shù)據(jù)庫

#1.登陸數(shù)據(jù)庫
[root@http-server ~]# mysql -uroot -pZls123.com
 
#2.創(chuàng)建wordpress數(shù)據(jù)庫
MariaDB [(none)]> create database zh;
MariaDB [(none)]> exit

3.通過瀏覽器訪問網(wǎng)站

http://zh.driverzeng.com/install/

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

Nginx實(shí)現(xiàn)基礎(chǔ)Web架構(gòu)

 

?

當(dāng)然除了這些產(chǎn)品,還有很多我們可以嘗試著搭建的:

phpmyadmin

zblog

discuz

edusoho

分享到:
標(biāo)簽:架構(gòu) Nginx Web
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定