創(chuàng)新互聯(lián)公司從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元長治做網(wǎng)站,已為上家服務(wù),為長治各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792
nginx的靜態(tài)處理能力很強(qiáng),動態(tài)處理能力不足,所以要把動態(tài)的頁面交給Apache,實(shí)現(xiàn)動靜分離。
[root@localhost ~]# yum install httpd httpd-devel -y ##安裝apacher軟件包
[root@localhost ~]# systemctl start httpd.service ##開啟服務(wù)
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=http ##永久允許http服務(wù)
success
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=https ##永久允許https服務(wù)
success
[root@localhost ~]# firewall-cmd --reload ##重新加載防火墻
success
MariaDB數(shù)據(jù)庫管理系統(tǒng)是MySQL的一個分支,主要由開源社區(qū)在維護(hù),采用GPL授權(quán)許可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕松成為MySQL的代替品。在存儲引擎方面,使用XtraDB(英語:XtraDB)來代替MySQL的InnoDB。 MariaDB由MySQL的創(chuàng)始人Michael Widenius(英語:Michael Widenius)主導(dǎo)開發(fā),他早前曾以10億美元的價格,將自己創(chuàng)建的公司MySQL AB賣給了SUN,此后,隨著SUN被甲骨文收購,MySQL的所有權(quán)也落入Oracle的手中。MariaDB名稱來自Michael Widenius的女兒Maria的名字。
yum install mariadb mariadb-server mariadb-libs mariadb-devel -y #安裝數(shù)據(jù)庫組件
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# netstat -natap | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 15154/mysqld
[root@localhost ~]# mysql_secure_installation
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): ##按回車
Set root password? [Y/n] y ##是否設(shè)置密碼
New password: #輸入你的密碼
Re-enter new password:
Remove anonymous users? [Y/n] y ##是否刪除匿名用戶,不刪
Disallow root login remotely? [Y/n] n ##是否讓root用戶遠(yuǎn)程登錄
Remove test database and access to it? [Y/n] n ##是否刪除測試數(shù)據(jù)庫
Reload privilege tables now? [Y/n] y ##是否加載里面的屬性列表
yum -y install php
##建立php和mysql關(guān)聯(lián)
yum install php-mysql -y
##安裝php插件
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
cd /var/www/html
vim index.php ##寫上PHP網(wǎng)頁
<?php
phpinfo();
?>
[root@localhost html]# systemctl restart httpd.service
[root@localhost ~]# yum install pcre-devel zlib-devel gcc gcc-c++ -y ##安裝環(huán)境包
[root@localhost ~]# useradd -M -s /sbin/nologin nginx ##創(chuàng)建程序性用戶
[root@localhost ~]# mkdir /chen ##創(chuàng)建掛載點(diǎn)
[root@localhost ~]# mount.cifs //192.168.100.23/LNMP /chen ##掛載
Password for root@//192.168.100.23/LNMP:
[root@localhost chen]# tar zxvf nginx-1.12.2.tar.gz -C /opt/ ##解壓
[root@localhost chen]# cd /opt/
[root@localhost opt]# ls
nginx-1.12.2 rh
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
./configure \ ##安裝組件
--prefix=/usr/local/nginx \ ##指定路徑
--user=nginx \ ##指定用戶
--group=nginx \ ##指定組
--with-http_stub_status_module ##狀態(tài)統(tǒng)計(jì)模塊
[root@localhost nginx-1.12.2]# make && make install ##編譯
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ##做軟連接
[root@localhost nginx-1.12.2]# nginx -t ##檢查語法
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx-1.12.2]# cd /etc/init.d/
[root@localhost init.d]# vim nginx
#!/bin/bash
#chkconfig: - 99 20 #注釋信息
#description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx" #這個變量,指向我的命令文件
PIDF="/usr/local/nginx/logs/nginx.pid" #這個變量,指向nginx的進(jìn)程號
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
[root@localhost init.d]# chmod +x nginx
[root@localhost init.d]# chkconfig --add nginx
[root@localhost init.d]# service nginx start
[root@localhost init.d]# netstat -ntap | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17544/nginx: master
[root@localhost init.d]# systemctl stop firewalld.service
[root@localhost init.d]# setenforce 0
[root@localhost init.d]# yum install elinks -y
[root@localhost init.d]# elinks http://192.168.136.162/ ##測試網(wǎng)站有沒有生效
[root@localhost init.d]# vim /usr/local/nginx/conf/nginx.conf
59 location ~ \.php$ {
60 proxy_pass http://192.168.136.174; ##在sever這個區(qū)域,修改地址,把動態(tài)的請求轉(zhuǎn)給174處理
61 }
[root@localhost init.d]# service nginx stop
[root@localhost init.d]# service nginx start
新聞標(biāo)題:Apache和LNMP架構(gòu)做動靜分離
文章URL:http://www.rwnh.cn/article26/ggohcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、動態(tài)網(wǎng)站、網(wǎng)站建設(shè)、小程序開發(fā)、做網(wǎng)站、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)