# Best apache2 HOWTO?

## zeveck

What is the best apache2 HOWTO?

I am trying to run a server that supports apache2 with SSL, PHP, and maybe Perl. I also want to run MySQL and PHPMyAdmin.

I tried looking for HOWTOs, but, for instance, the http://gentoo-wiki.com/HOWTO_Apache2 howto says it is outdated and need to be rewritten...and searches result in likewise finding lots of information that appears similarly outdated.

So...what is the most modern set of HOWTOs, &c., I would need to get the above up and running?

----------

## srlinuxx

Well, there probably isn't a gentoo specific one, and their ebuild changes quite a bit as I recall (file names and locations).  But you really can't beat the source on this one:  install with options  and all the related docs are here.  There are a few ebuilds I pass on and this is one of 'em.  But perhaps you can use them in conjunction with the gentoo howto and get it going.

----------

## Lousie_Louie

I am also trying to get php to work on Gentoo.  I have been following the instructions on the same page from the Gentoo Wiki, and Apache works, but I can't get php to respond.  I have emerged php and mod_php and added

APACHE2_OPTS="-D SSL -D PHP4" 

to 

 /etc/conf.d/apache2

But php pages still come back as plain code.  I'm guessing somthing has changed, can anyone help fix this wiki page?

----------

## Lousie_Louie

Actually I have been attempting to follow the instructions on this page:

http://gentoo-wiki.com/HOWTO_Apache2_with_PHP_MySQL

Apache works fine, but no php.

----------

## asuweb

 *Quote:*   

> I am also trying to get php to work on Gentoo. I have been following the instructions on the same page from the Gentoo Wiki, and Apache works, but I can't get php to respond. I have emerged php and mod_php and added
> 
> APACHE2_OPTS="-D SSL -D PHP4"
> 
> to
> ...

 

Add the following line to /etc/apache2/conf/apache2.conf

```
LoadModule php4_module                  /usr/lib/apache2-extramodules/libphp4.so
```

assuming that the path to libphp4.so is as above. 

Then restart apache 

```
/etc/init.d/apache2 restart
```

 and that should work.

----------

## nobspangle

you don't need to add any lines to your config files, the -D PHP4 is all you need (providing you've emerged PHP 4 not 5)

go to a page that doesn't exisit and you will get the apache 404 page, at the bottom will be the server banner something like

 *Quote:*   

> Apache/2.0.54 (Gentoo/Linux) mod_ssl/2.0.54 OpenSSL/0.9.7e PHP/4.3.11

 

If it doesn't say PHP then you haven't loaded the module, do  a 

```
ps aux | grep apache
```

 and check that the command running apache includes the -D PHP4

----------

## Lousie_Louie

Thanks asuweb!  Your advice worked!

----------

## asuweb

Glad I could be of help.  I had the same problem, took me a while to figure it out.

----------

## ronnie

There are numerous places where you can put the "LoadModule" command. 

But as nobspangle said, there should be no need to edit/hack apache2.conf. It should actually be loaded in /etc/apache2/conf/modules.d/70_mod_php.conf along with the rest of the PHP configuration when "-D PHP4" is passed to the start script, else something likely is wrong.

----------

## Lousie_Louie

Ok this was working with php, but now it quit.

Here are my apache commands:

```
axiom@axiom axiom $ ps aux | grep apache

root     12011  0.0  1.3  28196 11920 ?        Ss   09:06   0:00 apache2 -k restart

apache   12270  0.0  1.3  28196 11932 ?        S    09:11   0:00 apache2 -k restart

apache   12271  0.0  1.3  28196 12064 ?        S    09:11   0:00 apache2 -k restart

apache   12272  0.0  1.3  28464 12284 ?        S    09:11   0:00 apache2 -k restart

apache   12273  0.0  1.3  28196 12008 ?        S    09:11   0:00 apache2 -k restart

apache   12274  0.0  1.3  28464 12280 ?        S    09:11   0:00 apache2 -k restart

apache   12275  0.0  1.3  28196 12056 ?        S    09:11   0:00 apache2 -k restart

apache   12282  0.0  1.3  28196 12052 ?        S    09:12   0:00 apache2 -k restart

apache   12286  0.0  1.3  28196 12068 ?        S    09:12   0:00 apache2 -k restart

root     17873  0.0  0.0   1768   860 pts/3    S+   15:27   0:00 nano /etc//apache2/conf/modules.d/70_mod_php.conf

axiom    18342  0.0  0.0   1496   452 pts/5    R+   15:33   0:00 grep apache

axiom@axiom axiom $   
```

Here is my  404:

```
Apache/2.0.54 (Gentoo/Linux) PHP/4.3.11 Server at 127.0.0.1
```

Here is another file you mentioned /etc/apache2/conf/modules.d/70_mod_php.conf

```
# vim: ft=apache sw=4 ts=4

<IfDefine PHP4>

        # Load the module first

        <IfModule !sapi_apache2.c>

                LoadModule php4_module    extramodules/libphp4.so

        </IfModule>

        # Set it to handle the files

        <IfModule mod_mime.c>

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php .phtml

                AddType application/x-httpd-php .php3

                AddType application/x-httpd-php .php4

                AddType application/x-httpd-php-source .phps

        </IfModule>

        # Fix some bugs

        <Files *.php>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.php3>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.php4>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.phps>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

        <Files *.phtml>

                # keep this the same size as post_max_size in php.ini

                # LimitRequestBody 8388608

        </Files>

</IfDefine>

```

This has got to be somthing simple.

----------

