一.配置解析phpphp
編輯nginx配置文件/usr/local/nginx/conf/nginx.confhtml
[root@huh ~]# vim /usr/local/nginx/conf/nginx.conf
咱們須要將php的配置行打開,找到這麼幾行:mysql
#location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #}
1.將"fastcgi_pass 127.0.0.1:9000;"改成「fastcgi_pass unix:/tmp/www.sock;」linux
2.將「fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;」nginx
改成"fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;"web
改動後的結果:sql
location ~ \.php$ { root html; fastcgi_pass unix:/tmp/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; }
注:1./usr/local/nginx/html是網站根目錄的所在,網頁只有放在這兒才能被找到數據庫
2.php當前監聽的套接字文件爲/tmp/www.sock,nginx經過這個文件和php通訊vim
二.檢查nginx配置是否正確,從新加載nginx瀏覽器
[root@huh ~]# /usr/local/nginx/sbin/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@huh ~]# [root@huh ~]# /usr/local/nginx/sbin/nginx -s reload
三.關閉防火牆selinux和iptables
關閉selinux:
[root@huh ~]# vim /etc/selinux/config
將"SELINUX=enforcing"配置行改成"SELINUX=disabled",保存退出!
[root@huh ~]# getenforce
Enforcing
注:getenforce是臨時關閉selinux的命令
清空iptables的filter表:
[root@huh ~]# iptables -F [root@huh ~]# /etc/init.d/iptables save iptables:將防火牆規則保存到 /etc/sysconfig/iptables: [肯定]
注:1."iptables -F" 命令將iptables的默認表filter表清空。
2."/etc/init.d/iptables save"將當前規則保存
四.測試解析php
測試可否訪問web主頁:
[root@huh ~]# curl localhost -I HTTP/1.1 200 OK
咱們也能夠使用瀏覽器去訪問,在瀏覽器中輸服務器IP地址便可!本次實驗虛擬機IP爲192.168.199.226)
測試解析php:
[root@huh ~]# cd /usr/local/nginx/html/ [root@huh html]# vim info.php
寫入內容爲:
<?php
phpinfo();
?>
訪問php文件:
http://192.168.199.226/info.php
php文件加載成功!
五.安裝Discuz
下載解壓discuz:
[root@huh ~]# mkdir /data/www [root@huh ~]# cd /data/www [root@huh www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
[root@huh www]# unzip Discuz_X3.2_SC_GBK.zip
[root@huh www]# mv upload/* ./
[root@huh www]# rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip
修改nginx配置文件,將其默認訪問目錄爲/data/www:
[root@huh www]# vim /usr/local/nginx/conf/nginx.conf
1.找到以下配置行:
location / { root html; index index.html index.htm; }
並將其改成:
root /data/www; index index.html index.htm index.php;
2.找到配置行" fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;"將其中的/usr/local/nginx/html替換爲/data/www
保存退出!
[root@huh www]# /usr/local/nginx/sbin/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@huh www]# /usr/local/nginx/sbin/nginx -s reload
瀏覽器再次使用ip地址訪問,開始安裝discuz!
六.discuz在web上的配置
1.顯示Discuz安裝嚮導後,點擊我贊成
2.在服務器上執行以下命令,將那些紅叉消除:
[root@huh www]# cd /data/www/ [root@huh www]# chown -R php-fpm config data uc_client/data uc_server/data
3.點擊下一步
4.選擇全新安裝discuz,點擊下一步
5.在mysql上建立數據庫和用戶:
[root@huh ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. mysql> create database discuz; Query OK, 1 row affected (0.00 sec) mysql> grant all on discuz.* to 'huh'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
6.填寫數據庫信息和管理員信息:
安裝成功!