代码之家  ›  专栏  ›  技术社区  ›  McRui

由于502网关错误,将/var/www/html/更改为/var/www/

  •  0
  • McRui  · 技术社区  · 7 年前

    我在Vagrant中遇到了php版本升级问题。这已经解决了,但我现在的问题是,以前的工作现在没有了,我想应该与本地项目所在的目录有关。

    我(像以前一样)在 /var/www/ 所有的 *.conf 中的文件 /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ 都是相同的,并且指向 /变量/www/ .

    这个 /etc/hosts 例如,文件保持指向之前的状态 192.168.56.102 awesome.devel .这起作用了,但已经不起作用了。

    如果我击中 192.168.56.102 在浏览器上 祝贺你真是太棒了。 位于中的页面 /var/www/html/

    我的问题是 ,在何处以及如何配置服务器以从中加载项目 /变量/www/ 而不是来自 /var/www/html/ 再说一遍,因为所有的项目都是 *.形态 中的文件 sites-available sites-enabled 已配置。

    快速提示:MariaDB运行良好,我可以从Sequel Pro访问数据库,我可以通过ssh访问vagrant,php运行良好 PHP 7.1.17-1+ubuntu14.04.1+deb.sury.org+1 这里没有问题。

    在我的。conf文件我有以下内容(只需更改项目名称):

    server {
        listen *:80;
    
        server_name awesome.devel www.awesome.devel;
        client_max_body_size 1m;
    
        root /var/www/awesome/public/;
        index  index.html index.htm index.php;
    
        access_log /var/log/nginx/nxv_awesome.access.log;
        error_log /var/log/nginx/nxv_awesome.error.log;
    
        index index.php index.html index.htm;
    
        # static file 404's aren't logged and expires header is set to maximum age
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log off;
            expires max;
        }
    
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }
    
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_intercept_errors on;
            fastcgi_pass   127.0.0.1:9000;
            try_files $uri $uri/ /index.php$is_args$args;
        }
    }
    

    提前感谢您的帮助

    1 回复  |  直到 7 年前
        1
  •  1
  •   tux    7 年前

    升级php版本后,php的配置文件发生了变化。旧的php fpm(版本5)正在通过tcp进行侦听,但升级后php fpm(版本7)正在unix套接字上进行侦听。

    但根据上面给出的nginx配置,nginx试图通过tcp连接到php fpm,但php7被配置为在unix套接字上监听。

    将php配置更改为通过tcp侦听将解决此问题。应将php7的www.conf中listen指令的配置更改为以下内容

    listen = 127.0.0.1:9000