zoukankan      html  css  js  c++  java
  • xampp虚拟主机的配置

    一、修改httpd.conf
     
    文件目录 xampp => apache =>conf => 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"//确保此处路径是你要访问的项目的根路径
    
    ps:可以配置特定的根路径,比如: DocumentRoot "D:/www"
    

     二、修改httpd-vhosts.conf

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

    文件最后面可看到如下

    ##<VirtualHost *:80>
        ##ServerAdmin webmaster@dummy-host2.example.com
        ##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" common
    ##</VirtualHost>
    

     1.用ip访问

    <VirtualHost 127.0.0.5:80>//设置访问的ip
        ##ServerAdmin webmaster@dummy-host2.example.com
        DocumentRoot "D:/www"//你的项目文件目录
        ServerName  testname.dev//此项目的名称
        ##ErrorLog "logs/dummy-host2.example.com-error.log"
        ##CustomLog "logs/dummy-host2.example.com-access.log" common
    </VirtualHost>
    

     2.用ServerName访问

    <VirtualHost *:80>
        ##ServerAdmin webmaster@dummy-host2.example.com
        DocumentRoot "D:/www"//你的项目文件目录
        ServerName testname.dev//此项目的名称,通过此名称来访问项目,还需配置hosts文件
        ##ErrorLog "logs/dummy-host2.example.com-error.log"
        ##CustomLog "logs/dummy-host2.example.com-access.log" common
    </VirtualHost>
    

     3.配置hosts文件

    文件目录 C:WindowsSystem32driversetchosts
    在文件中加入
    127.0.0.1   testname.dev 
    

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

     
  • 相关阅读:
    MAC Operation not permitted
    Failed to connect to raw.githubusercontent.com port 443
    Ubuntu adb 报错:no permissions (user in plugdev group; are your udev rules wrong?);
    mysql随机抽取数据
    git 初始创建项目
    VS Code 中的代码自动补全和自动导入包
    25个ssh命令行技巧
    KaTex语法说明
    聊聊OkHttp实现WebSocket细节,包括鉴权和长连接保活及其原理!
    面试官:“看你简历上写熟悉 Handler 机制,那聊聊 IdleHandler 吧?”
  • 原文地址:https://www.cnblogs.com/pcx105/p/6369520.html
Copyright © 2011-2022 走看看