官术网_书友最值得收藏!

  • NGINX Cookbook
  • Tim Butler
  • 127字
  • 2021-07-03 00:04:25

How to do it...

The basic NGINX configuration for MediaWiki is very similar to many other PHP platforms. It has a flat directory structure which easily runs with basic system resources.

Here's the configuration:

server { 
    listen       80; 
    server_name  mediawiki.nginxcookbook.com; 
 
    access_log  /var/log/nginx/mediawiki.access.log  combined; 
    index index.php; 
 
    root   /var/www/html/; 
 
    location / { 
        try_files $uri $uri/ /index.php?$args; 
    } 
 
    location ~ \.php$ { 
        fastcgi_pass unix:/var/run/php7.0-fpm.sock; 
        fastcgi_index index.php; 
        fastcgi_param SCRIPT_FILENAME 
$document_root$fastcgi_script_name; include fastcgi_params; } }

The default installation doesn't use any rewrite rules, which means you'll get URLs such as index.php?title=Main_Page instead of the neater (and more readable) /wiki/Main_Page. To enable this, we need to edit the LocalSettings.php file and add the following lines:

$wgArticlePath = "/wiki/$1"; 
$wgUsePathInfo = TRUE; 

This allows the URLs to be rewritten in a much neater format.

主站蜘蛛池模板: 巴林右旗| 大埔区| 福贡县| 江门市| 丹凤县| 盐山县| 崇礼县| 桦甸市| 宜黄县| 宜城市| 渑池县| 松阳县| 东海县| 乌拉特后旗| 桦南县| 蒲城县| 香港| 屯留县| 宾阳县| 南丹县| 修文县| 昌宁县| 施秉县| 宜昌市| 邯郸县| 赫章县| 安福县| 石河子市| 沾化县| 仁寿县| 江源县| 双柏县| 新平| 枞阳县| 诸城市| 张家川| 虎林市| 阳西县| 陵川县| 泰和县| 黑龙江省|