使用xampp搭建运行php虚拟主机的详细步骤,xampp虚拟主机
最近,新装了xampp这么一个软件搭建自己的web开发环境,安装完毕自然要虚拟几个目录放自己的项目了,现将如何在xampp搭建的web服务器环境下新建虚拟主机的过程总结分享一下,大致过程分为三步,如下:
第一步: 用记事本打开C:/WINDOWS/system32/drivers/etc/hosts文件(win7 hosts文件位置:%systemroot%\system32\drivers\etc),
在127.0.0.1 localhost下面我添加了一个127.0.0.1 localhost.tuolarapp.com,这样以后每次在浏览器里输入localhost.tuolarapp.com,它就不再向网络DNS解析,而是直接解析到本地。所以事实上的localhost.tuolarapp.com你也访问不了了,当然你也可以自己设成 sohu.com如果你愿意的话。
第二步:因为我xampp是装在D盘的:用记事本打开D:/xampp/apache/conf/httpd.conf文件,我找到Include "conf/extra/httpd-vhosts.conf",确认前面没有加#.
第三步:D:/xampp/apache/conf/extra/httpd-vhosts.conf,在后面加上如下代码段:
<VirtualHost 127.0.0.1:80> DocumentRoot "D:/tuolarapp" ServerName "localhost.tuolarapp.com" </VirtualHost>
或者详细点如下:
<VirtualHost 127.0.0.1:80> DocumentRoot "D:/tuolarapp" ServerName "localhost.tuolarapp.com" <Directory "D:/tuolarapp"> Options Indexes FollowSymLinks ServerAlias 1.com *.2.com ErrorLog logs/www.eachbrand.com-error_log CustomLog logs/www.eachbrand.com-access_log common AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
然后保存,重启apache,这样我再浏览器输入localhost.tuolarapp.com时,会自动解析到D:/tuolarapp的目录里的网站。这样输入方便多了,关键自我感觉也会好些。
对以上的各个配置元素做如下说明:
ServerName:网站域名,同上,必须填写;
DocumentRoot:网站程序主目录,必须填写;
Options Indexes FollowSymLinks:显示目录列表,如果想要设置的安全点可将Indexes去掉,不显示目录列表,不是必须的;
Alias:能通过多个域名访问;
ErrorLog:错误日志文件存放位置;
CustomLog:访问日志文件存放位置;
ResinConfigServer:Resin服务器监听端口,我这里是本地为:127.0.0.1,如果有多台机器作为服务器,修改成对应IP地址即可;
以上就将虚拟主机的配置完成了,一个网站对应一个
这样就完成了xampp实现多网站的应用了。
如果想在其他端口下运行站点怎么办呢?
很简单:在“httpd.conf”主配置文件里面,设置多个端口,如Listen 8081
如何使用xampp搭建运行php的虚拟主机,我相信以后再遇到类似问题,一定不会难到大家了,希望大家会喜欢这篇文章。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.