- cp /etc/apache/http.conf /etc/apache/back_http.conf # No backup, no mercy.
- sudo vi /etc/apache/http.conf
- You need to change two lines: Locate "DocumentRoot" and set the path behind it to '/Users/yourUserHomeDirectory/Sites'. Then locate the <Directory "/Library/WebServer/Documents"> line and change the path to the one you entered above.
- Remove the '#' sign infront of the line starting with "LoadModule php5_module"
- Save the file and exit.
sudo /sbin/apachectl restart
You can use the two following scripts as a default template. Copy the text and place them two files within the ~/Sites directory.
The index.html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"Then enter the following into a file called phpinfo.php and place it in the ~/Sites directory as well.
<title>Index Testing PHP</title>
<br /><br />
<form method="POST" action="phpinfo.php">
<?php phpinfo(); ?>
Set permissions for phpinfo.php to 755 in order to be executable by Apache. Now enter http://localhost/~yourUserHomeDirectory/ into a browser. This will display a minimal page showing the path you entered above and a button. Hit the button and the phpinfo.php script will execute. This should be it.
In case you have trouble getting it running, feel free to leave a comment.