您现在的位置是:首页 > cms教程 > Discuz教程Discuz教程

Linux环境怎么搭建Discuz论坛

肖任2025-06-26Discuz教程已有人查阅

导读在Nginx服务器下面配置bbs的Vhostsvim /usr/local/nginx/conf/nginx.conf -->添加includechown -R nginx.nginx bbs/ -->涉及用户提交头像等操作,简单起见,先改为nginx,后进行修改

##创建BBS数据库在本地/远程服务器mysql -uroot -proot
create database bbs;
show databases;
grant all on bbs.*to bbs@'localhost' identified by 'root';
grant all on bbs.*to bbs@'192.168.25.%' identified by 'root'; # 远程mysql服务器
flush privileges;
select user,host from mysql.user;
##远程连接数据库: mysql -ubbs -proot -h 192.168.25.138
echo ' 192.168.25.144.bbs.com bbs.com'>> /etc/hosts
##配置BBS和Nginx
在Nginx服务器下面配置bbs的Vhostsvim /usr/local/nginx/conf/nginx.conf -->添加include
vim /usr/local/nginx/conf/extra/bbs.conf -->配置域名
vim /etc/hosts -->添加DNS解析
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload -->重启服务
mkdir -p /usr/local/nginx/html/bbs -->创建虚拟路径
cd /usr/local/nginx/html
chown -R root.root ./bbs
find ./blog/ -type f|xargs chmod 644
find ./blog/ -type d|xargs chmod 755 -->更改权限
server { listen 80; server_name.bbs.com; root html/discuz; location / {
# index index.html index.htm;
index index.php index.html index.htm;
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;if (!-e $request_filename) { return 404;} } location ~.*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/access_discuz.log main; }
bbs.conf
##下载&&安装BBSwget http://ahdx.down.chinaz.com/201712/Discuz_X3.4_SC_UTF8_0101.zip -->q不显示
unzip Discuz_X3.4_SC_UTF8*.zip
rm Discuz_X3.4_SC_UTF8*.zip -rf
cd /usr/local/nginx/html/bbs
cp -rf upload/* ./ -->把文件直接放在bbs的根目录下,upload有安装脚本
chmod 644 /usr/local/nginx/html/bbs/*
chown -R nginx.nginx bbs/ -->涉及用户提交头像等操作,简单起见,先改为nginx,后进行修改
页面显示:
检查安装环境
收回数据库权限:
drop user bbs@'192.168.25.%';
flush privileges;
grant update,insert,delete,drop,select on bbs.*to bbs@'192.168.25.%' identified by 'root';
删除安装程序,防止论坛再次安装rm -rf /usr/local/nginx/html/bbs/install
用户上传的数据:--》将来挂在到NFS上
上传图片的路径:cd /usr/local/nginx/html/bbs/data/attachment/forum/201709/02
查看头像文件上传路径
cd /usr/local/nginx/html/bbs
find ./ type f -name '*.jpg' -mmin -13
./uc_server/data/avatar/000/00/00/01_avatar_small.jpg
#伪静态化
1.前台
管理 ->全局 ->SOE设置 ->勾选URL静态化 ->提交
2.添加如下内容到/extra/bbs.conf 默认的location / 里 [可以查看discuz的规则添加即可]
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;if (!-e $request_filename) { return 404;}
3.测试并且重启服务

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)电子数码科技产品介绍带留言网站模板下载为电子产品企业设计的展示系统,集成智能产品对比器、参数规格表和展示模块。支持消费电子、智能设备等多级分类展示,内置产品技术参数数据库。查看源码
  • 深蓝色风景摄影机构网站(自适应多端)pbootcms模板该模板基于PbootCMS内核开发,专为风景摄影机构、户外摄影企业设计,采用深蓝色主题传递专业与艺术感,全栈响应式架构确保PC、平板、手机端无缝适配PHP程序结合轻量级SQLite数据库也可以更换MySQL数据库查看源码
  • (自适应)绿色农业大型机械设备展示网站模板下载基于PbootCMS内核深度定制开发的农业机械行业专用模板。针对农机设备展示、产品参数说明等需求优化设计,突出农业机械行业特性查看源码
  • (自适应响应式)黑色LED显示屏户外广告屏网站源码下载这是一款基于PbootCMS内核开发的响应式网站模板,专门为LED显示屏及户外广告行业打造。模板适配各类显示设备,帮助企业快速搭建专业官网,展示产品与服务优势,有效提升品牌形象。查看源码
  • pbootcms模板(自适应)花店鲜花花卉园艺网站源码一款基于PbootCMS内核开发的花店鲜花配送与花卉园艺企业网站模板。该模板采用响应式设计,自动适配手机、平板等移动设备,确保用户在任何设备上都能获得优质浏览体验。查看源码
  • Wordpress博客新闻主题在线商店平台betheme 21.5.6版BeTheme是一款功能丰富的WordPress主题模板,专注于为各行业提供网站建设解决方案。该模板支持WooCommerce电子商务功能,能够快速搭建在线商店平台,同时适用于博客、新闻资讯类网站建设。自2014年发布以来,该模板已经获得大量用户的使用验证。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