我在运行 CentOS 6.3 的 VPS 上安装了 nginx,但似乎无法让任何 PHP 文件运行。
这是我的 nginx.conf 文件:-
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
server_names_hash_bucket_size 128;
server {
server_name example.org www.example.org;
listen 198.245.51.xxx;
root /var/www/forum;
index index.html index.htm index.php;
access_log /var/log/virtualmin/example.org_access_log;
error_log /var/log/virtualmin/example.org_error_log;
include fastcgi_params;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /var/www/forum/$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /var/www/forum;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/forum/$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/forum;
include /etc/nginx/fastcgi_params;
}
ssl_certificate /home/example/ssl.cert;
ssl_certificate_key /home/example/ssl.key;
fastcgi_read_timeout 60;
autoindex on;
}
}
每当我尝试打开 www.mydomain.com/index.php 或任何其他 php 文件时,我都会收到以下消息:-
https://i.stack.imgur.com/J6y7k.png
提前致谢!如果我可以发布其他内容,请告诉我。
答案1
更改 domain.conf 文件中的用户和组后,它又开始工作了。默认情况下,它设置为用户:Apache 和组:Apache。
希望这能帮助将来遇到同样问题的人!谢谢大家的回答 :)