Enabling PHP in 10.2 Client

sixthring

Support Specialist
I would put this in the How To Forum but I can not add new threads. I also realize there is a PHP how to thread but it is for 10.0-10.1.x not 10.2 specifically, and it is getting a little long in the tooth. On to the instructions.

Although Apple builds Apache and support for PHP into OS X.2, it doesn’t actually turn these features on. You’ll have to do that part yourself. Here’s how:

Turn PHP Support On

To activate Apache’s PHP module, you’ll first need to modify the Apache configuration file. Since the configuration file is hidden from the Finder, you’ll have to make a trip to the command line.
Open Terminal (Applications: Utilities: Terminal). Before you make any changes, you’ll want to create a backup of your Apache configuration file—just in case something goes wrong. To do this, type the following commands into the Terminal window:

cd /etc/httpd

sudo cp httpd.conf httpd.conf.orig

Enter your administrator password when prompted, and then type sudo pico httpd.conf. This command opens your Apache configuration file in pico, a Unix text editor. In pico, press control-W to open the Find command, and then type php. When you hit the return key, your cursor should land on the line:

#LoadModule php4_module libexec/httpd/libphp4.so

Using the left-arrow key to move your cursor, remove the # character at the beginning of this line. Press control-W again. This time, type the string:

mod_php4.c and press return.

Remove the # character from the beginning of this line as well. Press control-W a third time and search for the string x-tar. When you land on it, move your cursor to the end of the line, press return, and then add the line:

AddType application/x-httpd-php .php

Once you’ve made these three changes, save the file by pressing control-O and then the return key. Press control-X to exit pico. Apache should now automatically load the PHP module on start-up. When the Web server encounters pages ending in .php, it’ll send them to the PHP module for interpretation.

Start Apache

With PHP enabled, you’re ready to flip the switch on your Web server. Open your System Preferences and select Sharing. Click on the Services tab, and select the Personal Sharing option. Click on Start. (If Web sharing was already on, you’ll need to turn it off and then back on to activate the changes you’ve made.)

Testing

To find out whether the PHP module has been correctly activated, open your favorite text editor and create a new document. (If you’re using Apple’s TextEdit, make sure you’ve turned off the pro gram’s Rich Text features, in Preferences, first.) In your blank document, type <? Phpinfo(); ?>. Save the file as test.php in the Sites folder in your user’s folder. Open your Web browser, and type in the address http I host/ ph p, where username is your short name on the OS X machine. (Because PHP is a server-parsed language, nothing will happen if you open a PHP file in your Web browser via the File menu or by double-clicking. To execute PHP pages, you must access them through a PHP-enabled Web server.)
Your browser should display tables packed with arcane data about your new PHP environment. If you see only one line of raw PHP code, repeat this step.
 
any smart people know how to erase or re-create a php.ini file? Mine is jacked and i want to get rid of it and create a new one.

Any help would be awesome.

Twister
 
Back
Top