真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做?。?創(chuàng)新互聯(lián)

Nginx動(dòng)靜分離介紹

1.Nginx的靜態(tài)處理能力很強(qiáng),但是動(dòng)態(tài)處理不足,因此,在企業(yè)中常用動(dòng)靜分離技術(shù)
2.針對(duì)PHP的動(dòng)靜分離

靜態(tài)頁(yè)面交給Nginx處理

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供大名網(wǎng)站建設(shè)、大名做網(wǎng)站、大名網(wǎng)站設(shè)計(jì)、大名網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、大名企業(yè)網(wǎng)站模板建站服務(wù),10余年大名做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

動(dòng)態(tài)頁(yè)面交給PHP+FPM模塊或Apache處理

3.在Nginx的配置中,是通過(guò)location配置段配合正則匹配實(shí)現(xiàn)靜態(tài)與動(dòng)態(tài)頁(yè)面的不同處理方式

反向代理原理

1.Nginx不僅能作為Web服務(wù)器,還具有反向代理、負(fù)載均衡和緩存的功能
2.Nginx通過(guò)proxy模塊實(shí)現(xiàn)將客戶端的請(qǐng)求代理至,上游服務(wù)器,此時(shí)nginx與.上游服務(wù)器的連接是通過(guò)http協(xié)議進(jìn)行的
3.Nginx在實(shí)現(xiàn)反向代理功能時(shí)的最重要指令為proxy_pass, 它能夠并能夠根據(jù)URI、客戶端參數(shù)或其它的處理邏輯將用戶請(qǐng)求調(diào)度至,上游服務(wù)器

配置Nginx實(shí)現(xiàn)動(dòng)靜分離

1.本案例根據(jù)企業(yè)需要,將配置Nginx實(shí)現(xiàn)動(dòng)靜分離,對(duì)php頁(yè)面的請(qǐng)求轉(zhuǎn)發(fā)給LAMP處理,而靜態(tài)頁(yè)面交給Nginx處理,以實(shí)現(xiàn)動(dòng)靜分離

2.架構(gòu)如圖所示:

部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做!)

配置步驟:

1.配置Nginx處理動(dòng)態(tài)頁(yè)面請(qǐng)求,在server{};中加入
2.在Apache.工作目錄新建test.php
3.重啟Nginx并測(cè)試

[root@nginx php5]#vim /usr/local/httpd/conf/nginx.conf
  server {
  .....
  location ~ \.php$ {
        proxy_pass http://192.168.9.237:8080;
......                                          //LAMP的IP地址

Demo:

環(huán)境準(zhǔn)備:兩臺(tái)CentOS 7,其中7-3做為lamp,7-4做為nginx
第一步:安裝httpd
[root@localhost ~]# yum install httpd httpd-devel -y
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# systemctl start httpd
此時(shí)可以使用宿主機(jī)訪問(wèn)Apache的主頁(yè)如下圖所示:

部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做?。?></p><h5>第二步:安裝mariadb數(shù)據(jù)庫(kù)(快捷輕量化的數(shù)據(jù)庫(kù))</h5><pre><code>[root@lamp ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y
[root@lamp ~]# systemctl start mariadb
[root@lamp ~]# systemctl start mariadb
[root@lamp ~]# netstat -ntap | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*       LISTEN      16836/mysqld    
[root@lamp ~]# mysql_secure_installation                //對(duì)數(shù)據(jù)庫(kù)進(jìn)行設(shè)置
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):       //給root管理員設(shè)定密碼,直接回車  
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y      //是否設(shè)置,選擇yes
New password:       //輸入新密碼
Re-enter new password:      //重復(fù)輸入新密碼
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] n     //是否刪除匿名用戶,選擇no
 ... skipping.
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n       //是否拒絕root用戶遠(yuǎn)程登陸,選擇no
 ... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n      //是否刪除測(cè)試數(shù)據(jù)庫(kù),選擇no
 ... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y        //是否加載權(quán)限列表,選擇yes
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!</code></pre><h5>第三步:安裝php</h5><pre><code>[root@lamp ~]# yum install php -y 
[root@lamp ~]# yum install php-mysql -y
[root@lamp ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
[root@lamp ~]# cd /var/www/html/
[root@lamp html]# ls
[root@lamp html]# vim index.php
<?php
  phpinfo();
?>
輸入:wq保存退出
[root@lamp html]# systemctl restart httpd.service</code></pre><h6>這時(shí)在宿主機(jī)的瀏覽器中輸入地址:http://192.168.18.128/index.php,就可以訪問(wèn)到lamp的php主頁(yè)</h6><p><img src= 輸入:wq保存退出

此時(shí) http://192.168.18.128/index.php 這個(gè)地址上顯示的內(nèi)容如下:

部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做?。?></p><h5>Nginx上的操作:</h5><pre><code>[root@nginx ~]# mkdir /aaa
[root@nginx ~]# mount.cifs //192.168.10.193/rpm /aaa
Password for root@//192.168.10.193/rpm:  
[root@nginx ~]# cd /aaa
[root@nginx aaa]# ls
apr-1.6.2.tar.gz                  error.png                  nginx-1.12.2.tar.gz
apr-util-1.6.0.tar.gz             httpd-2.4.29.tar.bz2       php-7.1.10.tar.bz2
awstats-7.6.tar.gz                lf.jpg                     php-7.1.20.tar.gz
cronolog-1.6.2-14.el7.x86_64.rpm  mysql-5.6.26.tar.gz
Discuz_X3.4_SC_UTF8.zip           mysql-boost-5.7.20.tar.gz
[root@nginx aaa]# tar zxvf nginx-1.12.2.tar.gz -C /opt/ 
[root@nginx aaa]# cd /opt
[root@nginx opt]# ls
nginx-1.12.2  rh
[root@nginx opt]# cd nginx-1.12.2/
[root@nginx nginx-1.12.2]# useradd -M -s /sbin/nologin nginx
[root@nginx nginx-1.12.2]# yum install gcc gcc-c++ pcre-devel zlib-devel -y
[root@nginx nginx-1.12.2]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
[root@nginx nginx-1.12.2]# make && make install
[root@nginx nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@nginx nginx-1.12.2]# vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Service Control Script
PROG=

此時(shí)得到如下界面,可按q,選擇yes,回車退出

部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做?。?></p><h5>此時(shí)在宿主機(jī)輸入:http://192.168.18.136/index.html 這個(gè)網(wǎng)址,會(huì)得到以下界面</h5><p><img src=

結(jié)論:后綴為html就是靜態(tài)元素,后綴為php就是動(dòng)態(tài)元素,地址是不用改變的,因?yàn)槲覀冊(cè)谄渲凶隽宿D(zhuǎn)發(fā)處理!動(dòng)靜分離實(shí)驗(yàn)成功!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


分享標(biāo)題:部署Nginx+Apache動(dòng)靜分離(實(shí)戰(zhàn)!可跟做!)-創(chuàng)新互聯(lián)
瀏覽路徑:http://weahome.cn/article/dedsch.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部