phpstudy配置虚拟域名(Apache)

2018-03-08 14:49:41 PHP 阅读: 372

window下的phpstudy软件集成了php开发所需要的所有环境,对于php开发者来说,十分的方便。
但是默认情况下我们是使用localhost访问我们的设计的网站,那么怎么在本机上配置一个域名,方便我们访问呢。
apache

其实很简单,这里假设要配置的域名为test.com,分三个步骤:
(注意:这里是Apache服务器的配置方法)

修改系统hosts配置文件

文件位置: C:\Windows\System32\drivers\etc\hosts
文件内容:

    # Copyright (c) 1993-2009 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host

    # localhost name resolution is handled within DNS itself.
        127.0.0.1       localhost

我们只需要添加一行:

    127.0.0.1       test.com

修改apache配置文件

文件位置:..\phpStudy\PHPTutorial\Apache\conf\httpd.conf
搜索:

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

去掉前面的注释符号#即可

配置vhost.conf文件

找到:..\phpStudy\PHPTutorial\Apache\conf
增加配置如下:

<VirtualHost _default_:80>
  DocumentRoot "E:\htdocs\test.com"
  ServerName test.com
  <Directory "E:\htdocs\test.com">
    Options -Indexes +FollowSymLinks +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>

其中的E:\htdocs\test.com为网站位置,请自行修改。

版权声明:本文为博主原创文章,转载需注明来自: 洛洛の空间


功能
最新评论