How to create a new virtual host

Open (by navigating, our Mac search doesn’t find it) MacSSD → usr → local → etc → apache2 → 2.4 → extra → httpd-vhosts.conf

Go to the bottom of the file and copy the last vhost and paste it below the one you copied from.

Change the “Document Root” and “Directory” to the path of the new site.

Then change the “Server Name” to the base name of the vhost (for ____:1111, the blank is the server name).

Make sure the quotes next to where you type don’t turn into magic quotes. Magic quotes are not straight up and down, but curve to the side. Copy some of the good straight ones and paste them in.

Save the file and then open MacSSD → private → etc → hosts

It may be locked, in which case you should change the permissions to the etc folder.

Copy one of the lines that has ( + the name of a vhost) and then switch in your vhost name.

Save the file, and change the permissions back.

Restart apache in terminal. (sudo apachectl restart)

Go and visit your new vhost in a browser. (vhostName:1111)

Leave a Reply