简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM