Sometimes we setup dev environment on locally and use ‘virtual host’, check steps below for OS X El Capitan virtual host setup.
Prerequisites: working Apache server
OS X El capitan Virtual host setup steps-
Go to terminal login to root user if you are not root,
Step 1 : Like ubuntu, we need to add domain to hosts file, open hosts file by cmd and your domain entry
sudo vi /etc/hosts
and add new line ex. 127.0.0.1 abcd.com
Step 2 : Create new virtual host
sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
Check the end of file, you can modify existing once or new simpl one like below
<VirtualHost *:80> DocumentRoot "/Users/amol/Sites/abcd" ServerName abcd.com </VirtualHost>
Make sure DocumentRoot is correct, try copying from “pwd”
Step 3 : Enable virtual hosts by including
/private/etc/apache2/extra/httpd-vhosts.conf file into /etc/apache2/httpd.conf file, its allready included you need uncomment a single line.
Step 3 : Finally restart a server and test your newly created host.
sudo apachectl restart