Thursday, March 17, 2011

How to enable PHP with Apache in Mac?

1. First you have to find the location of the apache configuration file httpd.conf. It is normally found at /private/etc/apache2/httpd.conf. Find the following or similar line:

#LoadModule php5_module        libexec/apache2/libphp5.so

Uncomment the above line by removing "#", save and quit the file.

2. Restart the apache using your root access or proper privileges
$ apachectl restart

3. Create a test php file called x.php in the public folder of the server, which can be accesses through URL in the browser

$ vi /Library/WebServer/Documents/x.php
and write

4. access the file using your favorite browser.

http://localhost/x.php

It show all the configuration. Congratulations!!!

Tip: You can create soft link directly from your home folder to your web directory like:

$ ln -s /Library/WebServer/Documents htdocs

No comments: