您好,登錄后才能下訂單哦!
nginx的靜態(tài)處理能力很強,動態(tài)處理能力不足,所以要把動態(tài)的頁面交給Apache,實現(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ū)在維護,采用GPL授權(quán)許可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕松成為MySQL的代替品。在存儲引擎方面,使用XtraDB(英語:XtraDB)來代替MySQL的InnoDB。 MariaDB由MySQL的創(chuàng)始人Michael Widenius(英語:Michael Widenius)主導開發(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用戶遠程登錄
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)建掛載點
[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)計模塊
[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的進程號
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
免責聲明:本站發(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)容。