Apache on Mac OSX
This page documents the location of information for Apache on Mac OS X.
Directory Locations
Document Directory | /Library/Webserver/Documents |
CGI-BIN Directory | /Library/Webserver/CGI-Executables |
Configuration Files | /etc/httpd/httpd.conf |
Default Log Files | /privat/var/log/httpd (both error and access logs can be found here. |
Given the length of the names, it is a good idea to create symbolic links to both directories in your home directory. For example:
ln -s /Library/WebServer/Document ~/htdocs
Starting and Stopping the Server
The server is started and stopped with the apachectl
program. The program is located in the /usr/sbin
directory. To restart the server, follow these steps.
- Type
sudo bash
to become super user - To stop the server type:
apachectl stop
- To start the server type:
apachectl start
- Type
exit
to end your super user shell session
Getting PHP to Work on Mac OS X and Apache
Having just done a fresh install of Panther (10.3) I recently noticed that PHP is not working correctly for some of my script files. A quick look through the httpd.conf file I found that the PHP module had not been included as one of the startup modules. So below is a summary of the sections that need to be set on the conf file for PHP to work.
In the Dynamic Shared Object Section (DSO) make sure the php LoadModule command is not commented out:
LoadModule php4_module libexec/httpd/libphp4.so
In the section just below, make sure that the AddModule command is also not commented out.
AddModule mod_php4.c
The conf file also included these module directives toward the end of the file.
<IfModule mod_php4.c> # If php is turned on, we repsect .php and .phps files. AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps # Since most users will want index.php to work we # also automatically enable index.php <IfModule mod_dir.c> DirectoryIndex index.html index.php </IfModule> </IfModule>
That's it. After all that was set everything worked swimingly. For more information about Apache or PHP on Mac OS X. See Apple's developer site at: http://developer.apple.com/internet/