Is there any way to change my MAMP server address from localhost to anything else, or am I stuck with localhost as the name?
问题:
回答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 address 127.0.0.1
.
Note that that will also only work on your local computer.
回答2:
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:
<VirtualHost *:80>
ServerName project_name
DocumentRoot "C:/wamp/www/project_name/"
</VirtualHost>
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
回答3:
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 :
dscacheutil -flushcache
Look in google for "Mac Os X reloading /etc/hosts" and try...