DEV Community

Cover image for πŸš€ How to Set Up a Virtual Host in XAMPP (C:) to Run WordPress from Another Drive (G:)
Pranto Mollick
Pranto Mollick

Posted on

πŸš€ How to Set Up a Virtual Host in XAMPP (C:) to Run WordPress from Another Drive (G:)

1. Install XAMPP(Already Installed)

Make sure Apache and MySQL modules are running from the XAMPP Control Panel.

2. Download/Edit WordPress on G:

Extract WordPress, say, to G:\wordpress.

3. Create a Database for WordPress

4. Set Permissions (if needed)

Make sure your user account has read/write permissions for G:\wordpress.

5. Configure Apache Virtual Hosts

a. Edit httpd-vhosts.conf:

  • Open C:\xampp\apache\conf\extra\httpd-vhosts.conf with a text editor (running as Administrator).
  • Add a block like this at the end:
<VirtualHost *:80>
    ServerName gamestore-dev.local
    ServerAlias gamestore-dev.local
    DocumentRoot "G:/wordpress"
    <Directory "G:/wordpress">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Replace mywordpress.local with your desired local domain.

b. Ensure mod_vhost and mod_rewrite are Enabled

  • In C:\xampp\apache\conf\httpd.conf, make sure these lines are uncommented (no #):


Include "conf/extra/httpd-vhosts.conf"
LoadModule rewrite_module modules/mod_rewrite.so
Enter fullscreen mode Exit fullscreen mode

6. Edit Your hosts File

  • Open Notepad as Administrator.
  • File > Open: C:\Windows\System32\drivers\etc\hosts
  • Add this line at the end:
    127.0.0.1   mywordpress.local
Enter fullscreen mode Exit fullscreen mode

7. Restart Apache

  • In the XAMPP Control Panel, stop and start Apache.

8. Install WordPress

  • Visit http://mywordpress.local in your browser.
  • Run the installation wizard.
  • Enter your database info: > - Database Name: wordpress_db > - Username: root > - Password: (leave blank unless you set one)

9. Test

  • You should see the WordPress setup page from G:\wordpress.
  • Log in to your WordPress site as normal.

Tip:
For multiple projects, just replicate the block with different folders and domain names.

Top comments (0)