1. Enable PHP by opening /etc/apache2/httpd.conf and uncommenting the line
LoadModule php5_module libexec/apache2/libphp5.so
2. By default, the web root directory is at /Library/WebServer/Documents. To
use your own directory, say ~/Sites/, create it with
mkdir ~/Sites
and then create /etc/apache2/users/your_username.conf and put the following information:
<Directory "/Users/your_username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
sudo apachectl start
Now you can test that Apache is running by opening http://localhost in a browser. You should see the text “It works!”.
To test that PHP is now working, create a PHP test file in your web directory with
printf "<?php phpinfo(); ?>" > ~/Sites/phpinfo.php
Then, open http://localhost/~your_username/phpinfo.php
4. To host the web directory in Dropbox, do
chmod a+rx ~/Dropbox
mv ~/Sites ~/Dropbox/
ln -s ~/Dropbox/Sites ~/Sites
All files under ~/Dropbox/Sites must have a+rx permission. Make sure to change the file permissions.
Otherwise, the web server will not be able to read them. You can test if the configuration files are valid by using the command
httpd -t