I am trying to create a virtual host in apache2 running on VirtualBox guest OS is Ubuntu 14.04 LTS. The following is the configuration of my virtualhost in /etc/apache2/sites-available/mysite.lo.conf
<VirtualHost *:80>
Servername mysite.lo
ServerAlias www.mysite.lo
DocumentRoot /var/www/mysite.lo
</VirtualHost>
Settings in /etc/hosts
127.0.0.1 localhost
172.16.17.146 mysite.lo
When i try to run www.mysite.lo from my host browser, the browser responds no resuts found. When I type the ip address 172.16.17.146 then the browser successfully displays the content of mysite.lo. I would be grateful if someone can guide me on how to access the contents using the servername instead of ip adress. This is the link I have used as a guide to create my virtual host. Regards.
you should add www.mysite.lo to 172.16.17.146 line, or run mysite.lo without www. from host browser.
Related
I want to access my virtual hosts (websites) that I've set up in my VirtualBox -> Ubuntu-Server 18. I have apache2 installed and everything is setup.
The host machine (macOS) can presently gain access to the default website of apache2 in the guest (Ubuntu-server) through a Port Forwarding rule I have assigned in the VirtualBox Network Settings:
127.0.0.1:8000 -> 10.0.2.15:80
I've set up a virtual host in my guest machine with the following configuration:
<VirtualHost *:80>
ServerName dropn.taxi
ServerAdmin admin#dropn.taxi
DocumentRoot /var/www/dropn.taxi/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The DocumentRoot directory mentioned above exists and has the files necessary to serve a basic "Hello World" home page. I've tested it with my apache installed in my local machine as well. The website's not the problem.
But everytime I access localhost:8000 from the local machine, I'm greeted with an Ubnutu-Apache greetings page. Whereas when I try localhost:8000/dropn.taxi, I get a 404 page. I've researched quite a bit and the closest I can get to a solution is what is suggested in this page:
Ubuntu Apache2 local virtual hosts url not found
Simply put: How can I access virtual hosts of the guest machine (VM) from the host machine?
Still not specific to my case. Would appreciate any help in this regards.
localhost in the apache2 server is set to point to /var/www/html by default. For the virtual hosts to work properly, the domain name accessing them must be what is defined in the ServerName field.
localhost:8000/dropn.taxi would translate to 127.0.0.1/dropn.taxi in the VM guest. Which means, it is trying to access the /var/www/html/dropn.taxi, which, ultimately does not exist, hence the 404 error.
The solution to this is to add dropn.taxi to the /etc/hosts file in both the Host Machine and the VM. The line would look like:
127.0.0.1 localhost dropn.taxi
While accessing from the Host Machine, we use dropn.taxi:8000 in the browser whereas the port :8000 is not used in the guest machine. This way, whenever accessing the virtual hosts, the domain name accessing them matches the ServerName field and it simply works!
Created a new Laravel project in htdocs in MAMP. Followed all the steps, added virtual hosts, changed conf file, etc/hosts, restarted mamp and my pc several times but I just can't get my virtual host to run.
however, when I am in the MAMP Dashboard I can navigate to my website -> website -> public and the default Laravel boilerplate page appears.
Has anyone had this issues with MAMP before? I gave up with XAMPP and Valet so it's my last chance here..
Specs
High Sierra 10.13.5 on 2015 MBP,
Composer version 1.6.5,
php 7.2.7
httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd-vhosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Applications/MAMP/htdocs/website/public"
ServerName website.dev
</VirtualHost>
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
127.0.0.1 website.dev
website.dev is technically a public url, so the browser is looking for it on the internet I guess. I was trapped once in this dreadful situation. changing the name to something like website.local should solve your issue. It did for me.
I wanted to host one website in local Network.(it is not accessed by out side the network)
i install apache server.
how can i create own domain name for that(i don't want buy any domain name).
it is my virtual host file
ServerName testing.com
ServerAlias www.testing.com
DocumentRoot /var/www/testing.com/public_html
It works only when i put localhost as serverName
locahost file
127.0.0.1 somedomain.com
I'm working on an Ubuntu 12.04 server with Apache and I'm trying to setup 2 virtual host. The problem is I don't know how to setup the .conf files correctly so that I can hit both virtual host correctly from a remote machine...
For example if the Ubuntu sever has an address of 192.168.1.3, and I'm using another machine, how can I access each virtual host with http://192.168.1.3/host1 and http://192.168.1.3/host2?
right now in my /etc/apache2/sites-available folder I have the following 2 files
host1.conf
<VirtualHost *:80>
ServerName 192.168.1.3/host1
ServerAlias host1
DocumentRoot /var/www/host1/
.....
host2.conf
<VirtualHost *:80>
ServerName 192.168.1.3/host2
ServerAlias host2
DocumentRoot /var/www/host2/
.....
what is the correct configuration to make the virtual host work correctly when accessing from a remote machine?
The simplest way to achieve this is to assign host names to both your virtual hosts. E.g: host1.local.com & host2.local.com. Then in your remote machine, open /etc/hosts (you will require sudo privileges) and add the following lines:
192.168.1.3 host1.local.com
192.168.1.3 host2.local.com
Your virtual hosts config would be:
<VirtualHost *:80>
ServerName host1.local.com
I started getting this error for all my local virtual hosts on apache in the morning when I updated my Chrome to the latest version on ubuntu.
While all of them work on other browsers chrome started misbehaving with ERR_NAME_NOT_RESOLVED error.
Screen shot for the error
Got it fixed like this:
Clear up the Chrome's DNS cache by typing this in the Chrome browser
chrome://net-internals/#dns
Screenshot -> Flushing Chrome DNS cache
You will see a button "Clear Host Cache". Press that DNS cache
will be flushed.
Keep this DNS window open. Now access the virtual host in the browser
for me it was http:/api.localhost. Once you do that you will see a
new entry in the DNS window. for me it was "localhost."
notice the period "." at the end of localhost that showed an error.
Last step is to simply add this entry as
127.0.0.1 localhost.
in the hosts file located at
for ubuntu : /etc/hosts
for windows : C:\Windows\System32\drivers\etc\hosts
Another solution could be to ditch the .localhost /.dev at the end of your local virtual host domain
This has to do with some new changes by google. ".dev" and ".local" comes under google's TLD (In the corner of the internet where people care about DNS, there is a bit of an uproar at Google's application for over a hundred new top-level domains, including .dev etc)
Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help here on the setup.
Here is how to fix xampp virtual hosts in chrome and firefox that are ending with .dev. who doesn't work anymore (in most versions of chrome, since .dev is real domain registered and reserved from google - [Dev domain ICANN]).
I had so much trouble, with getting virtual hosts working properly
on both firefox and chrome, but at the end i find out that the best solution
is to make two different hosts for each local domain. So i ended up with something like: Here is hosts file in (C:\Windows\System32\drivers\etc\hosts):
This is needed, becouse if you still want your localhost alive
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
This works fine in Firefox.
127.0.0.1 laravel.dev
::1 laravel.dev
fe80::1%lo0 laravel.dev
This works perfectly on Chrome.
127.0.0.1 laravel.localhost
::1 laravel.localhost
fe80::1%lo0 laravel.localhost
And here is my xampp httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.localhost
</VirtualHost>
I hope this helps for someone, because i lost a couple hours, finding out the best solution, and make the things work. :)
tags - virtual host doesn't work on chrome.
Another option is to replace in your file /etc/hosts any entry defined as your_domain.localhost with something like local.your_domain. But this would also require you to change the "ServerName" and "ServerAlias" value in your virtual hosts files.
For me is working this:
In hosts:
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
And In httpd.conf:
<VirtualHost localhost>
DocumentRoot "D:/Apache/htdocs/projects/some-project-root"
ServerName some-project.localhost
</VirtualHost>
Important is write to VirtualHost tag "localhost", "127.0.0.1" does not works in chrome.