LNMP搭建与Discuz安装

1. 安装Nginx

  1. yum install nginx -y
  2. systemctl enable --now nginx
  3. firewall-cmd --add-service=http --permanent
  4. firewall-cmd --reload

2. 安装mariadb

yum install mariadb mariadb-server -y
systemctl enable --now mariadb
# 初始化mariadb
mysql_secure_installation

3. 安装PHP

yum install php php-mysqlnd -y

# 开启php-fpm
systemctl enable --now php-fpm

vim /etc/nginx/nginx.conf

# 在nginx配置文件server字段里加入
location ~ .*\.php?$ {
    include fastcgi.conf;
}

# 重启nginx
systemctl restart nginx

4. 下载Discuz文件

用git在gitee上拉取Discuz的文件

yum install git -y 
git clone https://gitee.com/Discuz/DiscuzX.git

下面根据官方安装教程安装

将Discuz里面的upload目录下的所有文件上传到网站根目录

mv Discuz/upload/* /usr/share/nginx/html/

# 移动后重打SELinux标签
restorecon -Rv /usr/share/nginx/html

浏览器访问网站的install目录进行安装

如果访问失败查看防火墙或SELinux(80端口和SELinux标签)

根据提示安装必要的php扩展包:php-xml,php-mysql等

检查目录权限

问题:显示文件不可写

解决:

给对应的目录selinux打上httpd_sys_script_rw_t标签

chcon -t httpd_sys_script_rw_t /usr/share/nginx/html/config/ -R
chcon -t httpd_sys_script_rw_t /usr/share/nginx/html/data/ -R
chcon -t httpd_sys_script_rw_t /usr/share/nginx/html/uc_client/ -R
chcon -t httpd_sys_script_rw_t /usr/share/nginx/html/uc_server/ -R

问题:数据库没有权限访问

解决:

setsebool httpd_can_network_connect_db 1

论坛搭建完成!