运行命令:
sudo apt-get install nginx
编辑 /etc/nginx/nginx.conf 文件,把 server_tokens off 前的注释删除,防止暴露 nginx 和服务器的版本号
运行命令:
sudo apt-get install php php-xml
sudo chown -R www-data:www-data /var/www/dokuwiki
在 /etc/nginx/sites-available 目录下增加一个文件名叫 dokuwiki
sudo vi /etc/nginx/sites-available/dokuwiki
内容如下:(也可参考官方说明 https://www.dokuwiki.org/install:nginx)
server { listen 80; server_name _; # Maximum file upload size is 4MB client_max_body_size 4M; client_body_buffer_size 128k; root /var/www/dokuwiki; index index.php; # 安装结束后,启用下面这句配置,防止重新安装。 #location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include snippets/fastcgi-php.conf; # With php7.0-cgi alone: #fastcgi_pass 127.0.0.1:9000; # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
启用该站点配置,在sites-enabled目录下创建一个软链接:
sudo ln -s /etc/nginx/sites-available/dokuwiki /etc/nginx/sites-enabled/
运行命令
sudo service nginx start
打开浏览器,输入 http://localhost/install.php , 按照页面提示步骤进行安装。
重新修改 /etc/nginx/sites-available/dokuwiki ,
把
# 安装结束后,启用下面这句配置,防止重新安装。 #location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; }
这句前的注释删除,然后重新加载 nginx
sudo service nginx reload