Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Personal Web Sharing and PHP - Not working

Personal Web Sharing and PHP - Not working
Thread Tools
chabig
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 7, 2005, 12:04 AM
 
Standard Tiger install. I enabled PHP by editing the httpd.conf file and I now have Apache and PHP running. I know they are both running because it says so in my httpd error log. When I go to http://localhost/~chabig/Index.html I see the web page that proves Apache is running. But when I try to open a PHP file in Safari all I get is the text of the file. It's not interpreting anything. How can I fix it?

Chris
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Oct 7, 2005, 12:33 AM
 
can you please show what parts you did to enable php?
     
mania
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Oct 7, 2005, 12:47 AM
 
yeah - there are like 4 different lines you have to uncomment to get it to work.
The Bitcastle
graphic design, web development, hosting
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Oct 7, 2005, 04:19 AM
 
Originally Posted by mania
yeah - there are like 4 different lines you have to uncomment to get it to work.
4? I thought you just had to uncomment the following lines:

LoadModule php4_module libexec/httpd/libphp4.so

and

AddModule mod_php4.c

Chabig: Have you restarted Apache? `sudo apachectl restart' or you can do it through system preferences. Also, where is the PHP file located?
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 7, 2005, 07:49 AM
 
I've done what you all have spoken about so far (I followed the instructions at http://www.macmegasite.com/node/2506).

I uncommented the two php lines in httpd.conf and restarted Apache. When I go to my own home page I see http://homepage.mac.com/chabig/Welcome.jpg but when I try to open pmwiki.php I see http://homepage.mac.com/chabig/Source.jpg.

Is it critical that the pmwiki files be placed in /Library/Webserver/Documents/ or can they go in ~/Sites/ (my preference)?

Chris
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Oct 7, 2005, 08:37 AM
 
Ah, well there's the problem. Safari is just opening it as a file and not through the web server. Open it using http://localhost/pmwiki.php rather than file:///Users/chabig/wherever

And yeah, you can run php scripts from your sites folder. The address would be http://localhost/~chabig/pmwiki.php
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 7, 2005, 09:43 AM
 
Originally Posted by Black Book
Ah, well there's the problem. Safari is just opening it as a file and not through the web server. Open it using http://localhost/pmwiki.php rather than file:///Users/chabig/wherever
I know we're on the right track, but when I try to open it using http://... I just get a 404 File Not Found error.

And yeah, you can run php scripts from your sites folder. The address would be http://localhost/~chabig/pmwiki.php
Thank you for confirming this.

So I believe something is not right with my Apache configuration, because it doesn't seem to serve this file to Safari.

Chris
     
mania
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Oct 7, 2005, 05:02 PM
 
try putting in your IP address instead of localhost?
The Bitcastle
graphic design, web development, hosting
     
jay3ld
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Oct 7, 2005, 06:05 PM
 
your error is it cant be loaded localy.

put the pmwiki.php in the folder /Users/[YOUR NAME]/Sites/

then try to load it though

http://localhost/~[YOUR NAME]/pmwiki.php
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 7, 2005, 07:20 PM
 
I made a mistake in my earlier post. I do have it in /Users/myname/Sites/ and it still won't load. I honestly think it's an Apache configuration problem.

Chris
     
madmacgames
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 7, 2005, 07:39 PM
 
make sure pmwiki.php has read & execution permissions for the anybody group. I sometimes get problems after copying a script from my desktop to my site folder. chmod 0755 does the trick for me. Oddly though, files I directly save to my site folder I have no problems with. Only copied files I need to fix the permissions on.

Actually I have FileVault on and remember reading somewhere this is a file vault issue.
The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 7, 2005, 11:44 PM
 
Those files already have 755 permissions. This is just weird.

Chris
     
himself
Mac Elite
Join Date: Jan 2002
Location: Live at the BBQ
Status: Offline
Reply With Quote
Oct 9, 2005, 12:11 AM
 
There are other lines in the apache config file that you need to make sure are there... There are one or two lines that identify the file extensions that apache should process through php. If apache doesn't know what file extensions to look for to process as php, it will treat that file as a normal text of html file.
"Bill Gates can't guarantee Windows... how can you guarantee my safety?"
-John Crichton
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 9, 2005, 12:32 AM
 
That should be the two AddType lines in this section:

.
.
<IfModule mod_php4.c>
# If php is turned on, we repsect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
.
.
.
It looks right, so I don't think that's the problem either.

I really do appreciate everyone's ideas.

Chris
     
Simon Mundy
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Oct 9, 2005, 02:00 AM
 
Originally Posted by chabig
I know they are both running because it says so in my httpd error log
It shouldn't say anything in your error log if everything's OK.

Can you provide a list of the last 10-20 entries in your /var/log/httpd/error_log file?
Computer thez nohhh...
     
chabig  (op)
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Oct 9, 2005, 08:46 AM
 
I figured it out (and boy am I embarassed!). But first, here are the lines in my error_log that show it's all turned on:

Processing config directory: /private/etc/httpd/users/*.conf
Processing config file: /private/etc/httpd/users/bettyann.conf
Processing config file: /private/etc/httpd/users/chabig.conf
Processing config file: /private/etc/httpd/users/chadmin.conf
Processing config file: /private/etc/httpd/users/taylor.conf
[Sun Oct 9 06:23:41 2005] [notice] Apache/1.3.33 (Darwin) PHP/4.3.11 configured -- resuming normal operations

And my problem was...just that I couldn't get the URL right! This is so simple it's embarassing, but I was trying:

http://localhost/Users/chabig/Sites/pmwiki/pmwiki.php
http://localhost/~chabig/Sites/pmwiki/pmwiki.php

Neither of those worked because Apache resolves http://localhost/~chabig/ to my Sites folder, so the what I was actually asking for was http://localhost/~chabig/Sites/Sites/pmwiki/pmwiki.php, which doesn't exist (see the "Sites/Sites/" part?).

This was staring me in the face in my error_log and I just didn't see it until this morning. Interestingly, you can't drag the php file onto Safari's dock icon--that just opens it as text. I was thrown off by that too, but I guess it makes sense because that's asking Safari to open a file. It's not being served by Apache.

So I'm up and running. Thanks everyone for sticking with me on this.

Chris
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:06 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,