# PHP not running --> "Save to disk"

## rasat

Hi,

I have installed Apache, PHP and MySQL. I red through most of the solutions mentioned on this forum. I have problem to run a php file.

I made one file php_test.php containing "<? phpinfo() ?>" but instead of running the phpinfo one dialog box appears asking to "Save to disk". I have seen this problem before when using other Linux distros, but I forgot how to solve it by adding some comments to apache.conf..... or Gentoo requires something else?

Markku

----------

## ves

just add

AddType application/x-httpd-php .php

to httpd.conf, and restart apache.  That should take care of it.  Oh and make sure the apache module is loaded...run a ./httpd -l to see all loaded modules.  If PHP is compiled as a DSO, you'll have to have a LoadModule entry to load up the PHP DSO.

----------

## rasat

I don't have httpd.conf but /etc/apache/conf/apache.conf

In apache.conf I have the line

AddType application/x-httpd-php .php

When trying to run "httpd -l" the command is missing. What I did I copied it from my Red Hat partition...... ofcource this is not the way how its done.

When running httpd -l again, some libraries where missing..... again I copied from Red Hat hoping I could solve the "Save to disk" problem but it did not work.

rasat root # httpd -l

httpd: error while loading shared libraries: libdb-3.3.so: cannot open shared object file: No such file or directory

rasat root # httpd -l

httpd: error while loading shared libraries: libmm.so.11: cannot open shared object file: No such file or directory

After copying the libraries here is the result:

rasat root # httpd -l

Compiled-in modules:

  http_core.c

  mod_so.c

suexec: enabled; valid wrapper /usr/sbin/suexec

rasat root #

"Save to disk" is still appearing. It seems something is missing.

Markku

----------

## Clay

Do you have "-D PHP4" in your APACHE_OPTS in /etc/conf.d/apache ?

----------

## rasat

Yes, I do have.

APACHE_OPTS="-D SSL -D PHP4"

If I don't get php to work with gentoo ebuild package, I will go for tar ball for apache, php and mysql. I know its not a nice solution when gentoo's emerge -u world will not be upgrading them  in the future. Or maybe I should try first to reinstall. Is there any hint what I should do when reinstalling?

Markku

----------

## Trumpcard

I like what they are trying to do with the Apache/PHP configuration, but I like building with the Apache Toolbox alot better.

Go to www.apachetoolbox.com  and download his latest package.  Very handy, and he includes alot of the cool Apache addins and modules. Ive had alot of success with his work.

----------

## rasat

Hi,

I tried Apachetoolbox but all download sites have changed. Anyway, I am still interested to get apache + php + mysql to run with ebuild packages. I think I got everyhing correctly by adding USE="mysql php apache" and once installed run:

# ebuild /var/db/pkg/dev-lang/php-4.2.1-r1/php-4.2.1-r1.ebuild config

The "save/open" dialog box is still appearing but I found a comment on internet: 

"The reason the Apache is prompting you to save/open a php file is because haven't configured Apache to send a .php file to the PHP engine."

I seached for the php file but I only found it in my Red Hat partition /usr/bin/php

Any suggestion?

Markku

----------

## acidreign

You MUST restart apache,

Do not copy binaries from other distrobutions, this is not only a security risk, but also the libraries that it is linked to, you will need to copy.. hence undoing the purpose of it.. 

In short it all just gets messy.

Add the line as mentioned above, restart apache.. all will be well.

----------

## rasat

> Add the line as mentioned above, restart apache.. all will be well.

To restart apache is not the problem. I do it always after any change in apache.conf. What line did you refer to? Lines mentioned on this topic I have.

Markku

----------

## ves

i dont' know how gentoo or redhat sets things up, but you should have an httpd.conf.  That's the standard apache conf file.

----------

## Damasz

On gentoo the binary is called "apache" and the configuration file is "apache.conf". You can stop and start the program with either the apache script in /etc/init.d or with the /usr/sbin/apachectl program.

Do you have a LoadModule line for php4 in your apache.conf file?

What do your apache logfiles say? Are there any errors?

----------

## rasat

It creates confusion when replies are not related to Gentoo's apache+php+mysql. Myself, I also cleaned up all Red Hat files and libraries. And re-installed all three packages.

Apache and mysql works fine as usual but..... php askes for "save/open".

I am here describing what I did with php and apache

1) # emerge php

(apache, mysql and php were all installed automatically with the line USE="apache mysql php" in /etc/make.conf).

