Sunday 28 August 2011

Apache xampp virtual hosts configuration on mac

After installing xampp on mac you need to change permission for /xamppfiles/etc/httpd.conf file. There is simple program for that, called BatChmod.

Next you need to enable it for user thsty you want:

Find:
User nobody
Group nogroup

Change it to:
User YOURUSERNAME
Group admin



If you projects are in another location you will need to change DocumentRoot in httpd.conf to you path, and also need to change line
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
to you path, and "Deny from all" to "Allow from all" to this directory


After that uncomment
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

Here is where you put your virtual hosts. 

It should look like :

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
  ServerName yourdomain.dev
  DocumentRoot "/Users/
username/projects/your_project"
  DirectoryIndex index.php
  <Directory "/Users/
username/projects/your_project">
    Options +Indexes FollowSymLinks +ExecCGI
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
  ServerName localhost
  DocumentRoot "/Users/username/projects/"
  DirectoryIndex index.php
  <Directory "/Users/
username/projects/">
    Options +Indexes FollowSymLinks +ExecCGI
    AllowOverride AuthConfig FileInfo
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
 
Last thing, add yourdomain to hosts

Open the Terminal and type:
sudo pico /etc/hosts

Now enter your admin password. You'll get a little text editor in the console. Go to the last line and add this line:
127.0.0.1 yourdomain.dev with the correct name for every virtual host you would like to set up. When you're done, type control-o, then enter and then control-x in order to save and close.

No comments:

Post a Comment