XAMPP on MAC - change directory and virtual hosts to other volume - macos

I am trying to move my default htdocs folder from
/Applications/xamppfiles/htdocs/
to a folder on another partition at
/Volumes/Webserver/xampp/htdocs/
which happens to be the directory where XAMPP for Windows is installed, allowing me to use the same directory for my website project regardless whether I code on Windows or MAC.
(Note: I am using a Macbook Air with Bootcamp and ParagonNTFS, hence can read/write NTFS partitions)
I have successfully adjusted the httd.conf and vhost.conf files and managed to relocate the localhost directory to point to the files on the other volume, but I do NOT want to change the localhost directory, but rather create a new virtual host that points me to the other volume. So in short, I want these three domains
localhost -> /Applications/xamppfiles/htdocs/
site1.local -> /Volumes/Webserver/xampp/htdocs/project1/
site2.local -> /Volumes/Webserver/xampp/htdocs/project2/
The issue now is that when entering site1.local or site2.local into my browser, the browser redirects me to google because it cannot find the folders.
If I change the forward directory for localhost, things work fine.
localhost -> /Volumes/Webserver/campp/htdocs/project1/
Following config at play here:
httd.conf
DocumentRoot "/Volumes/Webserver/xampp/htdocs"
<Directory "/Volumes/Webserver/xampp/htdocs">
Include etc/extra/httpd-vhosts.conf
httpd-vhosts.conf
# Project1
<VirtualHost *:80>
ServerName site1.local
DocumentRoot "/Volumes/Webserver/xampp/htdocs/project1"
<Directory "/Volumes/Webserver/xampp/htdocs/project1">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site1.local-error_log"
</VirtualHost>
# Project2
<VirtualHost *:80>
ServerName site2.local
DocumentRoot "/Volumes/Webserver/xampp/htdocs/project2"
<Directory "/Volumes/Webserver/xampp/htdocs/project2">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site2.local-error_log"
</VirtualHost>
# localhost [must be included as the default named server]
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Volumes/Webserver/xampp/htdocs"
<Directory "/Volumes/Webserver/xampp/htdocs">
Require all granted
</Directory>
</VirtualHost>
I can access the localhost fine, but site1 and site2 dont work. If I change the documentroot of localhost, I can access fine though.
hosts
127.0.0.3 site2.local
127.0.0.2 site1.local
127.0.0.1 localhost
I tried assigning each site its own ip address, but without success.
Any help is much appreciated.

Had to restart about 10 times but now it seems the settings have taken effect. I can confirm the arrangement above works but requires a full restart in order to take effect.

Related

Virtual Host not working on Mac OS (MAMP)

OS: Mac OS
Mamp 6.6 version
The virtual host is not working, when I open the host I get an error:
Not Found
The requested URL was not found on this server.
looked at a lot of articles on topic of installing virtual hosts and it seems that I did everything right
My hosts file:
enter image description here
The virtual hosts file is included in configuration file /Applications/MAMP/conf/apache/httpd.conf:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
My httpd-vhost-conf:
NameVirtualHost *:80
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php"
<Directory "/Users/danilbondarev/Projects/php">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php/hybrid-main"
<Directory "/Users/danilbondarev/Projects/php/hybrid-main">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
Mamp->Preferences->Server->Document Root:
enter image description here
Error screen:
enter image description here
I want to note: I always restart apache and MAMP when I make any changes to the config files. I also tried to give directories permissions for Apache and it didn't help, although obviously this wasn't the problem
Tried these solutions:
Virtual hosts not working on MAMP
MAMP setting virtual host does not working

Laravel 5.2 site on localhost/Wamp

I am trying to learn Laravel.
I created a project on c:/sites where I develop all my sites. I called it larabasic.dev
I cannot open the site in my browser, it keeps switching to www.larabasic.dev and tells me server not found.
I set up a virtual host like I did to all my other sites that works well.
I tried:
1. Changing server.php to index.php and copied the public/htaccess file to the root folder
2. Going to http://larabasic.dev/public
3. Going to http://larabasic.dev/public/index.php
4. Changing vhosts file to:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev/public"
<directory "c:/sites/larabasic.dev/public">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
Instead of:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev"
<directory "c:/sites/larabasic.dev">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
My hosts file has these 2 entries:
127.0.0.1 larabasic.dev And
::1 larabasic.dev
Nothing helps. Again, any other sites I have developed with plain php work fine.
What am I missing?
Thank you
I've encountered the same problem and I've fixed this by giving 127.0.0.2 to my laravel application.
First, in the hosts file, you need to redirect larabasic.dev to 127.0.0.2:
127.0.0.2 larabasic.dev
Second, you need to bind the virtual host to that IP:
<VirtualHost 127.0.0.2:80>
DocumentRoot "C:/sites/larabasic.dev/public"
ServerAdmin admin#localhost
ServerName larabasic.dev
ServerAlias www.larabasic.dev
<Directory "C:/sites/larabasic.dev/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# if you want access from other pc's on your local network
#Require ip 192.168.1
# Only if you want the world to see your site
#Require all granted
</Directory>
</VirtualHost>
This is my working configuration on my local machine.

