| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
12-09-2009, 03:00 AM
|
#1
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Rep:
|
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...
Last edited by deostroll; 12-09-2009 at 03:03 AM.
Reason: added more info.
|
|
|
|
12-09-2009, 03:12 AM
|
#2
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
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
cat /etc/httpd/conf.d/php.conf
|
|
|
|
12-09-2009, 03:28 AM
|
#3
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
Here is the output of both commands:
Code:
$ rpm -qi php
The php package contains the module which adds support for the PHP
language to Apache HTTP Server.
Name : php Relocations: (not relocatable)
Version : 5.1.6 Vendor: CentOS
Release : 23.2.el5_3 Build Date: Tue 07 Apr 2009 05:34:02 PM IST
Install Date: Mon 25 May 2009 06:53:19 PM IST Build Host: builder10.centos.org
Group : Development/Languages Source RPM: php-5.1.6-23.2.el5_3.src.rpm
Size : 3017223 License: The PHP License v3.01
Signature : DSA/SHA1, Tue 07 Apr 2009 05:50:04 PM IST, Key ID a8a447dce8562897
URL : http://www.php.net/
Summary : The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
Description :
PHP is an HTML-embedded scripting language. PHP attempts to make it
easy for developers to write dynamically generated webpages. PHP also
offers built-in database integration for several commercial and
non-commercial database management systems, so writing a
database-enabled webpage with PHP is fairly simple. The most common
use of PHP coding is probably as a replacement for CGI scripts.
The php package contains the module which adds support for the PHP
language to Apache HTTP Server.
Code:
$ cat /etc/httpd/conf.d/php.conf
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
Yet I am not getting the php page served...don't know if the php code is incorrect either...pasting the code here for reference:
PHP Code:
<html>
<body>
<?php phpinfo(); ?>
</body>
</html>
|
|
|
|
12-09-2009, 03:29 AM
|
#4
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
This should do, test.php with the following in it
Code:
<?php
phpinfo();
?>
|
|
|
|
12-09-2009, 03:51 AM
|
#5
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
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...
|
|
|
|
12-09-2009, 03:55 AM
|
#6
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
Code:
tail /var/log/httpd/access_log /var/log/httpd/error_log
|
|
|
|
12-09-2009, 05:12 AM
|
#7
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
Code:
$ tail /var/log/httpd/access_log /var/log/httpd/error_log
==> /var/log/httpd/access_log <==
::1 - - [09/Dec/2009:12:15:35 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:21:45 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:21:47 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:21:48 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:21:49 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:24:53 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:12:26:12 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:04:57:09 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:04:58:08 -0500] "GET /test/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
::1 - - [09/Dec/2009:06:18:51 -0500] "GET /favicon.ico HTTP/1.1" 404 294 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042718 CentOS/3.0.10-1.el5.centos Firefox/3.0.10"
==> /var/log/httpd/error_log <==
[Wed Dec 09 12:26:12 2009] [error] [client ::1] PHP Warning: Unknown: Failed opening '/var/www/html/test/index.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
[Wed Dec 09 04:57:09 2009] [error] an unknown filter was not added: PHP
[Wed Dec 09 04:57:09 2009] [error] an unknown filter was not added: PHP
[Wed Dec 09 04:57:09 2009] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
[Wed Dec 09 04:57:09 2009] [error] [client ::1] PHP Warning: Unknown: Failed opening '/var/www/html/test/index.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
[Wed Dec 09 04:58:08 2009] [error] an unknown filter was not added: PHP
[Wed Dec 09 04:58:08 2009] [error] an unknown filter was not added: PHP
[Wed Dec 09 04:58:08 2009] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
[Wed Dec 09 04:58:08 2009] [error] [client ::1] PHP Warning: Unknown: Failed opening '/var/www/html/test/index.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
[Wed Dec 09 06:18:51 2009] [error] [client ::1] File does not exist: /var/www/html/favicon.ico
|
|
|
|
12-09-2009, 05:16 AM
|
#8
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
There is a permissions issue, i am guessing selinux what is the output of sestatus ?
|
|
|
|
12-09-2009, 08:04 AM
|
#9
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
don't understand what is selinux in the context?
|
|
|
|
12-09-2009, 08:05 AM
|
#10
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
You want help supply the output of
|
|
|
|
12-09-2009, 08:17 AM
|
#11
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
Code:
$ sestatus
SELinux status: disabled
|
|
|
|
12-09-2009, 08:20 AM
|
#12
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
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
[Wed Dec 09 04:57:09 2009] [error] [client ::1] PHP Warning: Unknown: Failed opening '/var/www/html/test/index.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
[Wed Dec 09 04:58:08 2009] [error] an unknown filter was not added: PHP
Check the file and directory ownership
Code:
ls -l /var/www/html
ls -l /var/www/html/test/
|
|
|
|
12-09-2009, 08:27 AM
|
#13
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
Code:
$ ls -l /var/www/html
total 12
drwxr-xr-x 2 root root 4096 Dec 9 15:27 test
$ ls -l /var/www/html/test
total 12
-rw------- 1 root root 55 Dec 9 15:27 index.php
-rw------- 1 root root 57 Dec 9 15:26 index.php~
-rwxr-xr-x 1 root root 20 Dec 9 04:08 test.html
-rw------- 1 root root 0 Dec 9 04:07 test.html~
$
|
|
|
|
12-09-2009, 09:24 AM
|
#14
|
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
The permissions are incorrect fix them using
Code:
chmod a+r /var/www/html/test/index.php
|
|
|
|
12-10-2009, 05:06 AM
|
#15
|
|
Member
Registered: Aug 2007
Location: Chennai
Distribution: ubuntu
Posts: 111
Original Poster
Rep:
|
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?!!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:29 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|