2) # ebuild /var/db/pkg/dev-lang/php-4.2.1-r1/php-4.2.1-r1.ebuild config

3) I enabled line APACHE_OPTS="-D SSL -D PHP4" in /etc/conf.d/apache

4) I added AddType application/x-httpd-php .php in /etc/Apache/conf/apache.conf

The following lines with php where automatically added to apache.conf  

*****************************

<IfDefine PHP4>

LoadModule php4_module    extramodules/libphp4.so

</IfDefine>

<IfDefine PHP4>

AddModule mod_php4.c

</IfDefine>

Include  conf/addon-modules/mod_php.conf

*****************************

5) # apachectl start

/var/log/apache/error_log

[Fri Jun 14 23:55:37 2002] [notice] Apache/1.3.24 (Unix) configured -- resuming normal operations

[Fri Jun 14 23:55:37 2002] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[Fri Jun 14 23:55:37 2002] [notice] Accept mutex: sysvsem (Default: sysvsem)

[Fri Jun 14 23:56:33 2002] [error] [client 127.0.0.1] File does not exist: /home/httpd/htdocs/favicon.ico

Did I miss anything or is the log error a problem?

By the way, did anyone succeed to get Gentoo's apache+php to work or did everone use tarballs?

Markku

----------

## ViceClown

Here's how I got it to work just this morning. Maybe I should submit a howto on this  :Smile: 

First added 'mysql' and 'php' to the make.conf file so that php would have mysql support compiled into it. You don't have to compile things in this order but this is how I did it...

emerge mysql

Everything went in fine and I added mysql to the rc startup script.

emerge apache

Again, compiled and merged fine, no problem.

emerge php

Compiled fine. Created  a /etc/apache/extramodules directory with libphp4.so in it. It also created /etc/apache/conf/addon-modules directory with mod_php.conf in it. That file contained all the mimetype settings.

So... I edited /etc/apache/conf/apache.conf as such:

In the LoadModule section I added at the end: 

'LoadModule php4_module      extramodules/libphp4.so'

In the AddModule section I added at the end:

'AddModule mod_php4.c'

Then at the end of the apache.conf file I added:

'Include /conf/addon-modules/mod_php.conf'

That took care of the mime settings.

After that just do a 'apachectl configtest'  to see if your syntax and stuff is ok. If it says ok just do 'apachectl restart' I did everything above in that order and everything works like a charm. Try that out.

----------

## rasat

Thanks for the step-by-step instruction. This was great. I got it to work.

Only difference what I did when "apachectl configtest" gave an error not finding the mod_php.conf, I edited the line.

    Include /etc/apache/conf/addon-modules/mod_php.conf

Markku

----------

## dju

just run this after emerge php mysql apache

ebuild /usr/portage/dev-lang/php/php-4.2.1-r1.ebuild config

 and restart apache

/etc/init.d/apache stop

/etc/init.d/apache start

[/code]

----------

## rasat

> ebuild /var/db/pkg/dev-lang/php-4.2.1-r1/php-4.2.1-r1.ebuild config

I did not run the command. Only followed the instructions of ViceClown to be sure to get php to work. To complete his instructions I have here described all the steps for a new apache/php/mysql user.

APACHE+MYSQL+PHP INSTRUCTIONS

1) Add 'mysql' and 'php' to the /etc/make.conf file (USE="mysql php")

Run in terminal....

2) emerge mysql

3) /usr/bin/mysql_install_db (to create database file in /var/lib/mysql)

4) emerge apache

5) emerge php

Check the /etc/apache/extramodules directory with libphp4.so in it.

Also check the /etc/apache/conf/addon-modules directory with mod_php.conf in it.

6) Check file /etc/hosts has hostname (this is my file):

127.0.0.1   localhost, rasat

7) Edit file /etc/apache/conf/apache.conf as such......

a) Enable ServerName localhost

b) In the LoadModule section add at the end:

LoadModule php4_module extramodules/libphp4.so

c) In the AddModule section add at the end:

AddModule mod_php4.c

d) At the end of the apache.conf file add:

Include /conf/addon-modules/mod_php.conf

Run in terminal....

8.) apachectl configtest (to see if your syntax is ok)

If it says mod_php.conf not found edit the line at the end in apache.conf:

Include /etc/apache/conf/addon-modules/mod_php.conf

9) apachectl restart 

10) To boot startup mysql and apache, at the end of file /etc/conf.d/local.start add:

apachectl start

/etc/init.d/mysql start

Markku

----------

