# Apache2+php.........one more time.

## squealie

Hi guys.

I am trying one last time to get this going before I abandon Gentoo for this project.

Working through the virt-mailhost how-to, and it leaves you on your own for the Apache php portion, I know it says to use Apache1, but 2 appearently works on the desktop how-to.

test.php = <? phpinfo() ?>  

It doesn't render.

I HAVE:

APACHE2_OPTS= "-D PHP4 -D SSL" 

In /etc/conf.d/apache2

What else can I check?

I have STFW and this forum and the above is the only advice I can find that seems relevant.

Please, I'm at my wits end here.   :Confused: 

----------

## squealie

OK, I found another tidbit while Googling.

I hadn't set the Severname directive (which was the cause of this behavior for one person) but now I have, along with updating DNS records.  Resolution OK, and I no longer get the 'could not determine servers FQDN message'.

It's still broke.   :Shocked: 

.

----------

## squealie

More Googling......

========================================

On Gentoo, it is important to run the ebuild config once you've emerged Apache2

and PHP. As the manual says:

# emerge apache php mod_php

# ebuild /var/db/pkg/dev-php/mod_php-4.2.2-r1/mod_php-4.2.2-r1.ebuild config

Your version numbers might differ. Do a "emerge -s mod_php" to get the present

version number.

Then, remember to edit /etc/conf.d/apache2 and add/modify this line to look like

this (the SSL part is optional ofcourse):

APACHE_OPTS="-D SSL -D PHP4"

=========================================

I reran the ebuild config (I forgt that I had remerged mod_php   :Embarassed:  )

I got this:

Due to some previous bloopers with PHP and slotting, you may have multiple copies of mod_php installed.  Please look at the autoclean output at the end of the emerge and unmerge all but relevant copies.....

after emerge -p mod_php (I don't know if I'm on the right track here..)

I get:

[   ebuild    R  ] dev-php/mod_php-4.3.3-r1

Now I'm gonna try to figure out what that means....  :Rolling Eyes: 

----------

## MrPyro

That warning is done by default: it isn't based on any checking done to the system.

The ebuild config run basically adds a few lines to apache.conf to configure it for PHP

----------

## squealie

 *MrPyro wrote:*   

> That warning is done by default: it isn't based on any checking done to the system.
> 
> The ebuild config run basically adds a few lines to apache.conf to configure it for PHP

 

Thanks, I did suspect that after looking at the ebuild file.

So, I'm back where I started, which is, without a clue.

----------

## raDeon

hi did you start apache with

```
apache2 -D PHP4
```

how come I have to type -D PHP4 at the end if I want PHP enabled?  I want it to be enabled when i run /etc/init.d/apache2 start or something.

----------

## darfsnuzal

I remember having a lot of trouble with apache + php.  Now I'm not 100% certain that this was the exact cure, but I unemerged php, apache and mod_php and then only emerged apache and mod_php.  That seemed to take care of the problem.

I believe if you do an emerge -p mod_php on a clean system it won't show "php" in the required list.  That's what gave me the idea to unemerge php.

HTH.

----------

## squealie

 *raDeon wrote:*   

> hi did you start apache with
> 
> ```
> apache2 -D PHP4
> ```
> ...

 

That did it!

Thank you.    :Very Happy: 

I don't know why, it doesn't work just putting the option in conf.d/apache2, but it did output this on startup:

[warn] module php4_module is already loaded, skipping

Thanks again, now I can at least get on with my server installation.

----------

## RevJones

I had a similar problem getting apache to load the php mod. It worked with if I did 

```
apache2 -D PHP4
```

but not if I added the option to the config file /etc/conf.d/apache2. After double checking the file I found that I had forgotten to remove the comment mark!  :Embarassed: 

Works now.   :Smile: 

----------

## tom

 *squealie wrote:*   

> I don't know why, it doesn't work just putting the option in conf.d/apache2, but it did output this on startup:
> 
> [warn] module php4_module is already loaded, skipping
> 
> 

 

Has anyone figured out why this should be?  I'm experiencing the same thing:  I have add the "-D PHP4" option explicitly on the command line.  Why won't it pick it up in /etc/conf.d/apache2?  Weird.

----------

## squealie

 *Quote:*   

> 
> 
> Has anyone figured out why this should be?  I'm experiencing the same thing:  I have add the "-D PHP4" option explicitly on the command line.  Why won't it pick it up in /etc/conf.d/apache2?  Weird.

 

Bump for any new info?

----------

## elvis38

 *squealie wrote:*   

