Great question π Setting up multiple WordPress sites in the same XAMPP is very useful if you want to test many projects. You can do this in two ways:
-
Simple way (different folders under
htdocs
) -
Professional way (virtual hosts with custom domain names like
site1.local
,site2.local
)
I’ll explain both.
✅ Method 1: Simple way (easiest)
-
Go to:
C:\xampp\htdocs\
-
Create a new folder for each WordPress project:
C:\xampp\htdocs\project1 C:\xampp\htdocs\project2
-
Copy the WordPress files into each folder.
-
Create a separate database for each project in phpMyAdmin:
-
wordpress_db1
for Project1 -
wordpress_db2
for Project2
-
-
Install each site by visiting in browser:
-
http://localhost/project1
-
http://localhost/project2
-
⚡ That’s it. Each WordPress site is independent.
✅ Method 2: Virtual Hosts (cleaner, looks like real websites)
This way, you can use custom local domains instead of localhost/project1
.
Step 1: Create project folders
Put your sites in htdocs
:
C:\xampp\htdocs\site1
C:\xampp\htdocs\site2
Step 2: Create databases
-
site1_db
for Site1 -
site2_db
for Site2
Step 3: Edit httpd-vhosts.conf
-
Open this file in Notepad (as Admin):
C:\xampp\apache\conf\extra\httpd-vhosts.conf
-
Add entries for each site:
<VirtualHost *:80> ServerName site1.local DocumentRoot "C:/xampp/htdocs/site1" <Directory "C:/xampp/htdocs/site1"> AllowOverride All Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName site2.local DocumentRoot "C:/xampp/htdocs/site2" <Directory "C:/xampp/htdocs/site2"> AllowOverride All Require all granted </Directory> </VirtualHost>
Step 4: Edit hosts
file
-
Open (as Admin):
C:\Windows\System32\drivers\etc\hosts
-
Add:
127.0.0.1 site1.local 127.0.0.1 site2.local
Step 5: Restart Apache
-
Open XAMPP Control Panel → restart Apache.
Step 6: Install WordPress
-
Visit:
-
http://site1.local → install WordPress into
site1_db
-
http://site2.local → install WordPress into
site2_db
-
Now you have multiple local sites running like real domains π
π Do you want me to write a step-by-step full config file example for 2 WordPress sites (site1.local
+ site2.local
), so you can copy-paste and run directly?
Perfect π I’ll give you a ready-to-use setup for 2 WordPress sites (site1.local
and site2.local
) inside XAMPP on Windows.
πΉ Step 1: Create Site Folders
Go to:
C:\xampp\htdocs\
Create:
C:\xampp\htdocs\site1
C:\xampp\htdocs\site2
Unzip WordPress into both folders.
πΉ Step 2: Create Databases
-
Create 2 databases:
-
site1_db
-
site2_db
-
πΉ Step 3: Configure Virtual Hosts
-
Open (with Notepad as Admin):
C:\xampp\apache\conf\extra\httpd-vhosts.conf
-
Add this code at the bottom:
# Site1 Configuration
<VirtualHost *:80>
ServerName site1.local
DocumentRoot "C:/xampp/htdocs/site1"
<Directory "C:/xampp/htdocs/site1">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# Site2 Configuration
<VirtualHost *:80>
ServerName site2.local
DocumentRoot "C:/xampp/htdocs/site2"
<Directory "C:/xampp/htdocs/site2">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
✅ Make sure the paths match your real folder names.
πΉ Step 4: Map Domains in hosts
File
-
Open (as Admin):
C:\Windows\System32\drivers\etc\hosts
-
Add at the end:
127.0.0.1 site1.local
127.0.0.1 site2.local
πΉ Step 5: Restart Apache
-
Open XAMPP Control Panel → Stop & Start Apache.
πΉ Step 6: Install WordPress
-
Visit:
-
http://site1.local → choose
site1_db
database, userroot
, no password. -
http://site2.local → choose
site2_db
.
-
Install each site normally → set username, password, and site title.
✅ Now you have two completely separate WordPress sites on your local system:
π Do you want me to also give you a template for adding more sites (site3, site4, etc.), so you can just copy-paste when needed?
No comments:
Post a Comment