无法在Homestead VM上访问Symfony应用程序

时间:2017-09-02 16:02:03

标签: symfony vagrant homestead

我一直试图让一个Symfony应用程序在Homestead上运行。每次我尝试加载网站http://homestead.app时,我的浏览器都说“无法访问此网站”。我不确定为什么会这样。我遵循的过程是:

在我的Linux薄荷主机系统上创建一个Symfony应用程序:

  • mkdir ~/dev/sites/symfony
  • cd ~/dev/sites/symfony
  • symfony new my_project。这将创建Symfony应用程序:“〜/ dev / sites / symfony / my_project”
  • composer require --dev laravel/homestead
  • php vendor/bin/homestead make
  • 编辑Homestead配置文件vim Homestead.yaml
  • vagrant up

“Homestead.yaml”文件包含:

ip: 192.168.10.10
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: ~/dev/sites/symfony
        to: /home/vagrant/Code
sites:
    -
        map: homestead.app
        to: /home/vagrant/Code/my_project/web
        type: symfony
databases:
    - homestead
name: symfony
hostname: symfony

当我尝试通过Chrome浏览器访问该网站时,我收到了“无法访问该网站”。我检查了nginx配置,但对我来说没问题:

server {
    listen 80;
    listen 443 ssl http2;
    server_name homestead.app;
    root "/home/vagrant/Code/my_project/web";

    index index.html index.htm index.php app_dev.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /app_dev.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/homestead.app-ssl-error.log error;

    sendfile off;

    client_max_body_size 100m;

    # DEV
    location ~ ^/(app_dev|app_test|config)\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    # PROD
    location ~ ^/app\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        internal;
    }

    location ~ /\.ht {
        deny all;
    }

    ssl_certificate     /etc/nginx/ssl/homestead.app.crt;
    ssl_certificate_key /etc/nginx/ssl/homestead.app.key;
}

如果我尝试从主机系统ping homestead.app ping网站,它会将地址转换为192.168.10.10,但无法返回ping响应。这表明URL正确映射到IP地址。

我检查了主机和来宾系统的'/ etc / hosts'配置。在主机系统上有homestead.app的条目,该条目映射到192.168.10.10。我注意到在guest虚拟机系统中,hosts文件只映射homestead而不是'homestead.app'。我更新了hosts文件以包含两者。但是,这没有任何区别。

0 个答案:

没有答案