gpt4 book ai didi

php - nginx-php 不适用于自己构建的 nginx

转载 作者:太空宇宙 更新时间:2023-11-04 03:52:36 26 4
gpt4 key购买 nike

我使用此配置命令编译了 NGINX:

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master

然后我做了make install来安装它,它已成功添加,但我无法执行PHP文件,当我尝试打开页面时它给我一个错误:((我已经安装了php-fpm)

这是我的 nginx.conf 文件:

#user  nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include 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 logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
#server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index 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 html;
}

location ~* \.php$ {
root html;
fastcgi_index index.php;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

rtmp {
server {
listen 1935;
chunk_size 4096;

application live {
live on;
record off;
}
}
}

这是错误日志输出:

2014/09/10 15:52:16 [notice] 22803#0: signal process started
2014/09/10 15:52:39 [notice] 22808#0: signal process started
2014/09/10 15:57:21 [notice] 22819#0: signal process started
2014/09/10 16:02:15 [error] 22891#0: *1 connect() failed (111: Connection refused) while c$
2014/09/10 16:03:36 [crit] 22947#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13$
2014/09/10 16:05:41 [crit] 23002#0: *2 connect() to unix:/var/run/php5-fpm.sock failed (13$
2014/09/10 16:06:26 [crit] 23057#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13$
2014/09/10 16:06:26 [crit] 23057#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13$
2014/09/10 16:06:27 [crit] 23057#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13$

看起来没有权限,但是如何给nginx正确的权限?

最佳答案

listen 指令出现臭名昭著的错误,它对于 nginx 和 php-fpm 必须相同。如果您在 nginx.conf 中使用套接字,则必须在 php-fpm 池配置中使用套接字(例如 debian 的/etc/php5/fpm/pool.d/www.conf)

nginx.conf(您已经设置了):

fastcgi_pass unix:/var/run/php5-fpm.sock;

php-fpm www.conf:

listen = /var/run/php5-fpm.sock

如果这些设置没有帮助,请尝试将listen.*设置为nginx的用户(例如debian的www-data)

php-fpm www.conf:

listen.owner = www-data
listen.group = www-data

关于php - nginx-php 不适用于自己构建的 nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25767700/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com