I have a Laravel site that I've setup in /var/www/html/
. I have also setup a vhost for this site as I want to have a custom url( example.dev ) rather than localhost
.
This is how I setup my vhost:
<VirtualHost *:80>
ServerName example.dev
ServerAlias http://example.dev
DocumentRoot /var/www/html/example/public/
<Directory /var/www/html/example/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After doing this I disable the default .conf by running sudo a2dissite 000-default.conf
and then I enable the .conf I created( sudo a2ensite example.dev.conf
). After all this I restarted apache and reloaded the configurations.
From there on I went to add my server name to my host file like this:
127.0.0.1 localhost example.dev
127.0.1.1 tangaye
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Now when I try to access my site in the browser my typing example.dev
I get:
This site cannot be reached. example.dev refuse to connect.
But when I do localhost
my site is launch. Why is this happening? Interestingly I have realized that when I curl -L example.dev
I get the full expected outcome of my site in the terminal. Why is me site being access in the terminal rather than the browser? Will appreciate any help. Thanks!
Firstly thanks to @Bekir for the heads up . I realized google has added .dev
as one of their Top Level Domiains(tld). Which means if one tries to use it locally one local machine should be able to:
As mentioned in the post there are two options: .localhost
or .test
. Both of these resolves to 127.0.0.1
.
I tried both and it worked perfectly for me. I also try .com
but it only work on opera and not on chrome .
On chrome I realize forces https
when I'm using example.com
or example.dev
, but everthing works fine across browsers when I switch to example.test
or example.localhost
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.