apache and php

tux

Registered
i bought my first mac the other week and installed it ok. then someone told me to try yellow dog so i gave it a go not knowing it formats my hdd :( aw well, i didnt have any documents on it yet.

today i backed up all of my files using a cross over cable to my pc and proceeded to repartition and install osx.

i immediatly went to enable the apache web server and install php. the install of php fails every time with this log

i formated and tryed again but same results. can anyone help me sort this?
 
Looks like you might have accidentally shut down the Apache webserver before you installed PHP.
You can try reinstalling PHP right after activating Person Web Sharing in the Sharing system preference (this will ensure that Apache is running properly), or you can muck about in the httpd.conf file to try and get PHP running. If you'd like to do the latter, let me know and I'll help you set it up :)
 
apache must have been running because it was started a few moments before i copied my files back.

so i think its best to edit the httpd.conf (yeah i will need help :p)

would it allso matter that i did php before running the software update? (thats running now)
 
It shouldn't have mattered.

To activate the Entrophy.ch PHP distribution (I am so going to write a HOWTO on this, must be the fifth time I've typed this out in one form or another...:))

You need to edit the /etc/httpd/httpd.conf. Open this by using sudo pico /etc/httpd/httpd.conf and scroll to the very bottom.
Add the following at the very end of the file (not required place, but that's where the installer puts it, so it makes most sense to put it there too)

Code:
# begin entropy.ch PHP module activation
Include /usr/local/php/httpd.conf.php
# end entropy.ch PHP module activation

# begin entropy.ch PHP module activation
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php
# end entropy.ch PHP module activation

This code tells the web server to load the PHP installation, and then tells it which file extensions to parse as PHP.

If any of this doesn't work, or you have more questions, feel free to ask, I like to help!
 
PHP comes installed with 10.3, so you should just enable it by uncommenting the relevant lines.
Use the Terminal:

Go to the config directory:
Code:
cd /etc/httpd/

Authorize as admin user (sudoer):
Code:
sudo -s
Enter your password.

Make a backup of the config file:
Code:
cp httpd.conf httpd.conf.backup

Open the config file in pico:
Code:
pico httpd.conf

Search for the php lines by hitting control+w and entering php. Remove the # in this line:

Code:
#LoadModule php4_module        libexec/httpd/libphp4.so

Hit control+w again and search for mod_php4.c .
Uncomment that line as well:

Code:
#AddModule mod_php4.c

Now exit pico by hitting control+x, then answering 'y' and hitting enter.
Restart apache with this command:

Code:
apachectl graceful

Eventually run the command with sudo in front of it if you're not already authorized as root or sudoer, i.e.

Code:
sudo apachectl graceful

PHP should work :)
 
i did what dlloyd said because i allready had entropy installed :)

but it kindof worked but didnt.

i went made a phpinfo(); page and put it in the user sites, so http://localhost/~jon/test.php would of been the address and it worked.

so i then put one in the server root (where al my site files where before the reinstall) so its http://localhost/test.php and it doesnt work. and i get forbidden errors in php index files :s
 
Ok, I'm going out on a limb here, because I'm not sure about it.
I think you've probably not got the right permissions on the server root directory. Try repairing permissions using Disk Utility and then do ls -lad /Library/WebServer/Documents from the Terminal and tell me the result. (Note that this quite possibly could have been caused by Software Update; always repair permissions after running it)
 
disk util is saying...

"symbolic link ./Library/WebServer/Documents/manual repaird
Filesystems/cd9660.fs/cd9600.util. New permisions are 33261
Group differs on /.private/var/log/install.log, should be 80, group is 0
Owner and group corrected on /.private/var/log/install.log
Permisions corrected on ./private/var/log/install.log
The privileges have been verified or repaired..."


terminal sais

drwxrwxr-x 7 root admin 238 5 May 23:44 /Library/Webserver/Documents


seeing as this is a clean install of osx. were the permisions corrupted when i installed php? and why does this happen?

[edit] still forbidden :(
 
Run Repair Permissions until it reports no more errors.

The terminal output looks right, but I'm betting that error from DU is too coincidental to not mean something. Anyway, since it's a clean install and you've just been running Software Update a lot, I expect it has something to do with all the updates you've installed.
 
i just played with the file permisions. i changed the documents to owner of me and that didnt work. i then changed test.php to owner me, access read write, group admin read write and otheres read only (otheres was no access)

and it loads! so thats our problem :) how do we fix it :)

ill run disk util as well now...
 
Oh how STUPID OF ME! :D
I had that problem on my web server the other week and Support said to make PHP file permissions 775 or greater. I can't believe I didn't connect that! So yeah, for PHP files, access for the 'others' group needs to be Read Only or better. Technically everyone needs to have Execute access for PHP files to work, but for some reason the Finder doesn't have an option for that.
 
Yay, I found how to do it!
Open your httpd.conf file again and find the line that starts DocumentRoot
Change this to whatever you want the server to go to when you type its address and then restart apache using sudo apachectl graceful
 
um. theres many lines in that file lol and how do i make it do things like this? im new to mac and unix :eek: (i only know file permisions for ftp)

[edit]

would this have happened because i copied all the files to a xp box?
 
Ooops, sorry, I got this thread mixed up with another about the same subject that I'm also helping with.

No, I don't think it has anything to do with the XP copying.

So, to do what I said before:
1) Open the Terminal and type sudo pico /etc/httpd/httpd.conf
2) Scroll down until you see a line that reads DocumentRoot "/Library/Webserver/Documents/" (in my file that was about 21 and a half page-downs; I had to press ctrl+V 21 times and then the down arrow a few times)
3) Change that to DocumentRoot "/Users/[your username]/Sites/"
4) Press ctrl+X (to exit) and when asked to save type Y (to write changes) and then press Enter (to accept the file name).
5) Restart the Apache server by typing sudo apachectl graceful

That changed the place Apache looks for files when you go to [computername].local, or your computer's IP address or anything, from /Library/WebServer/Documents to your sites directory.
 
also another problem.

the way my site loads the pages is like this

Code:
www.blablabla.com/index.php?page=products

and i use

Code:
if($page=="products"){ include "products.php"; }

but on my ibook, it thinkgs $page is blank. but if i upload to the server it works as expected
 
Ah ha, that's because register Globals is off. You can read more about that here: http://php.benscom.com/manual/en/security.registerglobals.php

There are two ways to fix that, either you retrieve the $page variable first by doing $page = $_GET['$page']; (best) or you can turn on the register Globals option.

To turn it on:
1) Open /usr/local/php/lib/php.ini in pico using the same procedure as above (Open the Terminal and type sudo pico/usr/local/php/lib/php.ini)
2) Scroll down until you see a line that starts register_globals (very close to the top). Change where it says Off to On.
3) Press ctrl+X (to exit) and when asked to save type Y (to write changes) and then press Enter (to accept the file name).
4) Restart the Apache server by typing sudo apachectl graceful
 
thanks. i used the proper php code :) your way didnt work but in teh php.ini it said

"instead of using $foo, you mus use $_REQUEST["foo"];"

you were very helpfull thanks! everythings fixed :D
 
Back
Top