I'm doing a Laravel project and I need to set up a virtual host example.dev
in my system. For that I've created a copy of 000-default.conf
and named it as example.dev.conf
and placed in /etc/apache2/sites-available
. The contents of the file is given below (comments removed):
<VirtualHost *:80>
<Directory /var/www/html/example/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName example.dev
ServerAlias www.example.dev
ServerAdmin [email protected]
DocumentRoot /var/www/html/example/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then I've enabled the site using a2ensite
command and disabled 000-default.conf
using a2dissite
command. Then it will open my project when I try localhost
(/var/www/html) in my browser and not example.dev
. The virtual host example.dev
always produce "The site can't be reached" error in browsers.
Any suggestions?
– Anoop S Apr 14 '18 at 12:29172.168.0.1 www.example.dev
(tried without www too).127.0.0.1 www.example.dev
instead? – Mojtaba Zali Apr 14 '18 at 12:39localhost
after that? – Anoop S Apr 14 '18 at 12:43.dev
. Last year Google bought.dev
,.foo
and some other domain extensions. Now the redirection tohttps://
of these is hard coded in some browsers. Few days ago I read here a nice answer about that, but I can't find it. The proposed duplication should be also helpful. – pa4080 Apr 14 '18 at 12:50dev
toexample.local
. It also produces same results. – Anoop S Apr 14 '18 at 13:01www.example.dev
, and then your web server will try to find a matching VirtualHost forwww.example.dev
. – Florian Diesch Apr 14 '18 at 13:01/etc/hosts
should be127.0.0.1 localhost example-dev.org www.example-dev.org
, etc... You can use and your LAN IP, but when the network interface is down it shouldn't work. Then useServerName example-dev.org
andServerAlias www.example-dev.org
. – pa4080 Apr 14 '18 at 13:18/etc/hosts
to:127.0.0.1 localhost example.local www.example.local
Now I can access both my localhost and the virtual host. Thank you for your support mate. :)
– Anoop S Apr 14 '18 at 13:39