Most Mac users don ’ t realize it, but macOS comes with its own built-in web server. Apache is an open-source web server that has been available since 1995, and as of 2016, it was the locomotive behind 46 % of all websites and 43 % of the top million websites in terms of traffic .
Having a world wide 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 exploitation web waiter before deploying them to an internet server. These instructions show you how to set up Apache waiter in macOS High Sierra. You ’ ll motivation to have some cognition of the Terminal app and how to run command line programs, an understand of network servers, and a familiarity with the united states virgin islands editor program.
To begin, we edit the Apache shape charge as root :
sudo vi /etc/apache2/httpd.conf
A web waiter is relatively useless without a server-side script language with which to handle interactions ; the most popular languages are PHP, Perl, and Python. In this exemplar, we ’ ll enable PHP and Perl. To do so, you ’ ll need to uncomment line 176 of the shape file. In the six editor, you can do this easily by typing 176G to go directly to line 176. next, type an x over the # at the beginning of the postdate lineage to delete the # comment marker :
#LoadModule php7_module libexec/apache2/libphp7.so
We want to do the same to be able to run Perl scripts, which is in line 177 of the configuration file. Use your arrow key to go down to the beginning of the adjacent line, then type the x over the # to delete the comment marker. The configuration file should then looks something like this around line 176 ( see screenshot below ) :
To save your changes in the editor program, type :w!
We still need to enable personal websites by uncommenting course 173, so type 173G and wardrobe refund, then type an x over the # to delete it. The same must be done with line 513 of the file — character 513G and bid hark back, then type an x over the # to delete it. now we ’ ll save these two final changes and quit the editor by typing ZZ.
The last dominate just enabled a file named http-userdir.conf, and we now need to edit it : In Terminal, enter :
sudo vi /etc/apache2/extra/httpd-userdir.conf
In this shape file, we need to uncomment pipeline 16. type 16G and press return, then type an ten over the # to delete it. Save and exit by typing 16G .
up until Mac OS X Lion, it was potential to share websites with a local workgroup and create personal websites with a snap ; to publish web pages, you simply put your hypertext markup language files into a Sites folder. now we have to do a batch more workplace. Let ’ s manually create a Sites booklet in Terminal and make a little test file so we know our web waiter is working .
Enter the following commands :
Welcome to my site
” > ~/Sites/index.html.en
adjacent, we need to make sure that we have a user configuration file. To create one, type in
sudo vi /etc/apache2/users/
sudo vi/etc/apache2/users/stevensande.conf ( don ’ metric ton use this for YOUR shape file ! )
In that shape file we want to enter the follow ( cutting and pasting into vi works ) :
AddLanguage en .en
AddHandler perl-script .pl
Options Indexes MultiViews FollowSymLinks ExecCGI
Require host localhost
Read more: Medical Website Hosting | RemedyConnect
once again, remember to replace
If you ’ ve made it this far… congratulations ! now let ’ s check our configuration of Apache by running the play along command in Terminal :
You ’ ll credibly get a warn message that says “ hypertext transfer protocol : Could not faithfully determine the server ’ s wax stipulate knowledge domain name ” along with how to resolve that issue ; since this is good for a local web server, ignore that warning — what you do want to see is the stopping point line : Syntax OK .
If everything is fine up to this point, you ’ re ready to start up Apache. If any of the shape file syntax is incorrect, you ’ ll get warnings on what needs to be fixed .
At long stopping point, we ’ ra cook to launch the Apache httpd service :
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
To see our one telephone line web page, establish Safari or your front-runner browser and embark http://localhost/
You should see :
To see your exploiter base directory, enter hypertext transfer protocol : //localhost/~
Welcome to my site
Should you decide to shut down the Apache serve, there ’ s a simple one-line Terminal command to do therefore :
sudo /usr/sbin/apachectl stop
Making life easier with MAMP
That was a bunch of sour to get things up and running, wasn ’ metric ton it ? There ’ s a much easier room 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 mighty web waiter. Add “ Mac ” to the begin of this, and you have MAMP — Mac, Apache, MySQL, and PHP/Python/Perl. The “ AMP ” distributions ( LAMP for Linux, WAMP for Windows, MAMP for Mac ) are the spinal column of the wildly popular WordPress platform, thus if you want a very complete WordPress development environment on your Mac, you ’ ve come to the right set .
MAMP comes in two varieties ; the complimentary MAMP solution for a personal web server and MAMP Pro ( $ 59 ), which adds extra services like e-mail, dynamic DNS, and more. For this post, we ’ ll install and configure the barren MAMP .
1) Download MAMP from the MAMP web site
2) Open the .pkg charge and follow the facility instructions to install MAMP to your Mac
3) Once the facility is complete, you ’ ll find two folders in your Applications folder — one for MAMP, and another that is a 14-day free test for MAMP Pro. Open the folder named MAMP and launch the MAMP app. You ’ ll see something that looks like this screenshot :
4) Click the “ Start Servers ” button .
MAMP will start both the Apache and MySQL servers, then launches a web page that confirms that your MAMP facility is complete ( see screenshot below ) :
The “ My Website ” link shows an empty page, but you can change that by placing an index.html file into the htdocs booklet found in the MAMP folder. It ’ second comfortable to change the Document Root directory by going to MAMP > Preferences > Web Server .
note that MAMP Pro besides brings “ Extras ” to the table ; these are packages designed by the MAMP team to install promptly and bring add functionality. Remember my comments about WordPress ? There is not only a MAMP Extra for WordPress, but for Joomla, Drupal and other content management systems as well .