如何重命名 MAMP Web 服务器?
有什么方法可以将我的 MAMP 服务器地址从 localhost 更改为其他地址,或者我是否坚持使用 localhost 作为名称?
Is there any way to change my MAMP server address from localhost to anything else, or am I stuck with localhost as the name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,你可以,但我会保留本地主机并添加其他虚拟主机。
在您的 C:\wamp\bin\apache\apache2.2.6\conf\httpd.conf 中 - 向下滚动到底部并找到取消注释“包括conf/extra/httpd-vhosts.conf”
转到文件夹:C:\wamp\bin\apache\apache2.2.6\conf\extra\ 并编辑 httpd-vhosts.conf
您可以在其他虚拟主机中添加以下内容:
记住重新启动 apache!
然后进入 C:\WINDOWS\system32\drivers\etc 并编辑 hosts
追加到列表末尾:127.0.0.1 project_name
Yes you can altho I would keep localhost and add other virtual hosts instead.
In your C:\wamp\bin\apache\apache2.2.6\conf\httpd.conf - scroll down to the bottom and locate uncomment "Include conf/extra/httpd-vhosts.conf"
go to folder: C:\wamp\bin\apache\apache2.2.6\conf\extra\ and edit httpd-vhosts.conf
where you can add in other virtual hosts something along the lines of:
Remember to restart apache!
Then go into C:\WINDOWS\system32\drivers\etc and edit hosts
Append to the end of the list: 127.0.0.1 project_name
localhost
是解析为本地计算机的主机名。如果您在本地计算机上运行网络服务器,
localhost
将解析为该服务。在任何其他计算机上,
localhost
不会解析到您的网络服务器,而是解析到该特定计算机。如果您想添加另一个解析到本地计算机的主机名,您可以编辑
hosts
文件 并添加 IP 地址127.0.0.1
的条目。请注意,这也仅适用于您的本地计算机。
localhost
is a hostname that resolves to your local computer.If you're running a webserver on your local computer,
localhost
will resolve to that service.On any other computer,
localhost
will not resolve to your webserver, but to that specific computer.If you want to add another hostname that resolves to your local computer, you can edit the
hosts
file and add an entry for the IP address127.0.0.1
.Note that that will also only work on your local computer.
通过查看您问题中使用的词语,我感觉您对 dns 和 virutalhost 没有太多经验,因此您可能需要先查看一些文档(基础知识请参阅维基百科)。
我会用这些术语重新表述您的问题(如果我错了,请毫不犹豫地阻止我):
我想使用一些自定义 dns 将一些虚拟主机添加到我的 MAMP 服务器,以便我可以使用自定义 dns 访问它。
必须有解决方案。如果您使用专业版,您应该能够添加具有您想要的 dns 的虚拟主机,以直接从 GUI 替换虚拟主机(参见 . 官方网页)。
如果您使用的是“普通”版本,我认为您可以通过手动编辑配置文件来执行相同的操作,但您必须知道自己在做什么。
MAMP 基于 Apache,因此语法应该与 Apache 配置文件几乎相同(您可以在互联网上找到许多教程:例如 此处),但它可能会与您的 GUI 产生冲突)。
由于您使用的是 MAMP,因此您应该使用 Mac。您可能应该编辑 /etc/hosts 来添加您的 dns,但您将需要额外的操作来确保 Mac Os X 正确地重新加载其缓存以进行名称解析,具体取决于您的操作系统版本,例如:
在 google 中查找“Mac Os X 重新加载 /etc/hosts”并尝试...
By looking at the words used in your question, I have the feeling that you have not much experience with dns and virutalhost so you may have to look at some documentation first (see Wikipedia for the basis).
I would reformulate your question in these terms (do not hesitate to stop me if I am wrong) :
I would like to add some virtual hosts to my MAMP server with some custom dns so that I could access it with a custom dns.
There must be solutions for that. If you use the pro version, you should be able to add a virtualhost with the dns that you want in replacement of virtualhost directly from the GUI (cf . the official webpage).
If you are using the "normal" version, I think you can do the same by manually editing the configuration files but you have to know what you are doing.
MAMP is based on Apache so the syntax should be nearly the same as Apache config files (and you can find many tutorials on the internet : for example here) but it is likely to create conflicts with your GUI).
Since you are using MAMP, you should be on a mac. You should have probably to edit /etc/hosts to add your dns but you will need an additional manipulation to ensure that Mac Os X properly reload its cache for name resolving depending on your version of the OS like :
Look in google for "Mac Os X reloading /etc/hosts" and try...