您好,登錄后才能下訂單哦!
靜態(tài)頁(yè)面交給Nginx處理
動(dòng)態(tài)頁(yè)面交給PHP+FPM模塊或Apache處理
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ù)器
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)如圖所示:
[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
[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!
[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
[root@lamp html]# vim index.php <?php echo "apache web !" ?> 輸入:wq保存退出
[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="/usr/local/nginx/sbin/nginx" PIDF="/usr/local/nginx/logs/nginx.pid" case "$1" in start) $PROG ;; stop) kill -s QUIT $(cat $PIDF) ;; restart) $0 stop $0 start ;; reload) kill -s HUP $(cat $PIDF) ;; *) echo "Usage: $0 {start|stop|restart|reload}" exit 1 esac exit 0 輸入:wq保存退出 [root@nginx nginx-1.12.2]# chmod +x /etc/init.d/nginx [root@nginx nginx-1.12.2]# chkconfig --add nginx [root@nginx nginx-1.12.2]# yum install elinks -y [root@nginx nginx-1.12.2]# service nginx start [root@nginx nginx-1.12.2]# netstat -ntap | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 42028/nginx: master [root@nginx nginx-1.12.2]# systemctl stop firewalld.service [root@nginx nginx-1.12.2]# setenforce 0 root@nginx nginx-1.12.2]# elinks http://192.168.18.136/
[root@nginx nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf location ~ \.php$ { proxy_pass http://192.168.18.128; } #以上內(nèi)容意思為:動(dòng)態(tài)請(qǐng)求轉(zhuǎn)交給誰(shuí)去處理 #我們找到以上內(nèi)容將前面的注釋去掉,并將其中的IP地址改為另外一臺(tái)7-3的地址 輸入:wq保存退出 [root@nginx nginx-1.12.2]# service nginx stop [root@nginx nginx-1.12.2]# service nginx start
向AI問(wèn)一下細(xì)節(jié)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。