您现在的位置是:首页 > 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;
}

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)WORDwps办公资源教程资讯网站模板下载基于PbootCMS内核开发的响应式网站模板,为办公教程、WPS技巧分享、职场技能培训等场景打造。模板内置标准化文档分类体系,支持图文/视频教程混合展示,满足现代办公知识传播需求。查看源码
  • (自适应响应式)陶瓷研磨盘抛光机械设备pbootcms网站模板本模板基于PbootCMS系统开发,为研磨抛光设备制造企业设计,特别适合陶瓷研磨盘、抛光设备等表面处理设备展示。采用响应式布局技术,确保各类设备的参数和工艺在不同终端上都能清晰呈现。查看源码
  • (自适应响应式)蓝色勘察设计院机构单位商会协会pbootcms模板下载本模板基于PbootCMS系统开发,为勘察设计院所、工程咨询单位设计,特别适合展示设计成果、技术服务和项目案例。采用响应式技术,确保设计图纸和方案以及文案在不同设备上都能清晰展示。查看源码
  • (自适应)宽屏大气的净水器智能电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为净水器设备、智能电子设备企业量身打造,采用响应式设计技术,可快速构建专业级企业官网。通过本模板可高效展示产品技术参数、解决方案及企业服务优势。查看源码
  • (自适应响应式)刷卡机POS机无线支付设备pbootcms网站源码下载本模板基于PbootCMS系统开发,为支付终端设备企业设计,特别适合POS机、移动支付终端、刷卡设备等金融科技产品展示。采用响应式布局技术,确保各类支付终端产品在不同设备查看源码
  • 帝国cms7.5淘宝客电商品牌特价带手机站带会员模板下载为电商品牌特价展示设计的帝国CMS模板,集成PC端与移动端双平台适配。采用瀑布流商品布局,支持品牌分类聚合展示,突出特价促销视觉冲击力。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