我使用Nginx创build了一个VPS,并试图显示php信息: <?php phpinfo(); ?> <?php phpinfo(); ?> 。
相反,浏览器要求我下载php文件,而且它也没有被parsing。
这只发生在位于/var/www/我的VPS网站上。 位于默认/usr/share/nginx/html (由浏览器通过ip访问)中的相同的php文件显示OK(并且显示在浏览器中,而不是要求下载)。
这是我的configuration文件:
virtual.conf
# # A virtual host using mix of IP-, name-, and port-based configuration # server { listen 80; # listen *:80; server_name website.com www.website.com; location / { root /var/www/website.com/public_html/; index index.php index.html index.htm; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/website.com/public_html/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
default.conf
# # The default server # server { listen 80; server_name 100.00.000.000; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
感谢大家!