您的位置:首页 > 其它

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

2016-11-25 13:08 239 查看
我的版本是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,即可直接访问该项目了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