# Apache2 + PHP + MySQL

## Artem

How would I go about setting this up? Anyone have a guide? I alreade emerged apache, php, mysql, mod_php, etc but it still says PHP is not running, and I bet that it doesn't recognize MySQL either. So how can I make this work?

-Artem

----------

## steveb

if you have apache2 and mod_php installed, then you only need to edit /etc/conf.d/apache2 and enable php in the APACHE2_OPTS, by adding "-D PHP4" to the line:

```
APACHE2_OPTS="-D SSL -D PHP4"
```

and then restart apache2  :Wink: 

cheers

SteveB

----------

## Artem

Tried that, same thing happens  :Sad: 

----------

## steveb

what is the content of /var/log/apache2/error_log?

cheers

SteveB

----------

## fixxxer

The first thing is that you should not install Apache2+mod_php for production or semi-production purposes:

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

I also prefer to emerge them separately: first Apache then mod_php (mysql should be emerged before php, too). At least this always works fine.  :Smile: 

You should also study the configure parameters of php and add the corresponding directives to the USE variable or you'll get no modules like DOM, XSLT or GD which are very useful.

If you're going to serve several virtual host you SHOULD read about the base_opendir and safe_mode ini directoves of PHP: this is due to all the php scripts run from the same user and therefore can access each other's sensitive data by default.

----------

## Artem

After emptying the log, restarting the server, and trying to access a PHP page this is what's in the log.

However this does not look like something special =\

```
[Wed Mar 10 15:38:43 2004] [notice] Digest: generating secret for digest authentication ...

[Wed Mar 10 15:38:43 2004] [notice] Digest: done

[Wed Mar 10 15:38:44 2004] [notice] Apache/2.0.48 (Gentoo/Linux) configured -- resuming normal operations

[Wed Mar 10 15:38:56 2004] [error] [client XX.XX.XX.XXX] File does not exist: /var/www/localhost/htdocs/favicon.ico
```

Note: XX.XX.XX.XXX is my blanked out IP address  :Wink: 

----------

## fixxxer

This is not an informative part of the log. It's all normal...

Are there mod_php.conf and php.ini files in /etc/apache/conf/addon-modules?

Is mod_php.conf included in httpd.conf or its includes?

What happens if you put an index.php file containing

<?php phpinfo() ?>

to your DocumentRoot and go to http://your_ip/index.php with your browser?

----------

## Artem

OK I see a problem because i don't have an addon-modules folder in conf.

----------

## fixxxer

Hmm.

If you emerged them all-in-time there probably are no addon-modules and everything is in httpd.conf. I just never tried it this way...but i can suppose it is so...

check your conf files for presense of the line like this

LoadModule php4_module        /usr/lib/apache/libphp4.so

is it present?

----------

## Artem

Added that - still won't work, even though the file exists...  :Sad: 

----------

## Artem

Damn, apache is pointless for me if I don't have PHP working  :Sad: 

----------

## radice

I have php4, apache 2.0.48 and mysql 12.22.

To install I followed these steps:

emerge apache

emerge mysql

emerge php

emerge mod_php

Added Line in /etc/apache2/conf/apache2.conf:

	LoadModule php4_module            modules/libphp4.so

Didn't added the  -D PHP in APACHE2_OPTS in /etc/conf.d/apache2

Now it is working perfectly

----------

## meyer37

I also had a bit of trouble setting up APACHE2 and PHP.  What work for me was

```

emerge apache

emerge php

emerge mod_php

```

I then followed the suggestions at the end of the mod_php emerge and add 

```
-D PHP4
```

 to the APACHE2_OPTS and also uncommented that line.

The main thing was to uncomment the APACHE2_OPTS line because by default it is commented out.  How the simplest errors can sometimes be the hardest to find  :Cool: 

----------

## webkiller71

 *Artem wrote:*   

> [Wed Mar 10 15:38:56 2004] [error] [client XX.XX.XX.XXX] File does not exist: /var/www/localhost/htdocs/favicon.ico

 

this is irrelevant, this is the icon in the adres bar, if it doesn't exists, it doesn't matter

----------

## hermes_jr

Hmm... icon... DIY!!! (Draw It Youself)  :Twisted Evil: 

And what about this?

----------

## mach.82

 *hermes_jr wrote:*   

> Hmm... icon... DIY!!! (Draw It Youself) 
> 
> And what about this?

 

Hwo do you do that? Or

What tool(s) do I use?

Thanks!

----------

