wiki:linux:nginx-php-dokuwiki

示例:Dokuwiki 网站在 Nginx & PHP7.0 环境下的配置

Nginx 配置文件: /etc/nginx/sites-available/xxx.com

功能:

  • 开启php功能
  • 开启rewrite功能
  • www.example.com 自动重定向到 example.com
server {
  server_name example.com;
  listen 80;
  autoindex off;
  client_max_body_size 15M;
  client_body_buffer_size 128k;
  index index.html index.htm index.php doku.php;
  #access_log  /var/log/nginx/example.com/access.log;
  #error_log  /var/log/nginx/example.com/error.log;
  root /var/www/example.com;

  location / {
    try_files $uri $uri/ @dokuwiki;
    if (!-f $request_filename)
    {
        rewrite ^(/)(.*)?(.*)  $1doku.php?id=$2&$3 last;
        rewrite ^(/)$ $1doku.php last;
    }
  }

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

  location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
    expires 30d;
  }

  location = /robots.txt  { access_log off; log_not_found off; }
  location = /favicon.ico { access_log off; log_not_found off; }
  location ~ /\.          { access_log off; log_not_found off; deny all; }
  location ~ ~$           { access_log off; log_not_found off; deny all; }

  location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  }

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

  location ~ /\.ht {
    deny  all;
  }
}

server {
    listen       80;
    server_name  www.example.com;
    return       301 http://example.com$request_uri;
}

评论

black vr porn, 2025/04/13 16:01

I every time used to study post in news papers but now as I am a user of internet so from now I am using net for articles or reviews, thanks to web.

black vr porn, 2025/04/13 16:01

I every time used to study post in news papers but now as I am a user of internet so from now I am using net for articles or reviews, thanks to web.

请输入您的评论. 可以使用维基语法:
 
wiki/linux/nginx-php-dokuwiki.txt · 最后更改: 2023/01/03 15:25 由 127.0.0.1