gpt4 book ai didi

php - nginx - 无法打开主脚本

转载 作者:IT王子 更新时间:2023-10-28 23:56:55 26 4
gpt4 key购买 nike

我收到错误信息:

FastCGI 在 stderr 中发送:“无法打开主脚本:/home/messi/web/wordpress/index.php(没有这样的文件或目录)”,同时从上游读取响应 header ,客户端:xxx.xxx .xxx.xxx,服务器:www.domain.com,请求:“GET/HTTP/1.1”,上游:“fastcgi://unix:/var/run/php5-fpm.sock:”,主机:“www.域名.com

这是我的配置文件:

/etc/php5/fpm/php.ini

cgi.fix_pathinfo=0
doc_root =
user_dir =
....

/etc/php5/fpm/php-fpm.conf

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
include=/etc/php5/fpm/pool.d/*.conf

/etc/php5/fpm/pool.d/www.conf

[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
security.limit_extensions = .php .php3 .php4 .php5
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on

/etc/nginx/nginx.conf

user  nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
server_tokens off;
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/sites-enabled/*;
}

/etc/nginx/sites-enabled/wordpress

server {
listen 80;
server_name www.domain.com;
root /home/messi/web/wordpress;
error_log /var/log/nginx/err.wordpress.log;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

设置用户权限:

#adduser www-data messi
#chown -R www-data:www-data /home/messi/web
#chmod -R 664 /home/messi/web/wordpress

我该如何解决这个问题?谢谢

最佳答案

默认情况下,SELinux 在 CentOS/RHEL 7+ 上会导致此错误:(

要测试 SELinux 是否是您的问题之源,请这样做

setenforce 0

... 看看是否一切正常。如果解决了它,你可以关闭 SELinux(弱,你比那更好),或者你可以重新打开它

setenforce 1

...然后正确解决问题。

如果你这样做

tail -f /var/log/audit/audit.log

...您会看到 SELinux 问题。就我而言,它拒绝 PHP-FPM 访问 Web 文件。您可以运行以下指令来修复它:

setsebool -P httpd_can_network_connect_db 1
setsebool -P httpd_can_network_connect 1

这实际上并没有为我解决这个问题,但后来恢复 SELinux 上下文做到了

restorecon -R -v /var/www

希望对您有所帮助。

关于php - nginx - 无法打开主脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22090350/

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