LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-24-2010, 03:10 PM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Unhappy Unable to view php pages in LAMP


Dear All,

I am trying to configure LAMP stack on RHEL 5.0 with the help of this article.

These are the versions I am using.
- Apache 1.3.42 from http://apache.oregonstate.edu/httpd/..._1.3.42.tar.gz
- PHP 5.2.13 http://www.php.net/downloads.php
- MYSQL 5.0.90 http://www.sfr-fresh.com/unix/misc/mysql-5.0.90.tar.gz/

I have configured and installed as per directions successfully, but I am unable to view PHP or HTML webpages. Seems like I am missing some small thing.

These are the details of my LAMP Stack. I have attached my httpd.conf hereby.

Code:
[root@server bin]# hostname
server.red.com

[root@server bin]# grep -v ^# /etc/hosts
192.168.1.10    server.red.com
127.0.0.1       server.red.com server localhost.localdomain localhost 192.168.1.10
::1             localhost6.localdomain6 localhost6

[root@server htdocs]# cat /usr/local/apache/htdocs/index.php
<?php
phpinfo();
?>
When, I am trying to view file in Mozilla or IE, it is prompting me to "save to disk" or "open with" options.

Have I missed out anything. Please HELP. Thanks in advance.
Attached Files
File Type: txt httpd.txt (33.9 KB, 26 views)
 
Old 04-24-2010, 04:36 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You miss:
Code:
LoadModule php5_module  libexec/libphp5.so
You should remove .htm and .html from:
Quote:
AddType application/x-httpd-php .php .htm .html
because you don't need to parse them as php scripts.

Regards
 
Old 04-25-2010, 12:56 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Dear Bathory,

Thanks for your precious time. I did as per your instruction, I get following error
Code:
[root@server bin]# ./apachectl restart
./apachectl restart: httpd not running, trying to start
Syntax error on line 223 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp5.so into server: /usr/local/apache/libexec/libphp5.so: cannot open shared object file: No such file or directory
./apachectl restart: httpd could not be started
The problem is that I dont have this file
Code:
[root@server libexec]# ls -lrth /usr/local/apache/libexec/libphp5.so
ls: /usr/local/apache/libexec/libphp5.so: No such file or directory
I tried google on this, as per this link, I found these three lines are necessary in /usr/local/apache/conf/httpd.conf
Code:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
AddModule mod_php5.c
I have put all the three manually lines in my /usr/local/apache/conf/httpd.conf
Code:
[root@server libexec]# grep "LoadModule php5"  /usr/local/apache/conf/httpd.conf
LoadModule php5_module        libexec/libphp5.so
[root@server libexec]#
[root@server libexec]# grep "AddHandler php5"  /usr/local/apache/conf/httpd.conf
    AddHandler php5-script php
[root@server libexec]#
[root@server libexec]# grep "AddModule mod_php5.c"  /usr/local/apache/conf/httpd.conf
AddModule mod_php5.c
Now, I believe I have missed out something while compiling php.
I compiled php with these options
Code:
./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--disable-debug \
--enable-ftp \
--enable-inline-optimization \
--enable-magic-quotes \
--enable-mbstring \
--enable-mm=shared \
--enable-safe-mode \
--enable-track-vars \
--enable-trans-sid \
--enable-wddx=shared \
--enable-xml \
--with-dom \
--with-gd \
--with-gettext \
--with-mysql=/usr/local/mysql \
--with-regex=system \
--with-xml \
--with-zlib-dir=/usr/lib
and got the below message after the ./configure stopped executing.
Code:
Thank you for using PHP.

Notice: Following unknown configure options were used:

--enable-mm=shared
--enable-track-vars
--enable-trans-sid
--with-dom
--with-xml
 
Old 04-25-2010, 01:08 AM   #4
EmmaMadeleineMcDonald
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
nice vikas
 
Old 04-25-2010, 01:12 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Smile Got some success

Dear Bathory,

Just another update. I just compiled PHP again, and now things are somewhat working for me.