>  *Quote:*   
> 
> Has anyone figured out why this should be?  I'm experiencing the same thing:  I have add the "-D PHP4" option explicitly on the command line.  Why won't it pick it up in /etc/conf.d/apache2?  Weird. 
> 
> Bump for any new info?

 

Did you remove the # from the begining of the line in etc/conf.d/apache2 ?

Worked for me...  :Wink: 

----------

## MeBrains

I have the same problem as well....

have not found a solid answer from no one yet although I searched the board several times for this already.

works from prompt, does not work with APACHE_OPTS...  :Confused: 

----------

## elvis38

Humm. You'd have to check the conf files, but I am assuming something went wrong on your machine during the emerge.

If it helps, this is what I did:

1. emerge sync

2. emerge phpmyadmin (this is what I really wanted)

3. edited /etc/conf.d/apache2 as per above (-D PHP4).

4. rc-update add apache2 default

I didn't have php, mod_php or apache2 emerged when I started.

----------

## sgarcia

 *Quote:*   

> Humm. You'd have to check the conf files, but I am assuming something went wrong on your machine during the emerge.
> 
> 

 

My guess is that something went wrong during the config update.  I emerged mod_php and apache2 to the most current versions quite some time ago, but was too lazy to update the config files.  I was installing a PHP package tonight and it was working fine.  

In the middle of the install of a subsidiary package unrelated to PHP I decided to clean up the 46 config files portage had been telling me I urgently had to update, so while ImageMagick was compiling, I "cleaned up" my config files.

When I restarted apache, PHP was dead.  If I put "-D PHP4" in /etc/config.d/apache2, nothing happens.  If I start using 

```
apache2 -D PHP4
```

 nothing happens.

I like Gentoo's portage system, but its init scripts are a nightmare to deal with.  They are convoluted and nasty.  Rather than be ashamed of the ugly things like any sane person would be, the developers seem to be proud of them.

Why do we have to deal with "defines" at startup?  It's SO much easier just to have the damned module listed in the ONE httpd.conf and be able to just use the apachectl that CAME with apache.  Sheesh!

I just unmerged apache, php and mod_php and now the machine is grinding away reinstalling them.  We'll see if anything works when I'm done.  But if I *do* get it running again, I'm going to think very seriously before I do any more updates.  This isn't the first time that "updating" startup scripts has broken things for me.

I would *NEVER* recommend Gentoo for anything important.  It makes a fine desktop -- I've had better luck getting a nice customized desktop machine set up than with any other distribution I've tried.  But this screwed up init/configuration maze is just too unreliable to use in the real world.

----------

## To

 *sgarcia wrote:*   

> My guess is that something went wrong during the config update.  I emerged mod_php and apache2 to the most current versions quite some time ago, but was too lazy to update the config files. 

 

One of the main problems on linux, ppl just don't read the manuals and don't edit the conf files.

 *sgarcia wrote:*   

> I was installing a PHP package tonight and it was working fine.  
> 
> In the middle of the install of a subsidiary package unrelated to PHP I decided to clean up the 46 config files portage had been telling me I urgently had to update, so while ImageMagick was compiling, I "cleaned up" my config files.
> 
> 

 

That's because you did a auto-update, you should read carefully the warning befour;)

I usually backup my /etc when I'm updating configure files, something may happend etc etc

 *sgarcia wrote:*   

