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

宝塔nginx服务器安装Discuz的步骤方法

涵双2025-06-29Discuz教程已有人查阅

导读需要说明的是,下网上以前一直流传的Rewrite都是有误的。下面的Rewrite中百分号前面多了个转移字符“\”,这在Apache中是需要的,而在Nginx中则是不需要的。

需要说明的是,下网上以前一直流传的Rewrite都是有误的。
下面的Rewrite中百分号前面多了个转移字符“\”,这在Apache中是需要的,而在Nginx中则是不需要的。
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last;
正确的应该是
​​​​​​​rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
这个错误在基本上目前所有使用Nginx作为服务器,并且开启了Rewrite的网站上存在包括Discuz!官方。
Nginx实例代码
server {
listen 80;
server_name.yoursite.com yoursite.com;
location /{
index index.html index.htm index.php;
root /www/ .yoursite.com;
rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
}
location ~\.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:8694;
fastcgi_param SCRIPT_FILENAME /www/www.yoursite.com$fastcgi_script_name;
}
location /www.yoursite.com-status {
stub_status on;
access_log off;
}
}
宝塔安装Discuz使用中的配置server
{
listen 80;
server_name.youtsite.com youtsite.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/root/ .youtsite.com;
#error_page 404/404.html;
error_page 404 /404.html;
error_page 502 /502.html;
include enable-php-56.conf;
include /www/server/panel/vhost/rewrite/ .youtsite.com.conf;
location /{
index index.html index.htm index.php;
root /www/ root/ .youtsite.com;
rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
rewrite ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
}
location ~\.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:8694;
fastcgi_param SCRIPT_FILENAME /www/ root/www.youtsite.com$fastcgi_script_name;
}
location/root/www.youtsite.com-status {
stub_status on;
access_log off;
}
access_log /www/logs/www.youtsite.com.log;
}

本文标签:

很赞哦! ()

相关源码

  • (自适应)蓝色英文外贸电子科技产品带三级栏目网站模板为外贸企业设计的英文网站模板,基于PbootCMS系统开发。突出多语言支持和国际化布局,三级栏目结构清晰展示产品分类,响应式设计确保更好客户在移动端和PC端获得一致的专业体验。查看源码
  • (PC+WAP)历史复古古典古籍文章资讯类pbootcms模板下载本模板基于PbootCMS系统开发,为古籍研究、历史文献类网站设计,特别适合展示古典书籍、历史档案等文化内容。采用复古风格设计,同时具备现代化响应式布局,确保在PC和移动设备上都能呈现优雅的阅读体验。查看源码
  • 响应式粉色美容整形化妆品pbootcms网站模板开源源码该网站模板为美容整形、化妆品企业设计,采用响应式布局确保在手机、平板及PC端自动适配显示效果。基于PbootCMS内核开发,支持一键替换图文内容快速转换至其他行业应用。查看源码
  • (自适应)建站广告公司工作室作品展示品牌策划设计pbootcms源码下载基于PbootCMS开发的创意服务展示系统,内置作品集展示、服务流程图等专业模块,预设客户案例、设计流程等创意行业专属栏目结构。查看源码
  • pbootcms网站模板响应式全屏旅游景区网站源码本模板为风景民宿、旅游景区等企业设计,基于PbootCMS内核开发,具备响应式布局与专业SEO优化功能,助力企业低成本高效获客。以下是核心特点:查看源码
  • (PC+WAP)绿色市政园林建筑设计绿化营销型pbootcms网站模板本模板基于PbootCMS系统开发,为园林绿化、景观设计类企业设计,特别适合市政园林、景观工程、绿化养护等企业使用。采用双端适配技术查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