Click to See Complete Forum and Search --> : aargh! RH 8, Apache, PHP4 problems


xyzzy
12-16-2002, 10:30 PM
Aargh, I'm having trouble installing Apache 1.3.27, PHP 4 and MySQL on a RedHat 8 box. I followed the instructions on the NHF on this site, but I get this error when I run the phpinfo program.

Warning: Failed opening '/usr/local/apache/htdocs/test.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0

Help?

theN
12-17-2002, 05:46 AM
* Were these installed from source?
* Do each of the software run fine on its own?
i.e. does apache / mysql run fine on its own
* Was PHP statically compiled or is it dynamically loaded?
if dynamically loaded, are there any references to it in the Apache httpd.conf file like LoadModule libphp4.so or similar text.
* Type ./apachectl in Apache's bin directory and look up the option used to check the validity of httpd.conf file. IIRC its either ./apachectl -t or ./apachectl -l. Sorry can't remember the correct one. Check the validity of httpd.conf file.
...when I run the phpinfo program...
the contents of a working phpinfo script needs to contain only this -

/*file name: phpinfo.php*/
<?php phpinfo(); ?>

I'm can't hazard a guess about the error from what you've posted, but the phpinfo.php script works on its own. It should not "include" files as indicated in your warning Warning: Failed opening '/usr/local/apache/htdocs/test.php' for inclusion.
I know the above may not be of much help. I guess a more pointed question from you would have got the attention of the gurus. Now you only got a novice like me :)

Regards
theN

xyzzy
12-17-2002, 10:29 AM
Originally posted by theN
* Were these installed from source?
* Do each of the software run fine on its own?
i.e. does apache / mysql run fine on its own
* Was PHP statically compiled or is it dynamically loaded?
if dynamically loaded, are there any references to it in the Apache httpd.conf file like LoadModule libphp4.so or similar text.
* Type [b]./apachectl in Apache's bin directory and look up the option used to check the validity of httpd.conf file. IIRC its either ./apachectl -t or ./apachectl -l. Sorry can't remember the correct one. Check the validity of httpd.conf file.

* PHP and Apache were compiled from source, and for MySQL I used RPMs.

* I'm not certain I understand how to tell if PHP was statically compiled or dynamically loaded.

* It's apachectl configtest, and it came back with Syntax OK.

I copied and pasted the phpinfo script from your message into phpinfo.php, and I get the same error.

Thanks,

xyzzy

theN
12-17-2002, 04:43 PM
PHP and Apache were compiled from source, and for MySQL I used RPMs.
Forget about MySQL for the time being.
- Could you briefly describe how you compiled Apache and PHP?
- What steps did you take to make Apache and PHP to work together?
- Did you follow the respective manuals for installation from source.
I'm not certain I understand how to tell if PHP was statically compiled or dynamically loaded.
-- If PHP was **statically** compiled, then ./apachectl -l would show something like mod_php.c in the output.
-- If PHP was compiled as a **dynamic module**, then your /apache/modules directory would have a file like libphp4.so and your httpd.conf file would have a line like LoadModule php4_module modules/libphp4.so.
Warning: Failed opening '/usr/local/apache/htdocs/test.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0
In your php.ini file try commenting out the "include_path" settings i.e. put a ; at the beginning of the line.
- is there a test.php file in /usr/local/php/lib?

This is all I can think of for the time being. Sorry for not being of any more help.

Regards
theN

xyzzy
12-17-2002, 09:27 PM
Originally posted by theN
Forget about MySQL for the time being.
- Could you briefly describe how you compiled Apache and PHP?
- What steps did you take to make Apache and PHP to work together?
- Did you follow the respective manuals for installation from source.

-- If PHP was **statically** compiled, then ./apachectl -l would show something like mod_php.c in the output.
-- If PHP was compiled as a **dynamic module**, then your /apache/modules directory would have a file like libphp4.so and your httpd.conf file would have a line like LoadModule php4_module modules/libphp4.so.

I

I followed the instructions here, except I used PHP4: http://www.linuxnewbie.org/nhf/Webservers/PHP_and_Apache_Intro.html

apachectl -l comes back as a nonvalid option, and I have no apache/modules directory. Thanks for your help!

