Search code examples
apachemampslim

Changing ServerName for MAMP


I'm trying to change the ServerName property for my MAMP instance but it doesn't seem to be responding to anything I do.

I edited part of the httpd.conf file (/Applications/MAMP/conf/apache/httpd.conf) to this:

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName localhost:8888
ServerName slimproject.dev

After this I've stopped and started my server.

Yet it is still responding to http://localhost:8888 When I go to http://slimproject.dev it will tell me "Server Not Found"


Solution

  • If you want your apache to respond to http://slimproject.dev/, you need to:

    1. Make your apache listen on port 80 (since that is the default http port), and you can do it by editing Listen directive in httpd.conf (so replace Listen 8888 with Listen 80.
    2. Your browser needs to know that host with the name slimproject.dev is actually on your local machine. You can do that for example by issuing this command echo 127.0.0.1 slimproject.dev >> /etc/hosts

    Additional steps may be needed depending on httpd config, but let's do this first.

    (You will probably need root access for both above steps)