Apache server commands

Enabling/Disabling service

Shell commands for start, stop and restart apache server

sudo apachectl -k start
sudo apachectl -k stop
sudo apachectl -k restart

Using virtual hosts

First edit the file httpd.conf

sudo nano /etc/apache2/httpd.conf

Locate the following lines and remove the hash

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

Now it should look like this:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

Now edit the httpd-vhosts.conf file and add your own virtual hosts

sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

When finished restart the service to apply all new changes

Finally add the new virtual hosts to the hosts file

sudo nano /private/etc/hosts

The new lines should look like this:

fe80::1%lo0     your_host_name.local
127.0.0.1       your_host_name.local

Important!.- Don’t forget to add the fe80::1%lo0 (IPV6) to your host. The latest versions of Mac OS X use IP version 6 instead IPV4. So it will try to find the vhost first using the IPV6. Otherwise you may experiment speed issues.

Leave a Reply

Your email address will not be published. Required fields are marked *