

That was a lot of work to get things up and running, wasn’t it? There’s a much easier way to set up a local test server! For quite a while, developers have realized that packaging Apache, MySQL (a database server), and PHP/Python/Perl was the best way to get a very powerful web server. Should you decide to shut down the Apache service, there’s a simple one-line Terminal command to do so: To see your user home directory, enter once again replacing with your Unix short user name. To see our one line web page, launch Safari or your favorite browser and enter You should see: Sudo launchctl load -w /System/Library/LaunchDaemons/ If any of the configuration file syntax is incorrect, you’ll receive warnings on what needs to be fixed.Īt long last, we’re ready to launch the Apache httpd service: If everything is fine up to this point, you’re ready to start up Apache.
#DOWNLOAD APACHE FOR MAC HOW TO#
You’ll probably get a warning message that says “http: Could not reliably determine the server’s full qualified domain name” along with how to resolve that issue since this is just for a local web server, ignore that warning - what you do want to see is the last line: Syntax OK. If you’ve made it this far… congratulations! Now let’s check our configuration of Apache by running the following command in Terminal: Type ZZ to save the new configuration file and quit the editor. Once again, remember to replace with your short user name. Options Indexes MultiViews FollowSymLinks ExecCGI In that configuration file we want to enter the following (cutting and pasting into vi works): Sudo vi/etc/apache2/users/nf (don’t use this for YOUR configuration file!) In my case, it’s stevensande, so I’d enter Don’t know what that name is? Look at the top of the Terminal window and you’ll see a name listed - that’s the short user name. Next, we need to make sure that we have a user configuration file. Let’s manually create a Sites folder in Terminal and make a small test file so we know our web server is working.Įcho “Welcome to my site” > ~/Sites/
#DOWNLOAD APACHE FOR MAC MAC OS X#
Up until Mac OS X Lion, it was possible to share websites with a local workgroup and create personal websites with a click to publish web pages, you simply put your html files into a Sites folder. Type 16G and press return, then type an x over the # to delete it. In this configuration file, we need to uncomment line 16. The last command just enabled a file named nf, and we now need to edit it: In Terminal, enter: Now we’ll save these two final changes and quit the editor by typing ZZ. The same must be done with line 513 of the file - type 513G and press return, then type an x over the # to delete it. We still need to enable personal websites by uncommenting line 173, so type 173G and press return, then type an x over the # to delete it. To save your changes in the editor, type :w! The configuration file should then looks something like this around line 176 (see screenshot below): Editing the Apache configuration file in the vi editor Use your arrow key to go down to the beginning of the next line, then type the x over the # to delete the comment marker. We want to do the same to be able to run Perl scripts, which is in line 177 of the configuration file. #LoadModule php7_module libexec/apache2/libphp7.so Next, type an x over the # at the beginning of the following line to delete the # comment marker: In the vi editor, you can do this easily by typing 176G to go directly to line 176. To do so, you’ll need to uncomment line 176 of the configuration file. In this example, we’ll enable PHP and Perl. To begin, we edit the Apache configuration file as root:Ī web server is relatively useless without a server-side scripting language with which to handle interactions the most popular languages are PHP, Perl, and Python.

You’ll need to have some knowledge of the Terminal app and how to run command line programs, an understanding of web servers, and a familiarity with the vi editor. These instructions show you how to set up Apache server in macOS High Sierra.

Having a web server built into macOS is perfect for those who want to share information in a small workgroup or set up and test sites on a development web server before deploying them to an internet server. Apache is an open-source web server that has been available since 1995, and as of 2016, it was the engine behind 46% of all websites and 43% of the top million websites in terms of traffic. Most Mac users don’t realize it, but macOS comes with its own built-in web server. Today, I’ll discuss how to bring back one of those services - web hosting - using both the Apache web server that is built into macOS and the full MAMP suite. A few weeks ago, The Rocket Yard ran an article detailing the many services that will be removed from macOS Server in the near future.
