004.测试解析php,安装discuz

一.配置解析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.填写数据库信息和管理员信息:

填写数据库信息:
  数据库服务器:localhost
  数据库名:discuz
  数据库用户名:huh
  数据库密码:123456
  ***(其它保持不变)
填写管理员信息
  管理员帐号:admin
  管理员密码:123456
  重复密码:123456

安装成功!

相关文章
相关标签/搜索