基于lnmp环境安装Discuz

时间:2022-06-13 15:44:24

安装环境

Linux:CentOS Linux release 7.5.1804 (Core)

nginx:1.14.2

php-fpm:5.4.16

mariadb-server:5.5.60

基本以上信息安装lnmp环境

安装nginx的yum源

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装相关软件包

yum -y install vim lrzsz nginx php-fpm mariadb-server php-mysql

关闭SELinux

setenforce 0

防火墙开启相关端口

firewall-cmd --zone=public --add-service=http
firewall-cmd --zone=public --add-port=9000/tcp
firewall-cmd --zone=public --add-service=mysql

启动数据库、创建账号

systemctl start mariadb
mysql -e "grant all privileges on *.* to user1@'%' identified by '123456';"
mysql -e "flush privileges;"

创建虚拟主机文件

在/etc/nginx/conf.d/下创建.conf结尾的虚拟主机配置文件 :

server {
listen 80;
server_name www.a.com;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} #
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }

删除原有default配置文件

检测nginx配置文件语法:

nginx -t

启动相关服务

systemctl start php-fpm
systemctl restart nginx

安装Discuz

上传Discuz_X3.3_SC_UTF8.zip 到服务器,解压,复制upload目录下全部文件到/usr/share/nginx/html/下

设置facl权限

setfacl -R -m u:nginx:rwx ./*
setfacl -R -m u:apache:rwx ./*

重启nginx服务,web登录,初始化相关数据。

回收facl权限

setfacl -b ./*