xampp配置服务器

一、修改httpd.conf

文件目录 xampp => apach e=>httpd.conf
1.在文件内搜索 关键字“httpd-vhosts.conf”,找到如下字段

# Virtual hosts

Include conf/extra/httpd-vhosts.conf//确保此段开头没有#

2.在文件内搜索关键字“AllowOverride All”,找到如下字段

<Directory "D:/xampp/cgi-bin">

    AllowOverride All

    Options None

    Require all granted

</Directory>

//修改为

<Directory "D:/xampp/cgi-bin">

    Options Indexes FollowSymLinks Includes ExecCGI

    AllowOverride All

    Order allow,deny

    Allow from all

</Directory>

3.搜索字段“DocumentRoot”,如下

DocumentRoot "D:/xampp/htdocs"//确保此处路径是你要访问的项目的根路径

<Directory "D:/XAMPP/htdocs">//确保此处路径是你要访问的项目的根路径

4.如果想自定义配置端口,搜索字段“Listen 80”,找到如下

Listen 80

//在此添加你想监听的端口,如

Listen 80

Listen 8080

Listen 8099

....

二、修改httpd-vhosts.conf

文件目录 xampp => apache =>conf => extra => httpd-vhosts.conf

文件最后面可看到如下

##<VirtualHost *:80>

    ##ServerAdmin [email protected]

    ##DocumentRoot "D:/xampp/htdocs/dummy-host2.example.com"

    ##ServerName dummy-host2.example.com

    ##ErrorLog "logs/dummy-host2.example.com-error.log"

    ##CustomLog "logs/dummy-host2.example.com-access.log"

##</VirtualHost>

先配置一个根目录,可以用localhost 来访问的路径

<VirtualHost *:80>

DocumentRoot "D:/XAMPP/htdocs"

ServerName  www.myWeb.com//除了localhost外还可以访问的域名

</VirtualHost>

1.ip访问

<VirtualHost 127.0.0.1:80>//设置访问的ip

    ##ServerAdmin [email protected]

    DocumentRoot "D:/xampp/htdocs/project"//你的项目文件目录

    ServerName  www.myWeb.com//此项目的名称

    ##ErrorLog "logs/dummy-host2.example.com-error.log"

    ##CustomLog "logs/dummy-host2.example.com-access.log"

</VirtualHost>

2.ServerName访问

<VirtualHost *:80>

    ##ServerAdmin [email protected]

    DocumentRoot "D:/xampp/htdocs/project"//你的项目文件目录

    ServerName www.myWeb.com//此项目的名称,通过此名称来访问项目,还需配置hosts文件

    ##ErrorLog "logs/dummy-host2.example.com-error.log"

    ##CustomLog "logs/dummy-host2.example.com-access.log"

</VirtualHost>

3.配置hosts文件

文件目录 C:\Windows\System32\drivers\etc\hosts

在文件中加入

127.0.0.1   www.myWeb.com  

三、修改完记得重启aphache在进行访问

*域名不要带下划线等特殊符号

发布了97 篇原创文章 · 获赞 21 · 访问量 28万+

猜你喜欢

转载自blog.csdn.net/sun124608666/article/details/103378878