004.测试解析php,安装discuz
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了004.测试解析php,安装discuz相关的知识,希望对你有一定的参考价值。
一.配置解析php
编辑nginx配置文件/usr/local/nginx/conf/nginx.conf
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf
我们需要将php的配置行打开,找到这么几行:
#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;”
2.将“fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;”
改为"fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;"
改动后的结果:
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通信
二.检查nginx配置是否正确,重新加载nginx
[[email protected] ~]# /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 [[email protected] ~]# [[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload
三.关闭防火墙selinux和iptables
关闭selinux:
[[email protected] ~]# vim /etc/selinux/config
将"SELINUX=enforcing"配置行改为"SELINUX=disabled",保存退出!
[[email protected] ~]# getenforce
Enforcing
注:getenforce是临时关闭selinux的命令
清空iptables的filter表:
[[email protected] ~]# iptables -F [[email protected] ~]# /etc/init.d/iptables save iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
注:1."iptables -F" 命令将iptables的默认表filter表清空。
2."/etc/init.d/iptables save"将当前规则保存
四.测试解析php
测试能否访问web主页:
[[email protected] ~]# curl localhost -I HTTP/1.1 200 OK
我们也可以使用浏览器去访问,在浏览器中输服务器IP地址即可!本次实验虚拟机IP为192.168.199.226)
测试解析php:
[[email protected] ~]# cd /usr/local/nginx/html/ [[email protected] html]# vim info.php
写入内容为:
<?php
phpinfo();
?>
访问php文件:
http://192.168.199.226/info.php
php文件加载成功!
五.安装Discuz
下载解压discuz:
[[email protected] ~]# mkdir /data/www [[email protected] ~]# cd /data/www [[email protected] www]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
[[email protected] www]# unzip Discuz_X3.2_SC_GBK.zip
[[email protected] www]# mv upload/* ./
[[email protected] www]# rm -rf readme/ utility/ upload/ Discuz_X3.2_SC_GBK.zip
修改nginx配置文件,将其默认访问目录为/data/www:
[[email protected] 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
保存退出!
[[email protected] 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 [[email protected] www]# /usr/local/nginx/sbin/nginx -s reload
浏览器再次使用ip地址访问,开始安装discuz!
六.discuz在web上的配置
1.显示Discuz安装向导后,点击我同意
2.在服务器上执行如下命令,将那些红叉消除:
[[email protected] www]# cd /data/www/ [[email protected] www]# chown -R php-fpm config data uc_client/data uc_server/data
3.点击下一步
4.选择全新安装discuz,点击下一步
5.在mysql上创建数据库和用户:
[[email protected] ~]# 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.填写数据库信息和管理员信息:
安装成功!
以上是关于004.测试解析php,安装discuz的主要内容,如果未能解决你的问题,请参考以下文章