• 004.测试解析php,安装discuz


    一.配置解析php

    编辑nginx配置文件/usr/local/nginx/conf/nginx.conf

    [root@huh ~]# 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

    [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

    安装成功!

  • 相关阅读:
    CyQ.data MDataTable
    IIS报错问题:MVC 网站部署到.NET空间上出现Web 服务器被配置为不列出此目录的内容。
    Field configService in com.rr.web.controller.common.CaptchaController required a single bean, but 2 were found: SPRINGBOOT 启动 错误
    学习前端遇到的一些东东
    SQLite If Else Case 实现
    C# WinForm 绘制手写签名
    Android listView典型错误分析(经验体会)
    Flink 如何通过2PC实现Exactlyonce语义 (源码分析)
    bash中特殊符号含义总结
    两头编程,测试中间
  • 原文地址:https://www.cnblogs.com/ruo-yu/p/5167669.html
Copyright © 2020-2023  润新知