![]() |
|
|
|
|
| 010011010110000101110100011101000010000001000010011101010111010001100011011010000110010101110010 | |
|
Enable Apache and PHP5 on Mac OSX LeopardApache and PHP are there... just turn them on!
Author: M Butcher Apple's OS X Leopard (10.5) comes with the Apache web server and PHP 5 pre-installed. But by default neither one is enabled. This short guide tells you how to get started. ApacheOS X Leopard ships with Apache 2.2 preconfigured for "sharing documents". In this configuration, each user on your system has a Sites/ directory inside of their home directory. (Example: /Users/mbutcher/Sites/) Turning Apache OnBy default, Apache is turned off. That means that when you start up your system, Apache is not one of the services started. To start it, got to your System Preferences, click on Sharing, and then check the Web Sharing checkbox in the list of services. $ sudo apachectl start (Note that hte $ sign is just there to indicate the shell prompt. You do not need to type $.) $ sudo apachectl stop
$ sudo apachectl restart This will stop and start Apache again, reloading the configuration files as it goes. Adding ContentNow that Apache is running, you probably want to add some content. Here's how this is done. http://matthew-butchers-macbook-pro.local/~mbutcher/test.html Since I have a file in /Users/mbutcher/Sites/test.html, the URL above will retrieve that file and display it in a web browser. If the test.html file did not exist, an error message (File Not Found) would be displayed in my web browser. PHP 5PHP 5 -- both the command line version and the Web server module -- are installed by default in OS X Leopard. To verify this, you can open a Terminal and type: $ which php This will print out the path to the version of PHP installed: /usr/bin/php To find out more about this version of PHP, try this: $ php --version This will print out version information: PHP 5.2.5 (cli) (built: Feb 20 2008 12:30:47) So we have PHP installed and available... but how do we configure Apache to allow it? Enable the PHP Apache ModuleTo get Apache to process PHP pages, we need to make one minor change to one of Apache's configuration file. We need to edit /etc/apache2/httpd.conf. And we will do this in Terminal by entering the following command: $ sudo pico /etc/apache2/httpd.conf (You might want to make a copy of /etc/apache2/httpd.conf first. Do that like this: cp /etc/apache2/httpd.conf /etc/apache2/original-httpd.conf.) #LoadModule php5_module libexec/apache2/libphp5.so It is a few hundred lines into the file, and it is just below a dozen or so other lines that also start LoadModule. All you need to do is remove the leading hash mark (#). The finished line should look like this: LoadModule php5_module libexec/apache2/libphp5.so Save and exit (hit Control-X in pico). $ sudo apachectl restart At this point, you should have PHP enabled. Then access it in your browser with http://localhost/~YOURNAME/test.php. You should simply see the words This is a test. Common Problems
Of course, there are other things that can go wrong. Fortunately, once you have the webserver running, you should be able to access all of Apache's documentation by typing in this URL: http://localhost/manual/ |
|
|||||||||||||||||
Search |
|||||||||||||||||||
|
Questions? Comments? Consulting Opportunities? Email matt at aleph-null.tv. This site and all of its content is Copyright © 2003-2005, Aleph-Null, Inc. All rights reserved. |
|||||||||||||||||||