@
@
@Richswitch2017-12-24 10:17:23
Nginx
@Richswitch, 2017-12-24 10:17:23

Why don't domains work in homestead?

Hey!
I decided to put homestead on my home PC under Linux - Elementary OS.
I installed everything, but I can't figure out why I can't connect to the project at "homestead.test" or "example.test".
But if I use the path http://192.168.10.10/test2/index.php- everything works.
My Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Documents/dev/server
      to: /home/vagrant/server

sites:
    - map: example.test
      to: /home/vagrant/server

databases:
    - homestead

Added hoststo addresses.
198.168.10.10   homestead.test
198.168.10.10   example.test

PS
Here is a file obtained on the VM, at /etc/nginx/sites-available/example.test. May be needed.
server {
    listen 80;
    listen 443 ssl http2;
    server_name .example.test;
    root "/home/vagrant/server";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.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/example.test-error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }

    ssl_certificate     /etc/nginx/ssl/example.test.crt;
    ssl_certificate_key /etc/nginx/ssl/example.test.key;
}

The question is, what is wrong with my Homestead.yaml? Or how to solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Vorotnev, 2017-12-31
@HeadOnFire

The folders directive maps the root folder with projects, which is mapped from the host to the virtual machine. In your case, this is ~/Documents/dev/server - you should have all projects in this folder. The sites
directive contains a specific project folder mapping, where each domain corresponds to a project folder in the root folder of all projects (see above), i.e. /home/vagrant/server/ project . The path from here will be used in the server config in the root directive.

folders:
    - map: ~/Documents/dev/server
      to: /home/vagrant/server

sites:
    - map: homestead.test
      to: /home/vagrant/server/homestead
    - map: example.test
      to: /home/vagrant/server/example

On your file system it should look like this:
~/Documents
   - dev
     - server (вот эту папку маунтим на виртуалку)
       - homestead (конкретный проект)
       - example (конкретный проект)

After that, don't forgethomestead up --provision

M
Maxim Fedorov, 2017-12-24
@Maksclub

where did the test2 folder come from?
Neither Homestead.yml nor nginx config have this folder in their paths...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question