|
Mac OS X is the perfect environment for developing PHP pages. Version 2 of the popular Apache Web server is a part of the system and the PHP server extension for Apache is included with OS X 10.5. This makes it relatively easy to setup Personal Web Sharing and enabling PHP to develop PHP files locally on your Mac.
The Personal Web Sharing is powered by the OS X Apache Web server and you can enable/disable Web sharing in the System’s Sharing Preference panel. PHP is however by default disabled in the standard setup.
This page describes how to activate PHP in the Mac OS X 10.5 Personal Web Sharing using the OS X Tools available in PageSpinner version 5.2 and higher. PageSpinner also offers support for PHP with PHP syntax coloring, a new PHP menu, the SpinPHP example set, and a Lookup PHP function. See this page for info on how to enable PHP in OS X 10.2-10.4.
Before you start working with PHP it is highly recommendable to set PageSpinner to use Unix line feeds whan saving the files. This will let you find any errors reported by the PHP engine using PageSpinner's Go To Line... command. You can set the PageSpinner to use Unix line feeds in Preferences : Default Filing Options...
Perform the following steps to activate the PHP module in the OS X Apache Web server:
If you are running PageSpinner version 5.2 or higher:
Choose OS X Tools from PageSpinner’s 5.2 Windows menu.
Click the OS X Apache button in the OS X Tools palette and select the menu item Edit Configuration in Pico.

NOTE: If you are running a PageSpinner version older than 5.2, you must launch the Terminal manually and and then type the following command in the Terminal window:
sudo pico /private/etc/apache2/httpd.conf
The Terminal application will now be opened and you will be asked for a password.
Enter the Administrator password for your system and the terminal-based Pico-compatible text editor "GNU nano" will be started.
You should now see the Apache httpd.conf file in the Terminal window.
Press Ctrl+W to do a search in GNU nano.
Type php and press Return.

The following line should be displayed:
#LoadModule php5_module libexec/apache2/libphp5.so
Use the arrow keys to move the cursor and the backspace key to remove the # at the beginning of the line. The line should then be look like this:
LoadModule php5_module libexec/apache2/libphp5.so
Press Ctrl+O and then press Return to confirm that you want to save.
Press Ctrl-X to quit GNU nano.
The PHP installation in 10.5 doesn't have an editable php.ini file, so we need to create it from the included default file. In the Terminal, type or paste the following command:
sudo cp /private/etc/php.ini.default /private/etc/php.ini
You now need to restart the Apache server to make it use the new configuration. Type:
sudo apachectl graceful
in the OS X shell and press Return. Enter the Admin password and press Return.
You can now close the Terminal window.
Personal Web Sharing should now be running with PHP support enabled.
The final (optional) step is to give the Web server access rights to create, modify and delete files using PHP in your personal Sites folder.
Open your Home folder in Finder.
Select the Sites folder and choose Get Info from Finder’s File menu. (You can optionally select a subfolder inside the Sites folder instead of the entire Sites folder if you want to restrict PHP modification access to all contents inside the Sites folder).
Display the Sharing & Permissions section.
Click the Padlock icon at the bottom of the Get info panel to unlock the settings.
Enter your admin password if Finder asks for it.
Choose staff in the Name column.
Change the Privilige for staff to Read & Write
Select Apply to enclosed items from the popup menu (to the right of the + and - buttons).
Congratulations, if everything has turned out successfully, PHP support should now be active and you are ready to explore the possibilities available with PHP!
Back
|