我在本地Raspberry Pi盒子上安装了DnsMasq设置,以将本地设备映射到网络上的简单路径,例如laptop.local。我在笔记本电脑上使用WAMP进行本地Web开发,并且此设置工作得非常好,但是只是为了整理URL和出于教育目的,我如何将笔记本电脑上的子目录(当前为“ laptop.local / website”)映射到子域,例如“ website.laptop.local”
假设您为laptop.local正确设置了DNS ,则可能只需要更新WAMP配置即可使用适当的Apache虚拟主机。
配置WAMP
创建一个目录来容纳您的子域。确保在WAMP安装可以访问的位置(例如,根www
文件夹下或旁边)完成此操作。
打开Apache httpd.conf(位于WAMP安装中的Apacheconf
目录下,或通过适当的菜单界面,例如Apache → httpd.conf
)。
取消注释此行(删除#):
# Include conf/extra/httpd-vhosts.conf
然后应该变成
Include conf/extra/httpd-vhosts.conf
打开您的Apacheconf\extra
文件夹并查找httpd-vhosts.conf
。在文件末尾添加类似于以下内容的内容:
# Virtual host entry for website.laptop.local
# Anything with a # is a comment
<VirtualHost *:80>
ServerName website.laptop.local
#ServerAlias *.website.laptop.local
# DocumentRoot should correspond to wherever the HTML files
# for your website.laptop.local site are located. This is an example!
DocumentRoot "C:/wamp/www/subdomains/my-website"
ErrorLog "logs/my-website-error.log"
CustomLog "logs/my-website-access.log" common
# If you have any problems with "Forbidden", try uncommenting
# the following (assumes Apache 2.4.x).
#<Directory "C:/wamp/www/subdomains/my-website">
#AllowOverride None
#Options None
#Require all granted
#</Directory>
</VirtualHost>
确保启用您的alias_module和vhost_alias_module Apache模块。通常,这是(再次)通过适当的菜单界面完成的,例如Apache → Apache modules
,也可以httpd.conf
通过简单地取消注释适当的模块行来完成。
重新启动您的WAMP服务器。
假设没有错误,则应该可以使用website.laptop.local。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句