匿名
未登录
创建账号
登录
istudylinux
搜索
查看“ShortURL配置/nginx”的源代码
来自istudylinux
命名空间
页面
讨论
更多
更多
页面操作
阅读
查看源代码
历史
←
ShortURL配置/nginx
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 环境 == {| class="wikitable" |- ! 名称 !! 内容 |- | 网页root目录 || /var/www/html |- | mw文件夹 || /var/www/html/myGod |- | LocalSettings.php || /var/www/html/myGod/LocalSettings.php |- | nginx配置文件 || /etc/nginx/site-enabled/mywiki.conf |- | 最后URL结果 || http://mw.istudylinux.cn/wiki/首页 |} 仅需要更改两个地方。<ref>[https://www.mediawiki.org/wiki/Manual:Short_URL/Nginx ShortURL的nginx改法]</ref> == mywiki.conf == 下面的内容可以更改两个地方,一个是mywiki,一个是66行后的wiki字段。 * myGod就是上面的mw文件夹名称 * wiki就是你改动后的URL后面首页前面的名称,也可以改为fun,boy,abc,随你喜好 <syntaxhighlight lang="nginx" line="true" highlight="2,5-76"> server { root /var/www/html; ... # Location for wiki's entry points location ~ ^/myGod/(index|load|api|thumb|opensearch_desc|rest|img_auth)\.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on } # Images location /myGod/images { # Separate location for images/ so .php execution won't apply } location /myGod/images/deleted { # Deny access to deleted images folder deny all; } # MediaWiki assets (usually images) location ~ ^/myGod/resources/(assets|lib|src) { try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Assets, scripts and styles from skins and extensions location ~ ^/myGod/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ { try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Favicon location = /favicon.ico { alias /myGod/images/6/64/Favicon.ico; add_header Cache-Control "public"; expires 7d; } # License and credits files location ~ ^/myGod/(COPYING|CREDITS)$ { default_type text/plain; } ## Uncomment the following code if you wish to use the installer/updater ## installer/updater #location /myGod/mw-config/ { # # Do this inside of a location so it can be negated # location ~ \.php$ { # include /etc/nginx/fastcgi_params; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on # } #} # Handling for Mediawiki REST API, see [[mw:API:REST_API]] location /myGod/rest.php/ { try_files $uri $uri/ /myGod/rest.php?$query_string; } ## Uncomment the following code for handling image authentication ## Also add "deny all;" in the location for /w/images above #location /myGod/img_auth.php/ { # try_files $uri $uri/ /myGod/img_auth.php?$query_string; #} # Handling for the article path (pretty URLs) location /wiki/ { rewrite ^/wiki/(?<pagename>.*)$ /myGod/index.php; } # Allow robots.txt in case you have one location = /robots.txt { } # Explicit access to the root website, redirect to main page (adapt as needed) location = / { return 301 /wiki/首页; } ... } </syntaxhighlight> == LocalSettings.php == 在页面后面添加如下内容: <syntaxhighlight lang="php" line="true" highlight="1-4"> # 配置shortURL $wgScriptPath = "/myGod"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true; </syntaxhighlight> == 参考 ==
返回至“
ShortURL配置/nginx
”。
导航
导航
首页
最近更改
随机页面
MediaWiki帮助
Wiki工具
Wiki工具
特殊页面
页面值
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志