Apache Virtual Host IP Works but not ServerName - apache

I am using Wamp.
My Apache Server is running on port 90.
I Tried adding a virtual host by doing the following steps:
1)Removed the comment from the line Include conf/extra/httpd-vhosts.conf line in my Apache httpd.conf file.
2)I Added the following code to my C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin admin#laravel.dev
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
ErrorLog "logs/laravel.dev.log"
CustomLog "logs/dummy-laravel.dev.log" common
</VirtualHost>
<VirtualHost *:90>
DocumentRoot "c:/wamp/www/"
</VirtualHost>
3)I made changes to my windows hosts file.This is the content of my hosts file
127.0.0.1:90 localhost
127.0.0.1:90 laravel.dev
127.0.0.1:90 www.laravel.dev
Now localhost:90 will Redirect to my C:/wamp/www and 127.0.0.1:90 will Redirect to my C:/wamp/www/laravel/public but both laravel.dev and www.laravel.dev are not working
I get the message Oops! Google Chrome could not find laravel.dev in my chrome.
Any help would be appreciated :)

Related

Apache httpserver virtualhost not working

I have configured virtualhost in apache, conf contents below. (/etc/apache2/sites-available/myapp.xyz.conf). this is running on ubuntu 20.04.1
i have run "a2ensite myapp.xyz" successfully.
However, i cannot access myapp.xyz.net from browser. (We can’t connect to the server at myapp.xyz.net)
ping myapp.xyz.net in the machine works fine. but from external machine, it doesnt recognize myapp.xyz.net.
i have tried multiple suggestions but no luck.
I have updated /etc/hosts to include "127.0.0.1 myapp.xyz.net myapp.xyz.net" - no luck.
Tried changing <VirtualHost *:80> to <VirtualHost 127.0.0.1:80> and - no luck
Appreciate suggestions.
<VirtualHost *:80>
ServerName myapp.xyz.net
ServerAlias myapp.xyz.net
LogLevel warn
ErrorLog /var/log/apache2/myappconsoleError.log
CustomLog /var/log/apache2/myappAccess.log combined
ProxyPass / http://myapp.xyz.net:8069/
ProxyPassReverse / http://myapp.xyz.net:8069/
</VirtualHost>
Update:
I can access the page if i use http://1.2.3.4 . (1.2.3.4 is machine ip address).
What should my virtualhost config look like to access it by servername (i.e myapp.xyz.net)

Using a hostname on Apache rather than an IP

I am wanting to run a hostname on apache (on xampp) and I have changed the httpd.conf file so that ServerName example.com.
I then changed httpd-vhosts.conf so that
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "C:/xampp/htdocs/example"
ServerName example.com
ErrorLog "logs/example.com.log"
CustomLog "logs/example.com.log" common
</VirtualHost>
and then added 127.0.0.1 example.com to the hosts file in the System32->drivers->etc folder.
It works on the computer running xampp (I think because that has the altered hosts file) but it will not work from other computers on the same network, which I gather is supposed to be handled by the virtual hosts file.

virtual Host not being configured

I have cofigured httpd-vhosts.conf as
<VirtualHost *:80>
ServerAdmin webmaster#repos
DocumentRoot "C:\Users\Naveed-Laptop\repos\ustainable"
ServerName ustainable
ErrorLog "logs/ustainable-error.log"
CustomLog "logs/ustainable-acess.log" common
</VirtualHost>
Configured my hosts file
127.0.0.1 ustainable
but when i go to google chrome search and search for
[http://ustainable]
it says
Oops! Google Chrome could not connect to ustainable
Suggestions:
Search on Google:
it was creating issue due to hotspot sheild and ErrorLog, CustomLog; i am using xampp 1.8
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs"
ServerName xampp.local
ServerAlias www.xampp.local
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs\domain\html"
ServerName domain.local.com
ServerAlias www.domain.local.com
after adding it at the end of your httpd-vhosts.conf file restart your xampp and also add following lines to your hosts file available at C:\Windows\System32\Drivers\etc\hosts
127.0.0.1 domain.local.com
127.0.0.1 xampp.local
it will work for xampp 1.8 for remaining xampp versions hope so

Apache: using vhosts

I've added a new entry to vhosts, d3test. When I go to d3test/ in Google Chrome, the page isn't found, Oops! Google Chrome could not find d3test.
All of my other entries work fine, for example graphgram/ shows the correct site.
Here is my vhosts:
#
# Use name-based virtual hosting.
#
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot /Users/donald/Projects/graphgram
ServerName graphgram
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot /Users/donald/Projects/lookgram
ServerName lookgram
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot /Users/donald/Projects/d3test
ServerName d3test
</VirtualHost>
Why would all entries work except the last one?
have you added that entry to /etc/hosts aswell? just in case make sure. And restart your service after that.. should work, check what the log says...

VIrtualHost: Different hosts point to the same location

I am trying to set virtual hosts for two Zend Framework applications. I started by changing the system32 hosts file.
It contains the following lines now:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 quickstart
After that, I proceeded with changing the httpd-vhosts.conf file. Its current content:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\ProjManer\public"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\quickstart\public"
ServerName quickstart
ServerAlias quickstart
ErrorLog "logs/quickstart-error.log"
CustomLog "logs/quickstart-access.log" combined
</VirtualHost>
If I don't add the virtual host with localhost first, I get a "Access forbidden 403 Error message".
The problem now is that both point to the same location, the localhost. How am I supposed to get the second virtual host working? I used the flushdns also.
You don't need the ServerAlias in them unless you want say quickstart2 to go to quickstart. In that case you will do ServerAlias quickstart2. You get access forbidden because your document root in your httpd.conf doesn't have an index.php or that virtualhost doesn't have an index.php and you have -Indexes set
Other than that the virtualhost and hosts file look fine. Try restarting your browser and restarting apache.