Mac Os X. Virtual hosts - macos

I want to install few virtual hosts on my Mac OS 10.9.4, using apache 2.2.6. I already have one virtual host, it's working correct, but when I added 2nd host it redirects me to 1st.
/etc/apache2/users/alex.conf:
<Directory "/Users/alex/Sites/">
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster#example
DocumentRoot "/Users/alex/Sites/site1.loc"
ServerName site1.loc
ServerAlias site1.loc
<Directory "/Users/alex/Sites/site1.loc">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#example
DocumentRoot "/Users/alex/Sites/site2.loc"
ServerName site2.loc
ServerAlias site2.loc
<Directory "/Users/alex/Sites/site2.loc">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
/etc/hotst:
##
# 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
fe80::1%lo0 localhost
127.0.0.1 site1.loc
127.0.0.1 site2.loc
SITE1.loc works correct, but when I go to site2.loc it redirect to site1.loc. How can I fix this?
Thanks. Sorry for my English

Related

Virtualhost always redirect to localhost root directory on Mac

When I am trying to access watheeq.local it returns me to localhost root directory "/Users/abdelrahmanmuntaser/Sites" here exactly, i want to access my website which is located at "/Users/abdelrahmanmuntaser/Sites/watheeq/web", sorry I am newbie at macOS, do I missing something ?
This is my httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName watheeq.local
ServerAlias watheeq.local
DocumentRoot "/Users/abdelrahmanmuntaser/Sites/watheeq/web">
<Directory "/Users/abdelrahmanmuntaser/Sites/watheeq/web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
ErrorLog "/private/var/log/apache2/watheeq.local-error_log"
CustomLog "/private/var/log/apache2/watheeq.local-access_log" com$
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/abdelrahmanmuntaser/Sites/
</VirtualHost>
This is my hosts file
##
# 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 watheeq.local
127.0.0.1 wath.local
::1 wath.local
enter code here

My virtual host in xampp isn't working for laravel

i've set my virtual hosts in xampp for laravel
httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/shareitbaby.io/public"
ServerName www.shareitbaby.io
ServerAlias shareitbaby.io
<Directory "C:/xampp/htdocs/shareitbaby.io/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and my host file:
127.0.0.1 shareitbaby.io
::1 shareitbaby.io
and when i type shareitbaby.io it's not working

Vhost access error / wamp

I have a big problem with my vhost installation with my wamp server when i want to load my website, it display this :
"Forbidden
You don't have permission to access / on this server."
i have seen a lot of tutorials and i have try this, and it didn't work well :
in : C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName panierdesaison79
DocumentRoot c:/wamp64/www/panierdesaison79/
<Directory "c:/wamp64/www/panierdesaison79/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
require all granted
</Directory>
</VirtualHost>
#
In : C:\Windows\System32\drivers\etc\hosts
#blablabla
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 panierdesaison79
::1 panierdesaison79
How it couldn't work?

MAC OSX: Cannot run multiple local domains

i am trying to add another local domain to my mac osx:
No matter what i do when visiting say 'domainnumber2.dev' it always displays the first host in my list.
If i swop them around in my httpd-vhosts file then i get the domainnumber2.dev site.
How can i run multiple localhost site on my mac.
I have a simple set up as below:
<VirtualHost *:80>
ServerName mydomain.dev
ServerAlias mydomain.dev
DocumentRoot "/Users/UserName/Sites/mydomain/"
</VirtualHost>
<VirtualHost *:80>
ServerName mydomainTwo.dev
ServerAlias mydomainTwo.dev
DocumentRoot "/Users/UserName/Sites/mydomainTwo/"
</VirtualHost>
I have also had the more details set up adding the below for both
<Directory "/Users/UserName/Sites/mydomain/">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my hosts file i have:
##
# 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
fe80::1%lo0 localhost
127.0.0.1 mydomain.dev
127.0.0.1 mydomainTwo.dev
which ever VirtualHost is first is the site that is served up
I stumbled across this same problem...
In your httpd-vhosts.conf file (/private/etc/apache2/extra/httpd-vhosts.conf after showing hidden files) add the following for each domain...
<VirtualHost *:80>
ServerName mysubdomain.dev
CustomLog "/root/to/site/logs/mysubdomain.dev-access_log" combined
ErrorLog "/root/to/site/logs/mysubdomain.dev-error_log"
DocumentRoot "/root/to/site/mysubdomain.co.uk"
<Directory "/root/to/site/mysubdomain.co.uk">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Then restart apache. Everything else you have seems to be the same as my setup.
Make sure you have the correct permissions to be able to write the log files etc too.

After adding vhosts definiation xamppfiles/htdocs is invisible on http , but still accessible through https

I have vhost like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName local.testing.com
DocumentRoot "/Users/myname/Sites/myapp"
DirectoryIndex index.html
<Directory /Users/myname/Sites/myapp>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
hots files
127.0.0.1 localhost
127.0.0.1 local.testing.com
::1 localhost
after enabling this vhost , i am unable to access any of the sites under xampp/htdocs through http. But they are accessible through https
when I access localhost it shows directory listing for :"/Users/myname/Sites"
plz help me sort out this issue ,
thanks in advance
so the issue was that we need a virtual host for localhost e. g like this SOQ
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
ServerAlias localhost
ServerName localhost
</VirtualHost>

Resources