zhaoJian's Tech Notes

Problems Encountered Configuring XAMPP for Multi-site with Local Domain Binding on MAC

Technology ~1538 words · 4 min read - views

I’ve always been running PHP environment in virtual machines. Today I wanted to install an environment on Mac to try, and finally chose XAMPP.

OK, here’s the problem - XAMPP doesn’t support multi-site, but I want to access different sites with multiple domain names. Searched online for a long time, all solutions were copy-pasted, I really don’t know how you configured after copying.

Let’s do it myself

Local environment:

OSX 10.13.1 XAMPP-VM (PHP 7.1.11)

Requirements:

XAMPP multi-site access with domain binding

First modify the config file httpd-vhosts.conf

vi /opt/lampp/etc/extra/httpd-vhosts.conf

Add configuration at the bottom of the file

<VirtualHost *:80>
ServerAdmin 757118@qq.com
DocumentRoot "/opt/lampp/htdocs/111.com"
ServerName 111.com
ErrorLog "logs/111.com-error_log"
CustomLog "logs/111.com-access_log" common
</VirtualHost>
# Where 111.com is the domain for local access this time
# To add more domains, copy the above code multiple times and modify the corresponding domain

Then press esc, type :wq and enter to save.

Next modify the config file httpd.conf

vi /opt/lampp/etc/httpd.conf

Change

# Virtual hosts
#Include etc/extra/httpd-vhosts.conf

To

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

Then restart Apache service

Modify local domain access, this time set 111.com as the local test domain

vi /etc/hosts

Add below

192.168.64.2 111.com

Done, enter domain 111.com to access local directory

Share:

Comments