局域网下将自己电脑的wampserver配置成服务器

我的版本是WampServer Version 2.5,appach版本是2.4.9。
主要是修改appach中的http.conf文件
找到

<Directory "F:/wamp/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove  
    ***Require all granted***     
</Directory>

主要是最后的两个配置,require all granted,意思是允许所有请求访问资源,然后一定要记得关闭防火墙,一开始没关导致一直没反应。

然后顺便介绍一下如何配置虚拟域名访问本地项目,但是注意www文件下不一定就只有一个项目,这里是以test为项目,
1.首先在http.conf文件里找到Include conf/extra/httpd-vhosts.conf,把此项前的#号删去,
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2.修改..\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf路径的httpd-vhosts.con文件,找到

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "F:\wamp\www\test"
    ServerName test.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

DocumentRoot “F:\wamp\www”是指定用这个虚拟域名可以访问到本地的某个(www)文件夹下,可以再www后面再加项目名(如test),若在浏览器中中输入域名如test.com,直接访问到了test这个项目,但是仅仅局限于本地主机的访问,
Servername是域名,例如test.com,
3.修改C:\Windows\System32\drivers\etc\hosts这个路径下的hosts文件,将虚拟域名加入进去,在最后加入访问test.com即访问127.0.0.1

127.0.0.1       localhost
127.0.0.1       test.com

4.重启wamp,在浏览器输入test.com,即可直接访问该项目了。

猜你喜欢

转载自blog.csdn.net/pan_xi_yi/article/details/53333227