itwiki:nginx-doku

NGINX 范例:DOKUWIKI

1. 安装 Nginx: Nginx 实践

2. 安装PHP-FPM,并做好一些调试,比如最大上传文件限制

3. 使用 $url/install.php 安装Wiki系统

4. 在Wiki的用户配置中启用 REWRITE 技术

  • 使用管理员账户登录Wiki,点击管理-配置设置
  • 打开两个配置项:使用更整洁的URL → 选择.htaccess;使用斜杆作为名称空间分隔符 → 选择“是”

5. 在NGINX的配置文件中启用 REWRITE 技术,将形如doku.php?id=namespace:pagename这样的链接改写成/namespace/pagename同时将媒体的链接也作改写,NGINX配置片段如下

以下为 SSL + REWRITE + 控制部分关键文件和文件夹

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name ovwx.org;
    charset utf-8;

    # ssl配置
    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_ecdh_curve secp384r1;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_session_tickets off;
    ssl_certificate /opt/acme/ovwx.org_ecc/fullchain.cer;
    ssl_certificate_key /opt/acme/ovwx.org_ecc/ovwx.org.key;

    #root /var/www/html/;
    root /var/www/dokuwiki/;
    #index index.php;
    index doku.php;

    #RE-WRITE

    location / { try_files $uri $uri/ @dokuwiki; }

    location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1&$args last;
    }

    location ~ \.(php|php5).* {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php-fpm/www.sock;
        include fastcgi_params;
    }

    location ^~ /usr/typecho.db {
        return 404;
    }

    location ~ /(conf|bin|inc|vendor)/ {
        deny all;
    }

    location ~ /data/ {
        internal;
    }
}

6. 备份 两种选择:一种是备份整个程序文件夹,一种是备份./dataconf文件夹

  • itwiki/nginx-doku.txt
  • 最后更改: 2024/01/03 12:20
  • ovwx@live.io