theN
12-18-2002, 03:42 AM
I screwed up big time :(

I misread a part of the original post and hence most of my questions were relevant only for Apache2.0.xx not the Apache1.3.xx. Please accept my apologies. and I deeply regret any inconvenience caused by this lapse.

I'm at a loss for ideas. Hope the following links can offer some clues.

- http://www.php.net/manual/en/install.linux.php
- http://www.php.net/manual/en/install.apache.php#install.apache.unix
- http://www.php.net/manual/en/install.configure.php
- http://httpd.apache.org/docs/misc/tutorials.html
- http://www.onlamp.com/pub/a/php/2000/11/17/php_admin.html
- http://www.onlamp.com/pub/a/php/2001/04/26/php_admin.html

Regards
theN

xyzzy
12-18-2002, 11:21 AM
Originally posted by theN
I screwed up big time :(

I misread a part of the original post and hence most of my questions were relevant only for Apache2.0.xx not the Apache1.3.xx. Please accept my apologies. and I deeply regret any inconvenience caused by this lapse.

I'm at a loss for ideas. Hope the following links can offer some clues.

- http://www.php.net/manual/en/install.linux.php
- http://www.php.net/manual/en/install.apache.php#install.apache.unix
- http://www.php.net/manual/en/install.configure.php
- http://httpd.apache.org/docs/misc/tutorials.html
- http://www.onlamp.com/pub/a/php/2000/11/17/php_admin.html
- http://www.onlamp.com/pub/a/php/2001/04/26/php_admin.html

Regards
theN

No problem! :) Do you think things would work easier/better if I used Apache2 instead of Apache 1.3.x?

xyzzy

theN
12-18-2002, 04:10 PM
IMHO yes.

I'm a total newbie myself. I had absolutely no hassle installing Apache2.0.43+PHP4.2.3+MySQL3.23.53a from source. The combo works like a charm.

PHP website recommends that you not use Apache2.0.43 on a live/production server. So if you are like me, learning on the localhost then Apache2 is fine.

I do have a suggestion though, please follow the respective manuals rather than instruction at any other site.

Precis of my installation sequence
-----------------------------------------
STEP1.
a)
Apache configuration & installation. You need to be root to install in the recommended folder i.e. /usr/local/apache2

cd apache_src_dir
./configure --prefix=/usr/local/apache2 \
--enable-so \
--enable-log_config \
--enable-rewrite \
--enable-speling

--enable-so is the key. It allows for dynamic loading of modules of other software like PHP etc.
You can optionally execute ./configure --help >> apacheconfig.txt before you do the actual ./configure --prefix thing. You can then read this .txt file for all the available config options.
b)
make
c)
make install

Now test apache2. Go to /usr/local/apache2/bin folder and then
./apachectl -k start
open http://localhost or http://127.0.0.1 in browser and check for the default page.

STEP2.
To configure MySQL, just follow all the steps listed at 2.3.1 Quick Installation Overview (http://www.mysql.com/documentation/mysql/bychapter/manual_Installing.html#Installing_source). I didn't do the groupadd and useradd thing and I'm yet to face any problems( ;) not that I won't in the future). I would suggest you could follow manual though.

TEST BOTH APACHE AND MYSQL BEFORE YOU PROCEED TO STEP3

STEP3.
a)
PHP configuration and installation. Default path is /usr/local/php and you need to be the root to do this. Please look at Complete PGP config options (http://www.php.net/manual/en/install.configure.php).

cd php-source_dir
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql


afaik --with-apxs2 means that PHP will be dynamically loaded by Apache as and when required.
b)
make
c)
make install
-----------------------------------------
Now take a look in /usr/local/apache2/modules folder for libphp4.so and in your Apache httpd.conf for LoadModule php4_module modules/libphp4.so. If you see them then the installation went fine. You can test it further by putting the phpinfo.php file in /usr/local/apache2/htdocs.


HTH
theN
ps: let us know how things go.

xyzzy
12-21-2002, 05:17 PM
OK. I followed your instructions, and everything went smoothly. The "LoadModule" is in my httpd.conf, and libphp4.so is in the modules folder. But, when I try to load the phpinfo() script, Apache returns the file as plaintext, i.e., I see the source of test.php. Any suggestions?

Thanks for your help!

theN
12-22-2002, 12:31 AM
Originally posted by xyzzy
But, when I try to load the phpinfo() script, Apache returns the file as plaintext, i.e., I see the source of test.php. Any suggestions? Thanks for your help!
Glad to know that things went ok. Sorry I forgot to say the following before.

Apache, at this jucture, does not know which application to use to render *.php files(even though the PHP modules is loaded) as there's no entry for php in the /conf/mime.types file. Don't touch the mime.types file, the above was just a FYI.

All you need to do now is tell Apache about the *.php file handler. You do that by **adding** the following line to the AddType section of httpd.conf -
AddType application/x-httpd-php .php

<clue>
Search for following text in httpd.conf "AddType allows you to override the MIME configuration file...". If the AddType application/x-httpd-php .php line is already there, then uncomment it. If it isn't, then just append the above line to the AddType section.
</clue>

Please do read the respective manuals a couple of times. It makes life a lot easier.

HTH
theN

xyzzy
12-29-2002, 03:54 PM
OK, everything is working smoothly, and I have read through the manuals. However, when I tried to install phpBB and InvisionBoard, they are both unable to access their support files. They return error messages that the files do not exist, but I am able to see the files in the terminal. So, it seems that PHP/Apache is not able to access these files. Any suggestions? Thanks!