一聚教程网:一个值得你收藏的教程网站

热门教程

XAMPP创建域名虚拟目录(php+apache+mysql)

时间:2022-06-30 18:11:40 编辑:袖梨 来源:一聚教程网

XAMPP是一个可以快速创建网站所需环境(php+apache+mysql)软件,如果项目多的话,用127.0.0.1或者localhost访问比较麻烦而且不容易记忆,可以使用域名虚拟目录来达到快速访问,也可以很好的区分各个项目。

WordPress 和 discuz 来做列子,wordpress用wordpress.com来访问,discuz使用discuz.com来访问。

1.下载好源码放置于htdocs文件里面
- /htdocs
- /wordpress
- /discuz
2.打开本地hosts文件(C:/windows/system32/drivers/etc/),在最后添加下面代码:
127.0.0.1 wordpress.com
127.0.0.1 discuz.com
3.编辑XAMPP vhost文件(/xampp/apache/conf/extra/httpd-vhosts.conf)
删除NameVirtualHost *:80前的*号,并在最后添加
## 添加 127.0.0.1 规则,要不然 127.0.0.1 不能使用

 代码如下 复制代码

ServerAdmin webmaster@127.0.0.1.com
DocumentRoot “E:/xampp/htdocs/”
ServerName 127.0.0.1
ErrorLog “logs/127.0.0.1-error.log”
CustomLog “logs/127.0.0.1-access.log” common

## 添加 localhost 规则,要不然 localhost 不能使用

 代码如下 复制代码

ServerAdmin webmaster@localhost.com
DocumentRoot “E:/xampp/htdocs/”
ServerName localhost
ErrorLog “logs/localhost-error.log”
CustomLog “logs/localhost-access.log” common

## 添加 wordpress.com 规则,要不然 wordpress.com 不能使用
## DocumentRoot 为源码目录

 代码如下 复制代码

ServerAdmin webmaster@wordpress.com
DocumentRoot “E:/xampp/htdocs/wordpress”
ServerName www.111com.net
ErrorLog “logs/wordpress-error.log”
CustomLog “logs/wordpress-access.log” common

## 添加 discuz.com 规则,要不然 discuz.com 不能使用
## DocumentRoot 为源码目录

 代码如下 复制代码

ServerAdmin webmaster@discuz.com
DocumentRoot “E:/xampp/htdocs/discuz”
ServerName www.111com.net
ErrorLog “logs/discuz-error.log”
CustomLog “logs/discuz-access.log” common

4.重启apache后,众www.111com.net 

热门栏目