Wednesday, February 23, 2011

simple way to install php on mac

Before you can enable PHP on a Mac, you first have to enable Apache. Fortunately this is extremely easy. If you would like more information about Apache on the Mac you can read more here.1.) Click the 'System Preferences' icon in the Dock.
2.) Click the 'Sharing' icon in the Internet & Network section of the System Preferences window.
3.) Place a check mark in the ‘Web Sharing’ box.
That's it! If you want to test if it worked, point your browser to http://localhost/ and you should see the standard Apache test page.
For this next part you are going to need a plain text editor that will allow you to open hidden files. Personally, I use TextWrangler because it's free and it gets the job done. These next steps might be slightly different if you are using a different editor, but the principle is still the same.1.) We want to open the file located at HD:private:etc:apache2:httpd.conf. In TextWrangler we do this by choosing "Open Hidden" from the File menu. 2.) Since it is a root file, we need to unlock it before we can edit. In TextWrangler this is done by clicking the pencil button in the top left hand corner. You will get a pop-up confirming that you want to do this.
3.) Go to line 114, the line should read # LoadModule php5_module libexec/apache2/libphp5.so
4.) Delete the #, the line should now read LoadModule php5_module libexec/apache2/libphp5.so
5.) Save the file. You will be prompted for your password if you are using TextWrangler.
The next thing we want to do is make a copy of php.ini.default and save it as php.ini. Once we have done this we can edit our PHP preferences.1.) First open up Terminal. It is located inside your Systems folder which is located inside your Applications folder. 2.) Enter the following lines, one at a time:
cd /private/etc
sudo cp php.ini.default php.ini

3.) You may now open your new php.ini file using TextWrangler or another editing programing and change the default settings if you wish. It will be located in Macintosh HD:private:etc
read more