您好,登錄后才能下訂單哦!
- Nginx的靜態(tài)處理能力很強,但是動態(tài)處理能力不足,因此,在企業(yè)中常用動靜分離技術(shù)
- 針對PHP的動靜分離
靜態(tài)頁面交給Nginx處理
動態(tài)頁面交給PHP-FPM模塊或Apache處理- 在Nginx的配置中,是通過location配置段配個正則匹配實現(xiàn)靜態(tài)與動態(tài)頁面的不同處理方式
LAMP服務(wù)器(192.168.13.139)
Nginx服務(wù)器(192.168.13.140)
[root@lamp ~]# yum install httpd httpd-devel -y ##安裝http服務(wù)及開發(fā)包
[root@lamp ~]# systemctl start httpd.service ##開啟服務(wù)
[root@lamp ~]# firewall-cmd --permanent --zone=public --add-service=http ##防火墻允許http
success
[root@lamp ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@lamp ~]# firewall-cmd --reload ##重啟防火墻
success
[root@lamp ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y
##安裝數(shù)據(jù)庫
[root@lamp ~]# systemctl start mariadb ##開啟數(shù)據(jù)庫
[root@lamp ~]# netstat -ntap | grep 3306 ##查看端口號3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2200/mysqld
[root@lamp ~]# mysql_secure_installation ##設(shè)置數(shù)據(jù)庫
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è)置root密碼
New password: ##輸入密碼
Re-enter new password: ##確認密碼
Remove anonymous users? [Y/n] n ##允許匿名訪問
... skipping.
Disallow root login remotely? [Y/n] n ##允許遠程登錄
... skipping.
Remove test database and access to it? [Y/n] n ##保留測試數(shù)據(jù)庫
... skipping.
Reload privilege tables now? [Y/n] y ##重啟數(shù)據(jù)庫
... 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!
[root@lamp ~]# yum install php -y ##安裝PHP
[root@lamp ~]# yum install php-mysql -y ##建立php和mysql關(guān)聯(lián)
[root@lamp ~]# yum install -y \
> php-gd ##GD庫是php處理圖形的擴展庫
> php-ldap ##輕量級目錄訪問協(xié)議
> php-odbc ##應(yīng)用程序編程接口
> php-pear ##擴展應(yīng)用代碼庫
> php-xml php-xmlrpc ##xml文件
> php-mbstring ##多字節(jié)字符串
> php-snmp ##管理端開發(fā)
> php-soap ##SOAP 擴展可以用來提供和使用 Web Services
> curl curl-devel ##支持數(shù)據(jù)文件下載工具
> php-bcmath ##BCMath庫來支持更加精確的計算
[root@lamp ~]# cd /var/www/html/ ##切換到站點
[root@lamp html]# vim index.php ##編輯php網(wǎng)頁內(nèi)容
<?php
phpinfo();
?>
[root@localhost init.d]# yum install elink -y ##安裝軟件
[root@localhost init.d]# netstat -ntap | grep 80 ##查看Nginx端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 44663/nginx: master
[root@localhost init.d]# systemctl stop firewalld.service ##關(guān)閉防火墻
[root@localhost init.d]# setenforce 0
[root@localhost init.d]# elinks http://192.168.13.140/ ##測試網(wǎng)頁
[root@localhost init.d]# vim /usr/local/nginx/conf/nginx.conf ##修改配置文件
location ~ \.php$ { ##找到此處將注釋去除,開啟動靜分離
proxy_pass http://192.168.13.139; ##填寫動態(tài)處理的Apache的服務(wù)器地址
}
[root@localhost init.d]# service nginx stop ##關(guān)閉
[root@localhost init.d]# service nginx start ##開啟
向AI問一下細節(jié)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。