Virtual Host Configuration in XAMPP

Using virtual hosts is much easier for development systems than using the default alias “project” style. Having a URL such as http://example.dev/index.php instead of http://localhost/example/index.php is much clearer, works better with some website “extensions” involving paths and routing, and stored passwords are much easier to manage in browsers. Let’s face it, it’s just better all around. 馃檪

Follow these simple steps and you should be up and running with an easily duplicable configuration for XAMPP.

Install XAMPP & Configure Control Panel Specifics

Screen Shot of XAMP Control Panel
Add editable files here that you’ll be consistently working on when adding new domain name-based virtual hosts to your Apache configuration. Optionally, add the `hosts` file if you have the file permissions properly set so you can edit it.

Default installation should work fine. I’m running mine in Windows, so the control panel looks like this. It’s probably a good idea to add extra/httpd-vhosts.conf and extra/httpd-ssl.conf, since you’ll likely be opening those files.

Configure XAMPP

Generally, there are three (3) steps that you’ll do to configure initially, with two (2) files you’ll be constantly updating as you add new virtual domains. The line changes might be different than what’s shown here. It’s no biggie, though: Simply find the relevant line and make the necessary edits.

  • Activate Modules in httpd.conf

        LoadModule rewrite_module modules/mod_rewrite.so
        LoadModule log_config_module modules/mod_log_config.so
  • Activate Virtual Host Settings in httpd.conf

        #Listen 12.34.56.78:80Listen80<VirtualHost*:80>

    Comment out directory information:

        #DocumentRoot "E:/xampp/htdocs"
        #<Directory "E:/xampp/htdocs">
        ...

    Be sure to close the VirtualHost directive before the file includes:

        </VirtualHost>
    
        # Supplemental configuration
        #
        # The configuration files in the conf/extra/ directory can be 
        # included to add extra features or to modify the default configuration of 
        # the server, or you may simply copy their contents here and change as 
        # necessary.
    
        # Server-pool management (MPM specific)
        Include conf/extra/httpd-mpm.con
  • Configure Extra Virtual Hosts Configuration File

    After making the previous changes to Apache’s base-level conf file, you can work with the vhost extra conf file.

        <VirtualHost *:80>
            ServerAdmin webmaster@myexamplesite.dev
            DocumentRoot "C:\Users\JHaas\Documents\Projects\MyExampleSite"
            ServerName myexamplesite.dev
            ServerAlias myexamplesite.dev
            ErrorLog "logs/myexamplesite.dev-error.log"
            CustomLog "logs/myexamplesite.dev-access.log" common
    
            <Directory"C:\Users\JHaas\Documents\Projects\MyExampleSite">
                Options Indexes FollowSymLinks
            AllowOverride all
            Order Deny,Allow
            Deny from all
            Allow from 127.0.0.1
            </Directory>
    
            DirectoryIndex index.html index.php
        </VirtualHost>
  • Editing /etc/hosts

    Finally, you edit the /etc/hosts file. This file is helps your system bypass the need for a DNS query, allowing you to create your own TLD (top-level domain) suffix such as *.dev, or anything that isn’t going to collide with current new top-level domain suffixes (*.me used to be quite popular until that suffix itself became a TLD suffix).

    The localhost entry is not required, and from my experience has actually caused problems if uncommented, so leave it commented out if it is already. If you see that localhost is not commented out (depending on your platform), be sure to leave it so. Changing the localhost entry from default can cause issues for many network services if it’s changed. Note that chrome has an issue with using *.local, so it’s probably best to avoid using this TLD suffix.

        127.0.0.1   localhost
        127.0.0.1   myexamplesite.dev
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

哆哆女性网网游之少年绝色寓意好的词语可起名字美剧下载网站实况足球6装饰公司怎样起名字长津湖电影完整版女儿好听的郑姓 起名caoliuyahoo梦见悬崖起名建筑劳务公司名字4gifs.comqq飞车绝版手饰丑妃驾到五金店起名婴儿起名李免费给小孩男孩取起小名大全我是你额上熏黑的矿灯秋天的快乐作文cctv13新闻频道直播在线写给小女孩起个洋气小名账本起一个高雅的名字pier999金起头的公司名字挂机软件篮球世预赛你是我的城池营垒小说免费阅读同船爱歌孝心女孩名字起鋆起名字带鱼的淀粉肠小王子日销售额涨超10倍罗斯否认插足凯特王妃婚姻不负春光新的一天从800个哈欠开始有个姐真把千机伞做出来了国产伟哥去年销售近13亿充个话费竟沦为间接洗钱工具重庆警方辟谣“男子杀人焚尸”男子给前妻转账 现任妻子起诉要回春分繁花正当时呼北高速交通事故已致14人死亡杨洋拄拐现身医院月嫂回应掌掴婴儿是在赶虫子男孩疑遭霸凌 家长讨说法被踢出群因自嘲式简历走红的教授更新简介网友建议重庆地铁不准乘客携带菜筐清明节放假3天调休1天郑州一火锅店爆改成麻辣烫店19岁小伙救下5人后溺亡 多方发声两大学生合买彩票中奖一人不认账张家界的山上“长”满了韩国人?单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#青海通报栏杆断裂小学生跌落住进ICU代拍被何赛飞拿着魔杖追着打315晚会后胖东来又人满为患了当地回应沈阳致3死车祸车主疑毒驾武汉大学樱花即将进入盛花期张立群任西安交通大学校长为江西彩礼“减负”的“试婚人”网友洛杉矶偶遇贾玲倪萍分享减重40斤方法男孩8年未见母亲被告知被遗忘小米汽车超级工厂正式揭幕周杰伦一审败诉网易特朗普谈“凯特王妃P图照”考生莫言也上北大硕士复试名单了妈妈回应孩子在校撞护栏坠楼恒大被罚41.75亿到底怎么缴男子持台球杆殴打2名女店员被抓校方回应护栏损坏小学生课间坠楼外国人感慨凌晨的中国很安全火箭最近9战8胜1负王树国3次鞠躬告别西交大师生房客欠租失踪 房东直发愁萧美琴窜访捷克 外交部回应山西省委原副书记商黎光被逮捕阿根廷将发行1万与2万面值的纸币英国王室又一合照被质疑P图男子被猫抓伤后确诊“猫抓病”

哆哆女性网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化