Apache的域名配置

apache 基本简介: Apache HTTP Server(简称Apache)是一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。本章介绍apache在Windows上安装以及其增加域名的用法:
 

Apache站点域名配置    

1、目录:C:\Windows\System32\drivers\etc\hosts   (这个目录一般都是一样的)

#   127.0.0.1       localhost

#   ::1             localhost

127.0.0.1           localhost               (这个是保证localhost下也能访问)

127.0.0.1        www.test.com    (域名设置)

2、目录:D:\wamp\bin\apache\apache2.4.9\conf\httpd.conf   (此目录根据自己的实际项目查询)

开启以下3个模块:

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Include conf/extra/httpd-vhosts.conf

3、目录:D:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf  (此目录根据自己的实际项目查询)

AH00526: Syntax error on line 59 of D:/Phpstudy/Apache/conf/extra/httpd-vhosts.conf:
Invalid command '\xc2\xa0', perhaps misspelled or defined by a module not included in the server configuration

(若为上面报错,尝试去除所有前面的空格,网页复制空格可能会被报错(踩过的坑))

 

<VirtualHost *:80>              #(注意:此处端口一般是80,根据自己apache的实际端口填写)

    DocumentRoot "D:/wamp/www/test"                #(此目录根据自己的实际项目路径填写)
    DirectoryIndex test.php                                     # (此为默认打开的文件)

    ServerName  www.test.com                             #  (需要增加的域名)

    ServerAlias   test.com

  <Directory "D:/wamp/www/test">

      Options FollowSymLinks ExecCGI

      AllowOverride All

      Order allow,deny

      Allow from all

      Require all granted

  </Directory>

</VirtualHost>

以上配置好了,在浏览器地址处输入www.test.com,就可以访问你的项目啦(若无法打开,关闭浏览器重新打开)

(注:localhost无效,则重新赋值域名)

<VirtualHost *:80>
  DocumentRoot "D:\Phpstudy\WWW"
  ServerName  localhost
  ServerAlias localhost
  <Directory "D:\Phpstudy\WWW">
    Options FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
   Require all granted
  </Directory>
</VirtualHost>

 

Apache站点端口配置

Listen 9093                            #(监听的端口)
<VirtualHost *:9093>
     DocumentRoot D:/website/dapei                      #(项目地址)
     DirectoryIndex index.php                                 # (默认打开的文件)

  <Directory "D:/website/dapei">                            # (项目地址)

    AllowOverride all
   Require all granted
  </Directory>
</VirtualHost>

 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值