Virtual Hosts not working XAMPP 1.8.3

Im trying to set up a virtual host using my local xampp stack but after following many tutorials i simply can't work out where im going wrong.
Here is what i added to my httpd-vhost.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot E:\Programs\xampp\htdocs
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:\Programs\xampp\htdocs\CVCMS
ServerName cvcms.dev
<Directory "E:\Programs\xampp\htdocs\CVCMS">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my hosts file
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 cvcms.dev
I have restarted apache after every change, i have made sure http.conf is linked to the httpd-vhosts file.
The issue is when i type in the domain cvcms.dev it shows the xampp splash page instead of the index.php in my cvcms folder.
Any ideas why?
Thanks
please remember to add the quotes to your virtual host document root path. At the same time what you need to to do enable them is to find httpd.conf , in this version it should be in your etc folder within your XAMPP's root folder.
Look out for :
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
Since '#' is a comment prefix, you have to uncomment "#Include etc/extra/httpd-vhosts.conf"
See if this works. Remember to restart your XAMPP's apache server to read the new settings you've just set. Cheers !
You can read more on this here.

Setting up a virtual host on XAMPP on Mac

I am trying to set up a virtualhost on my apple mac on localhost. The server is provided by XAMPP, which bundles Apache/MySQL/PHP in one bundle.
Here is what I have done so far:
Edited /private/etc/hosts to include 127.0.0.1 to point to test.myserver.local
127.0.0.1 test.myserver.local
Edited /Applications/XAMPP/etc/extra/httpd-vhosts.conf to inlcude my vhosts details
<VirtualHost *:80>
DocumentRoot /Users/???/Documents/workspace/trunk/htdocs
ServerName test.myserver.local
<Directory "/Users/???/Documents/workspace/trunk/htdocs">
AllowOverride All
</Directory>
</VirtualHost>
Placed a simple index.html in there with the word test in it.
I have restarted the server, and then browse to the test url to be greeted with Apache's default page instead of my test page.
The vhosts file works for another virtual host, the code is copied with the respective bits changed (i.e. folder paths), the hosts file works, as when Apache is turned off, my browser says server not found.
Why is Apache refusing to show up my test code? Are there any other files I need to change? I cant think of any others, its usually just those on linux/windows.
On xampp you need to edit 3 files to setup virtual hosts
the /etc/hosts and /Applications/XAMPP/etc/extra/httpd-vhosts.conf as you did.
But also you need to edit /Applications/XAMPP/xamppfiles/etc/httpd.conf to include the http-vhosts.conf
make sure you have uncommented this line
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
EDIT
Have you tried to add this lines
Order allow,deny
Allow from all
Just before the
AllowOverride All
Try leaving the the setting for "localhost" at the end of the file "httpd-vhosts.conf",
i.e.:
#
# Virtual Hosts
#
...
# others vhost
<VirtualHost *:80>
...
</VirtualHost>
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
#end of httpd-vhosts.conf file
Worked for me, greetings!
Have you told Apache to actually use name-based virtual hosting?
# Use name-based virtual hosting.
#
NameVirtualHost *:80
I don't believe it's enabled by default in Xampp on Mac.

Wampserver can't get Named Virtual hosts to work

Using wampserver I can't get named virtual hosts to work. I've edited the httpd.conf to use the
Include conf/extra/httpd-vhosts.conf
I've added the domain to my system32/driver/etc/hosts file. I've edited the httpd-vhosts.conf file and everything seems to work except now localhost is unavailable. The domain I setup (test123.com) works fine, hitting 127.0.0.1 works fine, but hitting localhost hangs. There is nothing relevant in the error logs and no mention of it in the access logs. Here is how I have edited httpd-vhosts.conf:
#
# Virtual Hosts
#
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName test123.com
ServerAlias *.test123
# Folder where the files live
DocumentRoot "D:/Projects/html/test123"
# A few helpful settings...
<Directory "D:/Projects/html/test123">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
What am I doing wrong?
Finally figured it out. In httpd.conf I had to change
Listen 80
to
Listen *:80

Resources