Now, I am unable to open index.php (again getting the same dialog box with "save to disk" or "open with" options.
BUT able to open index.html (or index.htm) which has php codes in it.



Please see the below output.
Code:
[root@server htdocs]# curl "http://server.red.com/index.php"
<?php
phpinfo();
?>

<? print(Date("l F d, Y")); ?>
[root@server htdocs]#


[root@server htdocs]# curl "http://server.red.com/index.html"
<html>

<head>
<title>Example #1 TDavid's Very First PHP Script ever!</title>
</head>
HELLO WORLD
Sunday April 25, 2010
<body>
</body>
</html>
[root@server htdocs]#



[root@server htdocs]# curl "http://server.red.com/index.htm"
<html>

<head>
<title>Example #1 TDavid's Very First PHP Script ever!</title>
</head>
HELLO WORLD
Sunday April 25, 2010
<body>
</body>
</html>
[root@server htdocs]#

Contents of index.html and index.php are :
Code:
[root@server htdocs]# cat index.php
<?php
phpinfo();
?>

<? print(Date("l F d, Y")); ?>
[root@server htdocs]#


[root@server htdocs]# cat index.html
<html>

<head>
<title>Example #1 TDavid's Very First PHP Script ever!</title>
</head>
HELLO WORLD
<? print(Date("l F d, Y")); ?>

<body>
</body>
</html>
[root@server htdocs]#
I believe my apache is not recognizing .php pages but is able to execute php codes in .html pages. I am attaching my new httpd.conf hereby.
Attached Files
File Type: txt httpd.txt (34.0 KB, 19 views)

Last edited by vikas027; 04-25-2010 at 01:17 AM. Reason: Forgot the attachement
 
Old 04-25-2010, 01:13 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Unhappy

Quote:
Originally Posted by EmmaMadeleineMcDonald View Post
nice vikas
What is nice about me Emma, I still can not run .php pages.
 
Old 04-25-2010, 03:52 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Here are some things to look after:
1. You don't need the "AddModule mod_php5.c" as the php module is compiled as a DSO.
2. I've already told you to remove .htm .html from the "AddType..." directive. You don't want to parse html as php
3. The AddHandler is not really needed
4. Take a look at the apache error_log
5. If you want to use php code in a html page, you have to give the .php extension to the page. Now it works because of the #2 above, but it's not correct.

BTW, why do you want to use apache 1.3.x and not apache 2.2.x?

Regards
 
1 members found this post helpful.
Old 04-25-2010, 04:18 AM   #8
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by bathory View Post
BTW, why do you want to use apache 1.3.x and not apache 2.2.x?
Regards
Fine, I think it would be better to compile first compile apache (v 2.2.15) and then php again.

I will post results here soon.
 
Old 04-25-2010, 08:57 AM   #9
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Thumbs up Cheers

Dear Bathory,

Finally, it worked for me. I believe the problem was due to package versions inter-operability.

I owe you a beer mug
My sincere thanks to you to help me get this working.
Now, I will try mysql connectivity with PHP and try to build a test website using php pages.

For other poor chaps like me who are having problems with LAMP, this might help them.

Quote:
Packages Required
- Apache 2.2.15 http://httpd.apache.org/download.cgi#apache22
- PHP 5.2.13 http://www.php.net/downloads.php
- MYSQL 5.0.90 http://www.sfr-fresh.com/unix/misc/mysql-5.0.90.tar.gz/

Useful Link -- http://www.lamphowto.com/

My working httpd.conf attached hereby.
Attached Files
File Type: txt httpd.conf.txt (13.2 KB, 47 views)

Last edited by vikas027; 04-25-2010 at 08:59 AM. Reason: forgot somethig to write
 
Old 04-25-2010, 10:24 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Glad to see it worked!

Quote:
Finally, it worked for me. I believe the problem was due to package versions inter-operability.
I don't think it was a version inter-operability problem. I was able to build apache 1.3.x with php5 support in the past without problems. I think it was something in the configuration that we overlooked (probably the AddHandler directive because the rest is needed).

Thx for the beer.
Cheers
 
Old 04-26-2010, 12:03 AM   #11
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Wink

Quote:
Originally Posted by bathory View Post
Glad to see it worked!

I don't think it was a version inter-operability problem.
Might be, still I am glad I am using the latest version of the http
 
  


Reply



Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't view the .php web pages nkd Fedora 8 04-23-2008 12:57 AM
PHP pages are displayed as blank pages Hirszu Linux - Software 6 03-03-2008 12:09 AM
How can I view php pages in Konqueror? yoshitec Mandriva 2 09-11-2004 12:03 PM
can't view php pages allan_y Linux - Software 2 07-23-2004 11:48 PM
[PHP] How do I view PHP pages?? vbp6us Linux - General 4 04-16-2003 06:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration