# [SOLVED] Apache is not parsing php files

## dnamroud

I emerged php with mysql and GD support:

# USE="-* mysql gd" emerge php mod_php

I added "-D PHP4 to APACHE_OPTS in my /etc/conf.d/apache

# /etc/init.d/apache restart

#ps ax | grep apache

 *Quote:*   

> 
> 
> 24363 ?        Ss     0:00 /usr/sbin/apache2 -k start -D SSL -D PHP4
> 
> 24369 ?        S      0:00 /usr/sbin/apache2 -k start -D SSL -D PHP4
> ...

 

emerge -s php shows the following

 *Quote:*   

> 
> 
> dev-php/mod_php
> 
>       Latest version available: 4.4.0-r9
> ...

 

At the end I am seeing the PHP source instead of the result of the parsed script...

How can I fix this problem

Thank you

DanyLast edited by dnamroud on Tue Nov 29, 2005 4:21 pm; edited 1 time in total

----------

## karneevor

I think you did the right thing.

Did you put index.php in the config file? (I'm not sure if thats nessesary).

What does your apache log tell you?

----------

## irf2003

u need to add an apache handler for php,  so that the web server (apache) will parse the file for any php code (google for apache handler)

in short you can make apache parse any file for php or any other embeded code, by adding handlers depending on the extension of the file

HTH

----------

## dnamroud

There is no error in my apache log file

 *Quote:*   

> 
> 
> [Mon Nov 21 15:48:17 2005] [notice] caught SIGTERM, shutting down
> 
> [Mon Nov 21 15:48:20 2005] [notice] Digest: generating secret for digest authentication ...
> ...

 

I did adde the following line into my apache conf file: AddHandler php-script .php

after restarting my apache, nothing happened... Am i missing something or is it right what I did??

Thank you

Dany

----------

## magic919

The equivalent files on mine are apache2.  Even the opts bit says APACHE2_OPTS="-D DEFAULT_VHOST -D PHP4"  Do you have older Apache files from <v2.

----------

## dnamroud

the only version that i have is APache2..

Do i need to change my APACHE_OPTS to APACHE2_OPTS?

Thank you

Dany

----------

## magic919

You know I really don't understand this.  I've got a couple of Gentoo machines with Apache and they have files in directories called Apache2.  Mine uses APACHE2_OPTS and I think you should give it a try.  Mine is called /etc/conf.d/apache2, of course.

----------

## dnamroud

I did a mistake in my previous update,

I also had APACHE2_OPTS and the the conf file is /etc/conf.d/apache2

I did more research and I found this link: http://ca3.php.net/manual/en/install.unix.gentoo.php

It didn`t help me enough..

I installed mysql on other systems using the same way and it worked fine... I don't know whatis the problem with this one...

Thank you

----------

## rafiosso

Are You sure, You have the following line in httpd.conf?

```

LoadModule php4_module            modules/libphp4.so
```

I hadn't   :Very Happy: 

----------

## allex87

You need to install mod_php, not just php in order to use php with Apache2...

----------

## magic919

According to the emerge info on his very first post mod_php is installed.

----------

## dnamroud

Hello

I checked my configuration file and i realized that someone changed the modules files loaded from /etc/apache2/modules.d to /etc/apache2.conf.modules.d after copying the following conf file to thr right directory: /etc/apache2/conf/modules.d:

 *Quote:*   

> 
> 
> <IfDefine PHP4>
> 
>         # Load the module first
> ...

 

Reatarting the apache2 I got the following error:

 *Quote:*   

> 
> 
> #/etc/init.d/apache2 restart
> 
>  * Stopping apache2 ...
> ...

 

If I remark the last line : AddDirectoryIndex index.php index.phtml and after restarting Apache, I still have the same error, apache is not parsing any php file...

thank you

Dany

----------

## magic919

Some of these files moved with a recent Apache upgrade.  I don't think you have all the files in the right place.  Look in httpd.conf and you'll see where it expects the modules .conf file to be.  Mine says 

Include /etc/apache2/modules.d/*.conf

----------

## pjp

Moved from Portage & Programming

----------

## dnamroud

According to my /etc/apache2/conf/apache2.conf all modules are loaded from /conf/modules.d/*.conf

my 70_mod_php.conf is already there inside this directory...

At this time I have Apache 2.0.52-r1 installed...

/etc/apache2/httpd.conf not found

Thank you

Dany

----------

## magic919

Could you do apache2 -V

----------

## dnamroud

# apache2 -V

Server version: Apache/2.0.52

Server built:   Apr  7 2005 08:38:23

Server's Module Magic Number: 20020903:9

Architecture:   32-bit

Server compiled with....

 -D APACHE_MPM_DIR="server/mpm/prefork"

 -D APR_HAS_SENDFILE

 -D APR_HAS_MMAP

 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)

 -D APR_USE_SYSVSEM_SERIALIZE

 -D APR_USE_PTHREAD_SERIALIZE

 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT

 -D APR_HAS_OTHER_CHILD

 -D AP_HAVE_RELIABLE_PIPED_LOGS

 -D HTTPD_ROOT="/usr"

 -D SUEXEC_BIN="/usr/sbin/suexec2"

 -D DEFAULT_PIDLOG="/var/run/httpd.pid"

 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"

 -D DEFAULT_LOCKFILE="/var/run/accept.lock"

 -D DEFAULT_ERRORLOG="logs/error_log"

 -D AP_TYPES_CONFIG_FILE="/etc/apache2/conf/mime.types"

 -D SERVER_CONFIG_FILE="/etc/apache2/conf/apache2.conf"

----------

## dnamroud

The problem is fixed

what i did was simple:

from a shell  i run: #php -f /var/www/localhost/htdocs/test.php    and It worked fine 

so i cleared the buffer of my web browser again ( Idid it before many times but it didn't work)

and it works fine... 

finally I can open it in my browser...

Thank you guys for your help

Dany Namroud

----------

## macguyver

Hi, guys (and girls), it's my first post in here.

Sorry for posting in a "solved" topic, but it's such a close problem, hopefully someone will read this =)

My problem is almost the same from the poster, except I am running Apache 1.3.33 and PHP 5.0.5.

The confs are correct, I do have -D PHP5 on conf.d/apache, my server string is as follows:

Apache/1.3.33 (Unix) (Gentoo/Linux) PHP/5.0.5-pl3-gentoo mod_perl/1.27 mod_gzip/1.3.26.1a

When I request a PHP file through links2 (so, no browser cache) it asks wether I want to display or save a file in the format application/x-httpd-php (so, the php config file inside modules.d/ is indeed being parsed).

However, when I choose to display it, all I get is the source code of the file, as plain text.

The config files have all the relevant entries to work, including LoadModule, AddHandler, AddType, AddDirectoryIndex, etc., but nothing happens at all. No error on Apache log, either.

Oh, and I emerged dev-lang/php, and not mod_php (don't remember where in the tree is it)

You should see more information about my server in here:

http://linuxsbo.com:8000/server-info

and my config files in here (if it falls back to port 80, just try again on port 8000):

http://linuxsbo.com:8000/conf/

I don't know if I need to provide more information, I am quite new to the Gentoo model, so I hope it's enough.

-- 

editing:

I forgot, here's a file which is supposed to be parsed, in case anyone wants to test:

http://linuxsbo.com:8000/phpinfo.php

-- 

Thanks, in advance

----------

## dnamroud

Hello,

I had the same problem and the solution was simple, but it took a long time to be solved....

1- Try to upgrade your apache version

2- check this website (maybe you did it already)

http://ca3.php.net/manual/en/install.unix.gentoo.php

 *Quote:*   

> 
> 
> Common Problems
> 
> If you see the PHP source instead of the result the script should produce, you have probably forgot to edit /etc/conf.d/apache. Apache needs to be started with the -D PHP4 flag. To see if the flag is present, you should be able to see it when using ps ax | grep apache while Apache is running. 
> ...

 

----------

## macguyver

 *dnamroud wrote:*   

> Hello,
> 
> I had the same problem and the solution was simple, but it took a long time to be solved....
> 
> 1- Try to upgrade your apache version
> ...

 

I tried everything in this thread, nothing seems to work =(

1- Well, I have 1.3.33-r12, that's the highest you can go in apache1 slot, and as I don't feel like installing apache2, I may try downgrading... Who knows? =)

2- Yes I did, that's how I ended up here:

 *Quote:*   

> If you are having problems configuring Apache and PHP, you can always search the Gentoo Forums. Try searching with the keywords "Apache PHP". 
> 
> 

 

Well, I will try downgrading to x86 and see what happens.

Thanks for the prompt answer!

----------

## macguyver

Okay, I got it now =)

I tried some combinations of various versions of apache1 and php, and after I got one working, I realized when I upgraded packages, some symlinks were not updated, so I upgraded apache1 and php back again, and solved the problem with this:

eselect php set php5; eselect php-cgi set php5; eselect php-devel set php5

Shame on me for not reading enough =)

Still getting used to Gentoo's model...

Anyway, thanks for the attention!

----------

