centos 5: config apache to execute php scripts/pages
most of my googling odysseies lead me to articles which talk about compiling apache & php from the source as this is touted to be more flexible. But the problem we have is this...we already have an apache 2 web server running. Now how do we serve php pages of it...
PS: i believe we even have php installed... |
If you already have php installed it should work out of the box, you do not need to do anything.
Check using Code:
rpm -qi php |
Here is the output of both commands:
Code:
$ rpm -qi php Code:
$ cat /etc/httpd/conf.d/php.conf PHP Code:
|
This should do, test.php with the following in it
Code:
<?php |
it still doesn't work...4got to mention wher i've kept my php file...
in /var/www/html/test folder I've created a page called index.php with the above code. In the browser I an typing http://localhost/test/index.php still nt giving me an output... |
Code:
tail /var/log/httpd/access_log /var/log/httpd/error_log |
Code:
$ tail /var/log/httpd/access_log /var/log/httpd/error_log |
There is a permissions issue, i am guessing selinux what is the output of sestatus ?
|
don't understand what is selinux in the context?
|
You want help supply the output of
Code:
sestatus |
Code:
$ sestatus |
Thats very wierd given the errors
Code:
[Wed Dec 09 04:57:09 2009] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Code:
ls -l /var/www/html |
Code:
$ ls -l /var/www/html |
The permissions are incorrect fix them using
Code:
chmod a+r /var/www/html/test/index.php |
Thanx tht worked!!!
Don't understand those permissions I've to set tho. Are there any articles that can come in handy? Isn't there a more direct way? I mean I am looking at directly creating php files and expecting them to get deployed...straight. So those files should have the correct permissions...I don't want to create a file and then change its permission always...OR, is this how its done always?!! |
Okay, a quick explanation for you.
You created the file as root with read, write permissions for the owner (rw-------) The webserver is running as user apache, so is unable to read the file. The command i gave u changes the file permissions to be readable by the group and others (readable by anyone) |
All times are GMT -5. The time now is 11:01 AM. |