Leopard Tutorial – Installing PHP Mac 10.5

November 6, 2008 at 12:04 am Leave a comment

For users who prefer to learn Apple Leopard 10.5 visually we have a range of video tutorials, this method of training greatly enhances learning and allows beginners to master Apple Leopard 10.5 at their own pace.
View the Apple Leopard Tutorial Videos

.

Installing PHP 5 on Apple Leopard 10.5
 

These short PHP tutorials will help users correctly install PHP on Apple 10.5 Leopard using the default Apache server configuration that ships with Leopard.

Really this tutorial is not about installing PHP on Leopard 10.5, and that’s because it’s already installed, all you need to do is make a few small changes and you will unleash the full power of the Apache 2 web server and a full working version of PHP 5, here’s how.

First you need either a copy of BBEdit or TextWrangler, either one of these programs will allow us access to the hidden system files that we need to change in order to set up PHP 5. BBEdit is a paid product whereas TextWrangler is a lite, free version of BBEdit, the directions are the same for both programs:-

Launch BBEdit or TW, Select  File > Open Hidden.image1

 

 

 

 

 

this will open a Finder Window, at the bottom of the window select “All Files”  from the Enable drop-down box.

Now we need to open the httpd.config file, this should be located inside your Macintosh HD private:etc:apache2:httpd.conf , once you have found this file click open, the file will open but editing of this file is prohibited since it’s a system file, no worries, to enable editing just click the red diagonal red line located in the top left of the BBEdit / TW title bar. image2

 

 

 

You will get a warning that the Apache httpd.conf file is owned by root and do want to alter this file.

A word of warning you are now playing with an hidden system file and under normal circumstances you should first make a back-up, and you can if you wish to, however Apple have already anticipate this and a back-up copy of this and all the other Apache system files exist in the Original folder inside the Apache2 directory.

Now on to making the changes to the http.conf file, scroll down until you see the line of code that starts #LoadModule php5_module libexec/apache2/libphp5.so ( around line 114 ).image3

 

Uncomment the line by removing the preceding # , it should now read:
LoadModule php5_module libexec/apache2/libphp5.so
We have now made PHP 5 active, save the file, since the file is a system file you will have to type your administrator password before the file will save, that’s it, PHP is now running, you could stop and this point and all should work, but it is better if we create the php.ini file is we can make custom changes to the standard PHP configuration later if we need to.
The php.ini file on the Mac
PHP 5 on the Mac does not install a php.ini file, but one does exist on the system, we only have to make a few small changes to make it active, unlike the httpd.conf file we can’t use BBEdit or TW to open the file, we have to use the terminal.

Open the terminal ( located in the Application > Utilities folder ) and enter the following command ( press the enter key after each line)

cd /private/etc
sudo cp php.ini.default php.iniimage4

 

 

 

After the last command you will be asked for you administrator password, enter it, hit return and we are nearly done.

Turn on Web Sharing
Go to System Preferences > Internet & Network and select Sharing, this should start Apache, but it’s always a good idea to restart your system too.

When your Mac restarts we can test to make sure PHP is enabled :
open up BBEdit and type the following

<?php phpinfo(); ?>

Save this as test.php in Macintosh HD:Library:WebServer:Documents

Now open up your browser and type
http://localhost/test.php/

If you see details about your php installation give yourself a big pat on the back

The working php.ini file as now been copied to Macintosh HD:private:etc , like the httpd.conf file, this file can in the future be edited with BBEdit or TW.

Entry filed under: Apple Leopard Tutorials, PHP. Tags: , , .

Redirect Using .htaccess or PHP MS Project Tutorals – Free Viewer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Follow us on Twitter


Follow

Get every new post delivered to your Inbox.