我在配置 NGINX 虚拟主机时遇到了一个小问题。我让所有不存在的子域名都指向一个静态 HTML 文件,该文件已被提供服务。
我已删除该静态 HTML 文件,并将 GravCMS 添加到域。有一个来自 Git 的安装
root@vps:~# ls -la /var/www/html/blog/
total 259
drwxr-xr-x 16 peter www-data 30 Mar 7 23:18 .
drwxr-xr-x 6 www-data root 8 Mar 6 17:06 ..
-rwxr-xr-x 1 peter www-data 1002 Mar 6 17:02 .dependencies
-rwxr-xr-x 1 peter www-data 359 Mar 6 17:02 .editorconfig
drwxr-xr-x 8 peter www-data 13 Mar 6 17:02 .git
-rwxr-xr-x 1 peter www-data 539 Mar 6 17:02 .gitignore
-rwxr-xr-x 1 peter www-data 3034 Mar 6 17:02 .htaccess
-rwxr-xr-x 1 peter www-data 4791 Mar 6 17:02 .travis.yml
drwxr-xr-x 2 peter www-data 2 Oct 20 13:06 .well-known
-rwxr-xr-x 1 peter www-data 79258 Mar 6 17:02 CHANGELOG.md
-rwxr-xr-x 1 peter www-data 6389 Mar 6 17:02 CONTRIBUTING.md
-rwxr-xr-x 1 peter www-data 1071 Mar 6 17:02 LICENSE.txt
-rwxr-xr-x 1 peter www-data 15368 Mar 6 17:02 README.md
drwxr-xr-x 2 peter www-data 3 Mar 6 17:02 assets
drwxr-xr-x 2 peter www-data 3 Mar 6 17:02 backup
drwxr-xr-x 2 peter www-data 6 Mar 6 17:02 bin
drwxr-xr-x 5 peter www-data 6 Mar 6 17:56 cache
-rwxr-xr-x 1 peter www-data 302 Mar 6 17:02 codeception.yml
-rwxr-xr-x 1 peter www-data 1832 Mar 6 17:02 composer.json
-rwxr-xr-x 1 peter www-data 111475 Mar 6 17:02 composer.lock
drwxr-xr-x 2 peter www-data 3 Mar 6 17:02 images
-rwxr-xr-x 1 peter www-data 1545 Mar 6 17:02 index.php
drwxr-xr-x 2 peter www-data 3 Mar 6 17:02 logs
-rwxr-xr-x 1 peter www-data 197 Mar 6 17:02 robots.txt
drwxr-xr-x 9 peter www-data 11 Mar 6 17:02 system
drwxr-xr-x 7 peter www-data 11 Mar 6 17:02 tests
drwxr-xr-x 2 peter www-data 3 Mar 6 17:56 tmp
drwxr-xr-x 8 peter www-data 8 Mar 6 17:02 user
drwxr-xr-x 20 peter users 21 Mar 6 17:53 vendor
drwxr-xr-x 2 peter www-data 8 Mar 6 17:02 webserver-configs
这是一个 vhost 配置:
server {
listen 80;
index index.html index.php;
## Begin - Server Info
root /var/www/html/blog;
server_name pbocan.net;
## End - Server Info
access_log /var/log/nginx/blog.log;
## Begin - Index
# for subfolders, simply adjust:
# `location /subfolder {`
# and the rewrite to use `/subfolder/index.php`
location / {
try_files $uri $uri/ /index.php?_url=$uri&$query_string;
}
## End - Index
## Begin - Security
# deny all direct access for these folders
location ~* /(.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
# deny running scripts inside core system folders
location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny running scripts inside user folder
location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny access to specific files in the root folder
location ~ /(LICENSE.txt|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; }
## End - Security
## Begin - PHP
location ~ \.php$ {
# Choose either a socket or TCP/IP address
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
## End - PHP
}
然而,我得到的是不存在的 HTML 文件。我使用的是 NGINX 1.6.2