So, i have a little issue here, i installed XAMPP which uses Apache on a Ubuntu desktop Virtual machine(on vbox), i also created a Laravel project on it and it works fine when i access it from the same VM itself !
Accessing the home page from firefox ubuntu
however when i try to access it from my host windows machine it just access to the XAMPP home page like this :
access from chrome windows
now my ubuntu VM has its address set to 192.168.1.50 and my windows 192.168.1.8 !
i also added to the windows machine "etc" file the entry :
192.168.1.50 usthbcloud.com
and to my ubuntu machine:
127.0.0.1 usthbcloud.com
my httpd.conf file of the XAMPP includes the file : httpd-vhosts.conf
i modified the httpd-vhosts.conf to the following :
vhosts.conf
Any solutions ?..
You're Facing issues in windows. Try this
<VirtualHost *:80>
DocumentRoot "D:/XAMPP/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/XAMPP/htdocs/eduguru/public/"
ServerName eduguruacademy.com
</VirtualHost>
Try this in your httpd-vhosts.conf. Replace with your DocumentRoot & ServerName Accordingly. Then restart XAMPP
Related
I have a server running Ubuntu 20.04 and Apache 2 that I use as a webserver. I made a configuration of a virtual host to point to a Laravel application, as you can see in the configuration file below.
<VirtualHost laravel-8.test>
DocumentRoot /var/www/laravel-8/public
ServerName laravel-8.test
<Directory "/var/www/laravel-8/public">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
And everything works perfectly on the server, but when I try to access the address laravel-8.test from another machine on the network, it goes to the Apache page. I even added in the Ubuntu hosts file to inform the address.
127.0.0.1 laravel-8.test
And I did the same on the workstation (Windows 10 Pro), I added the line
192.168.0.112 laravel-8.test
What am I doing wrong? I have the necessary Apache modules for Laravel to work (rewrite)
change your v-host config to something like this...
<VirtualHost *:80>
DocumentRoot /var/www/laravel-8/public
ServerName laravel-8.test
<Directory "/var/www/laravel-8/public">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
If you want to connect from another PC, you need to write an external IP.
may I ask question about the Apache Virtual Host config?
I use XAMPP, and my ipv4 is 192.168.1.7
I have configured my host file (C:\Windows\System32\drivers\etc...) like
127.0.0.1 g4.org
192.168.1.7 g4.org
and C:\xampp\apache\conf\extra\httpd-vhosts.conf like
NameVirtualHost 192.168.1.7:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/rs"
ServerName g4.org
ServerAlias www.g4.org
</VirtualHost>
The virtualhost works perfectly on the machine that has installed xampp .
but the problem is in the another machine(PC) [SAME LAN] if i go to http://192.168.1.7 the page load and work perfectly
but
if i go to this link http://g4.org the page won't load and say
ERR_CONNECTION_REFUSED
In the another machine, just put the "192.168.1.7 g4.org" at the host file.
I have following config in extra\httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/history"
ServerName history.test.in
<Directory "C:/xampp/htdocs/history">
Options All
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
Also, I enabled this in apache\conf\httpd.conf file,
Include conf/extra/httpd-vhosts.conf
In drivers\etc\hosts file, I have
127.0.0.1 localhost
127.0.0.1 history.test.in
When I try to access http://history.test.in, site is not loading but when tried with http://localhost/history, it works. Am I doing anything wrong? Also, I don't see any error logs in Apache.
The above configuration is correct. The reason for the virtual host not working was due to incorrect settings like firewall block, anti-virus software interruption, multiple OS environment etc. in system.
This post(eye-opener) helped me found the issue in windows xampp environment: https://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot
especially ipconfig /displaydns DNS command helped me find that new hosts take effect correctly.
Additionally, if you are running multiple versions of OS (windows 7, vista or windows 10) in your system, make sure you edit the running drivers\etc\hosts OS's hosts file and not the idle one.
I have installed vagrant and scotchbox from scotch.io to develop locally and is running like a charm.
Now I need use the subdomains as variable, and i have googled about, but still no working.
I have changed the hosts file and added
192.168.33.10 scotch.box
Is needed add a line for wildcard subdomain hosts?
Also I have added the next line to my conf file
<VirtualHost *:80>
DocumentRoot /var/www/public
ServerName tenant.scotch.box
ServerAlias *.scotch.box
</VirtualHost>
Sorry for my broken english.
Just add
192.168.33.10 tenant.scotch.box
to hosts.
I had the same problem a couple of months ago. On the hosting OS you have to edit the hosts file.
On Windows
C:\Windows\System32\drivers\etc\hosts
On linux
sudo nano /etc/hosts
you have then to add the ip-address of your scotch box with the desired host name
192.168.33.10 tenant.scotch.box
You can even add multiple lines to your hosts file if you have multiple subdomains or you are developing multiple web applications on the same scotch box. For example :
192.168.33.10 sub1.scotch.box
192.168.33.10 sub2.scotch.box
192.168.33.10 sub3.scotch.box
BUT don't forget to edit the virtual host file inside Scotch Box which is located /etc/apache2/sites-available/YOUR_CONFIG.conf
You will need a <VirtualHost *:80> </VirtualHost> for each sub domain. Example:
<VirtualHost *:80>
DocumentRoot /var/www/public
ServerName sub1.scotch.box
ServerAlias *.scotch.box
</VirtualHost>
I set up XAMPP running apache and tried to set up the virtual host, but it wouldn't work, I keep getting routed to the XAMPP splash page. http://localhost/index.html says "It works!"
I uncommented the are where it said vhost_alias module, httpd-vhosts and rewrite_module.
I also added the following to my httpd-vhosts.conf & httpd.conf files:
<Directory "C:/Sites/test.dev-web">
Allow From All
AllowOverride FileInfo
Options +FollowSymLinks
</Directory>
<VirtualHost *:80>
ServerName "test.dev-web"
DocumentRoot "C:/Sites/test.dev-web"
</VirtualHost>
I also added this to my hosts file in my system32\drivers\etc:
127.0.0.1 test.dev
I also have 127.0.0.1 localhost in that file
However whenever I type in test.dev in chrome, it takes me to the xampp splash page (test.dev/xampp).
Running windows 7 and XAMPP 1.7.4
XAMPP says that apache is running on the control panel.
I shut off all programs that could be running port 80 (skype)
Any ideas on what's wrong?
Follow the step mentioned here -
http://foundationphp.com/tutorials/apache22_vhosts.php
Easy solution: Delete XAMPP's local test site (xampp/htdocs) and replace it with your own site.
The Correct solution: Set up proper virtual hosts. Set up multiple virtual hosts on windows
or the link that Vinay shared will give you a good guide.