> 
> 
> When I restarted apache, PHP was dead.  If I put "-D PHP4" in /etc/config.d/apache2, nothing happens.  If I start using 
> 
> ```
> ...

 

If you had it running befour, then you did an etc-update and stop working the answer is easy, edit you config files!

 *sgarcia wrote:*   

> 
> 
> I would *NEVER* recommend Gentoo for anything important.  It makes a fine desktop -- I've had better luck getting a nice customized desktop machine set up than with any other distribution I've tried.  But this screwed up init/configuration maze is just too unreliable to use in the real world.

 

I recomend gentoo speacially for important things. Why? cause you can decide what you want and how you want it.

Any other distribuion has a nice KDE skin or wahtever and ppl love it, but nothing gets close to gentoo's optimization options.

Fact is, even if you aren't an expert, gentoo and the help of this foruns are one of the finest resources to learn and develop linux skills.

Tó

----------

## bos_mindwarp

Last time I installed php, I forgot to add the file extensions part of apache.conf (portage doesnt do this for you).

Check this out:

http://www.php.net/manual/en/install.apache2.php

read the part about apache2 shared module instructions (example 3-6), paragraf 15.

----------

## Frans

 *bos_mindwarp wrote:*   

> Last time I installed php, I forgot to add the file extensions part of apache.conf (portage doesnt do this for you).
> 
> 

 

uhm .... Like squealie said... Yes, portage will do that for you.. READ the output after a emerge!

 *squealie wrote:*   

> 
> 
> ebuild /var/db/pkg/dev-php/mod_php-4.2.2-r1/mod_php-4.2.2-r1.ebuild config 
> 
> Your version numbers might differ. Do a "emerge -s mod_php" to get the present version number. 
> ...

 

Maybe ... just maybe APACHE2_OPTS works better....

----------

## sgarcia

 *Quote:*   

> sgarcia wrote:
> 
>  *Quote:*    was installing a PHP package tonight and it was working fine.
> 
> In the middle of the install of a subsidiary package unrelated to PHP I decided to clean up the 46 config files portage had been telling me I urgently had to update, so while ImageMagick was compiling, I "cleaned up" my config files. 
> ...

 

Backing up /etc would probably have been a good idea.  Where did you get the idea that I did an auto-update?

I did, however replace the apache startup script with the new one that came out.

 *Quote:*   

> sgarcia wrote:
> 
>  *Quote:*   I would *NEVER* recommend Gentoo for anything important. It makes a fine desktop -- I've had better luck getting a nice customized desktop machine set up than with any other distribution I've tried. But this screwed up init/configuration maze is just too unreliable to use in the real world.
> 
>  
> ...

 

Gentoo has the potential to be a superb option for important things.  However, the init system is convoluted and largely undocumented.  Instead of a config file for Apache 2, you have half a dozen, spread out all over the file system.  If you want to trace what's going on during startup, most of the "action" happens inside the bowels of runscript, which appears to be completely undocumented.  You're completely at the mercy of whoever most recently rewrote the init script for your particular service, because you're never going to be able to trace it to see what he screwed up.

It also doesn't help that instead of having a config file for each service, there is a normal config file as well as one in /etc/conf.d (which may or may not have critical settings) as well as potentially other config files at the discretion of the Gentoo maintainer.  As, for example, the module config stuff in /etc/apache2/conf/modules.d.  I searched for 20 minutes before I found settings that normally reside in the httpd.conf hiding away in modules.d.

If Gentoo used standard SysV init scripts, or if the Gentoo init setup was a bit more transparent, so administrators could easily trace what was going on and customize it to their own needs (or fix what a developer screwed up) -- well, then I'd concede that Gentoo was ready for the big time.  As it is, it's a crap shoot.  Mostly things work well, but when they don't, it's a nightmare to fix.  If there were documentation for the init process this would be a lot more acceptable.

The init scripts use /sbin/runscript as the shell.  That's fine, as long as the shell functions and script language are documented.  If there is documentation, it's well hidden.

----------

## mallchin

 *elvis38 wrote:*   

>  *squealie wrote:*    *Quote:*   
> 
> Has anyone figured out why this should be?  I'm experiencing the same thing:  I have add the "-D PHP4" option explicitly on the command line.  Why won't it pick it up in /etc/conf.d/apache2?  Weird. 
> 
> Bump for any new info? 
> ...

 

LMAO, I must have setup many Apache+PHP installs but...  :Rolling Eyes:  ... I got caught out by the #

Thanks elvis!

----------

## korozion

Well, I may have a weird one. I have -D PHP4 and -D SSL in the config file, php works great, but ssl will not.

----------

## elvis38

 *korozion wrote:*   

> Well, I may have a weird one. I have -D PHP4 and -D SSL in the config file, php works great, but ssl will not.

 

Korozion, I know it may be an obvious question but did you have ssl in your USE variables when you emerged apache?

----------

## Oopsz

Gentoo is fantastic on the server.  it's intuitive.  All the apache specific configuration is in /etc/apache/conf, all the run time changes go in /conf.d.  And module ebuilds automagically add themselves to your apache.conf!  Changing start up options is as easy as editing one line.  What more could you want?  

If you don't want full control of your system, go download red hat, I hear lots of people like that.  They have nice graphical interfaces for everything, too.    :Twisted Evil: 

----------

## duhmmm

I just went though this last night....

Reading the thread it looks like many are typing "apache2 -D PHP4" at the commandline with success, but not not getting it to work with "apache2 -k start".

When you type "apache2...." at the commandline, you are not starting /etc/init.d/apache2, you actually run /usr/sbin/apache2, thus /etc/conf.d/apache2 is not used.

--- or maybe everyone had figured this out.

----------

