Go Back   MacRumors Forums > Apple Systems and Services > OS X > Mac OS X Server, Xserve, and Networking

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 15, 2011, 01:51 PM   #1
patmalt
macrumors newbie
 
Join Date: Jan 2010
Enable PHP on a Mac

I googled how to enable PHP for snow leopard, but I cannot figure this out. I am trying to uncomment the php line of /private/etc/apache2/httpd.conf, but I get an 'MacOS Error -5000' when trying to save the file in TextWrangler. I looked up the error code and it said that I do not have permission to edit the file. However, I am the only user account on this Mac and I am an admin. How do I save this file? Thanks.
patmalt is offline   0 Reply With Quote
Old Mar 15, 2011, 03:38 PM   #2
Consultant
macrumors G5
 
Consultant's Avatar
 
Join Date: Jun 2007
Probably need to use sudo texteditor to open the file.

For web testing only, you are better off with MAMP.
Consultant is offline   0 Reply With Quote
Old Mar 15, 2011, 05:00 PM   #3
dmmcintyre3
macrumors 68020
 
dmmcintyre3's Avatar
 
Join Date: Mar 2007
Run in terminal:
sudo nano /private/etc/apache2/httpd.conf
to edit the httpd.conf
__________________
FreeVPS.us
dmmcintyre3 is offline   0 Reply With Quote
Old Mar 15, 2011, 06:44 PM   #4
patmalt
Thread Starter
macrumors newbie
 
Join Date: Jan 2010
I uncommented the PHP line in httpd.conf file in Terminal, but when i go to http://localhost/xyz.php in my browser, it is still just printing my PHP code.

I turned web sharing on/off and restared my computer but PHP still does not work!!!
patmalt is offline   0 Reply With Quote
Old Mar 16, 2011, 03:42 PM   #5
blaster_boy
macrumors 6502
 
Join Date: Jan 2004
Location: Belgium
Just enabling the php5 library to load in Apache is not enough. You also need to tell Apache what to do with any .php file that is served to the user.

Check your apache config file to see if this code is in there - perhaps it is commented out ?

Code:
<IfModule mod_php5.c>

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>

</IfModule>
It lets Apache know what to do with any php file.
blaster_boy is offline   0 Reply With Quote
Old Aug 4, 2011, 02:24 PM   #6
jbutler404
macrumors newbie
 
Join Date: Oct 2010
Help please (anyone who can help me get php working!)

Quote:
Originally Posted by blaster_boy View Post
Just enabling the php5 library to load in Apache is not enough. You also need to tell Apache what to do with any .php file that is served to the user.

Check your apache config file to see if this code is in there - perhaps it is commented out ?

Code:
<IfModule mod_php5.c>

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>

</IfModule>
It lets Apache know what to do with any php file.
I am a newbie to php, my OS is 10.6.8. I have done all the steps put up by everyone on the web but have the same problem as others in that the code is just printed instead of being parsed. I've tried your code (the line isn't in my file so I typed it in) but to no avail but this is probably because I don't understand it and need to. Can anyone help me to get my php loaded and working please? Thanks.
jbutler404 is offline   0 Reply With Quote
Old Aug 5, 2011, 10:17 AM   #7
ryanide
macrumors regular
 
Join Date: Jul 2002
Get MAMP PRO

http://www.mupromo.com/deal/1592/7024/mamp-pro
ryanide is offline   0 Reply With Quote
Old Aug 5, 2011, 12:30 PM   #8
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
The file you need to edit is located at
Code:
/etc/apache2/httpd.conf
While there is an httpd.conf in the /private directory, I've never messed with that one.

Just uncomment the line:
Code:
LoadModule php5_module libexec/apache2/libphp5.so
and restart Web Sharing, and that's all there is to it. The <IfModule> block that blaster_boy referred to is already present.
Darth.Titan is offline   0 Reply With Quote
Old Aug 5, 2011, 08:47 PM   #9
JavaTheHut
macrumors 6502
 
Join Date: Aug 2010
Quote:
Originally Posted by ryanide View Post
You can grab this deal but its limited time $25 if you run out of time you will need to pay more $50. You can also get the free version which works well and gives you a good start at managing Apache/mySQL/php at a nice price!
JavaTheHut is offline   0 Reply With Quote
Old Aug 5, 2011, 09:35 PM   #10
JavaTheHut
macrumors 6502
 
Join Date: Aug 2010
Quote:
Originally Posted by jbutler404 View Post
I am a newbie to php, my OS is 10.6.8. I have done all the steps put up by everyone on the web but have the same problem as others in that the code is just printed instead of being parsed. I've tried your code (the line isn't in my file so I typed it in) but to no avail but this is probably because I don't understand it and need to. Can anyone help me to get my php loaded and working please? Thanks.
Just my laymen observation but the code that was supplied by blaster_boy looks like its from a http://www.entropy.ch/software/macosx/php/ install this would have been downloaded and installed other than the original OSX php config?

The complete code looks like this (it may differ on others installs):
/usr/local/php5/entropy-php.conf (this is an alias in /private/etc/apache2/other/+entropy-php.conf)
Code:
# Additional PHP Apache directives,
# part of the entropy.ch PHP package for Mac OS X
# 
# For more information, go to http://www.entropy.ch/software/macosx/php/
#

LoadModule php5_module        /usr/local/php5/libphp5.so

<IfModule mod_php5.c>

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>

</IfModule>
The standard php config file in OSX is:
/private/etc/apache2/other/php5.conf
Code:
<IfModule php5_module>
	AddType application/x-httpd-php .php
	AddType application/x-httpd-php-source .phps

	<IfModule dir_module>
		DirectoryIndex index.html index.php
	</IfModule>
</IfModule>
The file & line you need to uncomment is
/private/etc/apache2/httpd.conf
Code:
LoadModule php5_module        libexec/apache2/libphp5.so
You need to use something like textwrangler(free) to save over the files with admin privileges or unlock the files using info in finder unlock them make them writable to user and lock them when your done your edits. I realize an adapt IT could do this all in terminal commands, and I certainly respect that fact but I went the visual route and it worked.
Hope this helps -- we've all been there -- enjoy!
JavaTheHut is offline   0 Reply With Quote
Old Aug 6, 2011, 05:04 PM   #11
asmiller
macrumors newbie
 
Join Date: Nov 2004
Enabling PHP

You also need to make sure permissions are correct. There is plenty of information out there about how to do this correctly. Typically they are set to 644 or 755 and you have to make sure the enclosing directory has correct permissions.
asmiller is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > OS X > Mac OS X Server, Xserve, and Networking

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
[php] - php problems os x mountain lion 10.8.2 cakas6933 OS X 10.8 Mountain Lion 4 Jun 10, 2014 09:08 AM
Learning PHP on the Mac ed45 Web Design and Development 24 May 21, 2014 04:30 AM
Enable Find My Mac without recovery partiton 5t3f4n OS X Mavericks (10.9) 13 Oct 22, 2013 03:48 PM
I need help please: Mac OS X Account - can't find how to enable a feature. fitzswim10 Mac Basics and Help 1 Jul 8, 2013 01:09 PM
How to enable RAID 1 in Mac mini Server mid 2010 technowar Mac mini 21 Jan 21, 2013 11:33 AM

Forum Jump

All times are GMT -5. The time now is 09:54 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC