所以我有一个ubuntu服务器,我试图从备份中恢复。 而当一个虚拟的PHP版本页面,我得到502错误的网关。 我有什么试图解决它? 包括从这个相关的问题的答案 – Nginx 502坏的网关很多东西
server { listen 80; # listen [::]:81 ipv6only=on default_server; root /var/www/html; index index.PHP index.html index.htm; server_name localhost; location ~* .(js|css|png|jpg|jpeg|gif|ico|html)$ { expires max; } location / { try_files $uri $uri.PHP $uri.PHP/$args /index.PHP?q=$uri&$args $uri/ =404; index index.PHP index.html index.htm; rewrite ^(.*)$ /$1.PHP; } location /PHPmyadmin { index index.PHP; try_files $uri $uri/ =404; auth_basic "Admin Login"; auth_basic_user_file /etc/Nginx/pma_pass; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/Nginx/html; } location ~ .PHP$ { try_files $uri =404; 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 fastcgi_params; } location ~ /.ht { deny all; } }
编辑:这是我认为是日志的相关部分
2017/08/11 13:18:13 [error] 27759#0: *270 connect() Failed (111: Connection refused) while connecting to upstream,client: 66.61.18.112,server: domain.com,request: "GET /favicon.ico HTTP/1.1",upstream: "http://127.0.0.1:8080/favicon.ico",host: "[IP ADDRESS]",referrer: "http://[IP ADDRESS]/PHPmyadmin/index.PHP"
编辑2:
在Windows上持久,预先(阻止)Perl Web服务
在Nginx中使用HHVM fastcgi处理fastcgi_param
如何优雅地重新启动运行在Nginx后面的fcgi的django?
这是我运行ps aux | grep PHP-fpm时的结果 ps aux | grep PHP-fpm :
mre 21685 0.0 0.0 11756 932 pts/0 S+ 10:42 0:00 grep --color=auto PHP-fpm root 32721 0.0 1.0 269300 11168 ? Ss Aug11 0:30 PHP-fpm: master process (/etc/PHP5/fpm/PHP-fpm.conf) www-data 32724 0.0 0.4 269300 4540 ? S Aug11 0:00 PHP-fpm: pool www www-data 32725 0.0 0.4 269300 4540 ? S Aug11 0:00 PHP-fpm: pool www
编辑3:
[global] ; Pid file ; Note: the default prefix is /var ; Default Value: none pid = /var/run/PHP5-fpm.pid ; Error log file ; If it's set to "syslog",log is sent to syslogd instead of being written ; in a local file. ; Note: the default prefix is /var ; Default Value: log/PHP-fpm.log error_log = /var/log/PHP5-fpm.log ;;;;;;;;;;;;;;;;;;;; ; Pool DeFinitions ; ;;;;;;;;;;;;;;;;;;;; ; To configure the pools it is recommended to have one .conf file per ; pool in the following directory: include=/etc/PHP5/fpm/pool.d/*.conf
编辑4:
以下是我的www.conf中未注释的内容:
listen = 127.0.0.1:9000 listen.owner = www-data listen.group = www-data listen.mode = 0660 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 chdir = /
编辑5:
[error] 29393#0: *23 connect() Failed (111: Connection refused) while connecting to upstream,client: [Computer IP Address],server: [Subdomain.domain.com],upstream:"http://127.0.0.1:8080/favicon.ico",host: [Server IP],referrer: "http://[Server IP]/index.PHP"
为什么在图像的开始处有不需要的额外字节?
Apache – 如何获得REMOTE_USERvariables
为什么不能Nginx POST到我的Perl后端?
C语言的FastCGI与Nginx
如何用C ++中的FastCGI(Nginx)创build一个cookie
所以我检查了我的Nginx配置,发现这些行:
include /etc/Nginx/conf.d/*.conf; include /etc/Nginx/sites-enabled/*;
然后我去了/etc/Nginx/conf.d/*.conf ,看到在servers.conf文件中,有一个我计划使用的子域的配置,但不会再把它删除了。 这是问题的一个重要部分,因为Nginx首先查找这个配置,这就是为什么错误包含这个子域。
至于PHP的问题,我把我的配置切换到fastcgi_pass unix:/run/PHP/PHP7.0-fpm.sock; 而这似乎已经解决了这个问题。
尝试更换
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
在你的Nginx配置里
fastcgi_pass 127.0.0.1:9000;
因为如果你的PHP-FPM配置你使用TCP而不是套接字(没关系)。
你必须改变这一行
从:
listen = 127.0.0.1:9000
至:
listen = /var/run/PHP5-fpm.sock
在您的www.conf文件中
不要忘记重新启动PHP。
说明:
如果你看看你的Nginx虚拟主机fastcgi_pass参数
location ~ .PHP$ { try_files $uri =404; 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 fastcgi_params; }
你会看到你正在处理PHP文件到PHP5-fpm套接字,但在你的www.conf文件中PHP正在监听端口9000,这就是为什么你应该把它改为/var/run/PHP5-fpm.sock
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。