虚拟主机在Nginx Ubuntu 18.04中不起作用

时间:2019-08-28 11:46:50

标签: laravel ubuntu

最近我在我的电脑上设置了ubuntu 18.04。我试图在Nginx中创建一个虚拟主机。首先,我创建一个conf文件,名称为leave_application.conf。然后,我启用了此功能并在etc/hosts中写入主机。但是当我在浏览器中点击服务器名称时,它不起作用。错误日志为

  

PHP消息:PHP致命错误:require():需要打开失败   '/var/www/html/leave_application/public/../vendor/autoload.php'   (include_path ='。:/ usr / share / php')在   /var/www/html/leave_application/public/index.php,第24行“,而   从上游读取响应头,客户端:127.0.0.1,服务器:   Leave_application.ck,请求:“ GET / HTTP / 1.1”,上游:   “ fastcgi:// unix:/run/php/php7.2-fpm.sock:”,主持人:   “ www.leave_application.ck”

leave_application.conf

server {
        listen   80; 

    root /var/www/html/leave_application/public;
    index index.html index.htm index.php;

    server_name leave_application.ck www.leave_application.ck;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    autoindex on;
    autoindex_exact_size off;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }
}

主机

    127.0.0.1    localhost
    127.0.0.1    bs28
    127.0.0.1        www.leave_application.ck


    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

在浏览器中获取此输出

This page isn’t working www.leave_application.ck is currently unable to handle this request.
HTTP ERROR 500

1 个答案:

答案 0 :(得分:0)

该错误表明缺少vendor/autoload.php,可以通过运行以下命令来解决此问题:

composer install

要安装作曲家,可以使用以下指南: https://getcomposer.org/download/