亲爱的
我尝试在 amazon ec2 上部署 wordpress,我在 nginx 和 php-fpm 上遇到了麻烦,提前感谢您的帮助。当 nginx 和 php-fpm 运行时,我收到以下错误。
[error] 16282#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,
但是如果我停止 php-fpm,改用“php-cgi -b 9000”,它就可以正常工作。我还有一个问题是如何调试 nginx 和 php-fpm 上的问题,即使我将日志级别设置为调试或信息,它也会向日志文件中抛出一些错误消息。期待您的回复。非常感谢。
以下是我的配置文件。
/etc/nginx/conf.d/默认.conf
server {
listen 80;
server_name 127.0.0.1;
root /usr/www/ROOT/wordpress;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|css|js|txt)$ {
# root /usr/www/ROOT/wordpress;
# expires 24h;
#}
location / {
# root /usr/www/ROOT/wordpress;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
# root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#location / {
# proxy_pass http://127.0.0.1:8080;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root /usr/www/ROOT/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /usr/www/ROOT/wordpress$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
/etc/php-fpm.d/www.conf 中的部分配置
; Start a new pool named 'www'.
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 127.0.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache
答案1
fastcgi_param
您正在包含文件之前定义额外的行fastcgi_params
。这意味着fastcgi_params
定义将覆盖您在此处定义的行。
因此,请include fastcgi_params
先行fastcgi_param
。