Discuz! Q 官方文档之Web服务器配置
- Web服务器推荐启用SSL(https协议),如果没有SSL证书,可以到这里申请。
复制代码 Nginx
如果你使用 Nginx ,除了PHP的相关配置之外,还要在你的站点配置中加入以下配置,建议(非强制)开启 https 和 http2 ,将root目录指向 discuz/public 目录,同时一定要配置 index 和 location /,将所有的请求将引导至 index.php 。
具体配置时,请注意对照检查这样一些地方:
#root 配置
确认 root 指向了安装好的 public 目录,以下是示例,请按自己的实际配置设置
- root /home/www/discuz/public;
复制代码 index 配置
确保 index 的第一项是 index.php ,也可以只保留 index.php,以下为示例
location 配置
确保 location / 按如下配置,如果原来有配置,请替换成如下配置:
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- }
复制代码 Apache
Apache要在配置中,将 DocumentRoot 指向 discuz/public 目录,同时通过重写规则,将所有请求转发给 index.php 处理。
在 discuz/public 下创建 .htaccess 文件(设置伪静态规则),内容如下(此配置依赖 mod_rewrite ,请先检查自己的Apache是否启用了 mod_rewrite 模块):
- <IfModule mod_rewrite.c>
- Options +FollowSymLinks
- RewriteEngine On
- SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . index.php?%{QUERY_STRING} [L,QSA,PT]
- RewriteRule ^$ index.php?%{QUERY_STRING} [L,QSA,PT]
- </IfModule>
复制代码
|
|