# php apache problem

## mixmasterdj2002

Hi, I have just followed the desktop install off of the website and installed php apache and ssl, my document root = /web this is a larger hard drive for the web space. I have managed to change the apache.conf and commonapache.conf files so that I can view the web site, but I am not sure how to get ssl and php working correctly... 

What additional changes do I have to make to the configuration files...

when I try

```
<? phpinfo(); >
```

I just end up seeing the text on the screen, php is not actually executing the script.

!!  :Exclamation:  HELP  :Exclamation:  !!

 :Wink:  :Wink:  Thanks in advance

----------

## chadh

When you installed php, you should have seen a message telling you to run 

```
ebuild /var/db/pkg/dev-lang/php/php-<version>.ebuild config
```

Did you do that?

----------

## Ian Goldby

By some coincidence, I've just been installing php for the first time today, and got stuck in the same place as you.

Presumably, you read the message at the end of the php ebuild telling you to run an ebuild with the 'config' argument. I tried this and it didn't seem to do anything to apache.conf, although it may have done something elsewhere.

First check that you've got the file /etc/apache/extramodules/libphp4.so

Assuming that's ok, edit your apache.conf file and add the following lines - they can go as the last entries in the corresponding lists of similar lines:

```
LoadModule php4_module        extramodules/libphp4.so
```

```
AddModule mod_php4.c
```

(Note mod_php4.c is not a file on your disk. That had me baffled for some considerable time as I tried to locate it first.)

Next go into your /etc/apache/conf/commonapache.conf file and put in the following <IfModule> section. I put mine following the previous last one:

```
# php module

<IfModule mod_php4.c>

     AddType  application/x-httpd-php         .php .php4 .php3 .phtml

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

</IfModule>
```

You could instead use an Include directive to /etc/apache/conf/addon-modules/mod_php.conf if you prefer, which contains the same Apache directives.

Then restart Apache with the usual /etc/init.d/apache restart. That should be it. Check mod_php4 is visible to Apache by going to http://localhost/server-info and then try your test page.

----------

## klieber

Moving this (cross-posted) topic to the networking forum.

--kurt

----------

## Nebajoth

I had the same issues with getting PHP and SSL to work with Apache after following the instructions laid out in the Desktop Install portion of the Gentoo website.  After more than a little headache, I narrowed the problem area down to the "apache" file in /etc/conf.d which states:

APACHE_OPTS="-D SSL -D PHP4"

Now, I'm perfectly aware of what this line is SUPPOSED to do.  It is intended to assign the string "-D SSL -D PHP4" to the env value "APACHE_OPTS", so that when apache is started (via /etc/init.d/apache start) it is equivalent to "/etc/init.d/apache start -D SSL -D PHP4".  This enables SSL and PHP4, so that when the /etc/apache/conf/apache.conf file hits the <IfDefine PHP4> and <IfDefine SSL> sections, it runs the enclosed lines (which turn on PHP and SSL for your Apache webserver).

However, because of some parsing issue of which I am NOT qualified to fix, the /etc/conf.d/apache file does not read that line correctly.  It reads 

>> APACHE_OPTS="-D" 

and then stops, meaning that it does not know to load SSL or PHP.

Much to our detriment.  I do not know how to fix that file, though I suspect it is a quick and simple fix involving the placement of quotation marks, or the placement of the command in one of the main .conf files in /etc/apache/conf.  One of you can play around with it, because I've just done the following:

export APACHE_OPTS="-D SSL -D PHP4"

/etc/init.d/apache start

It then works perfectly, since the env variable has been set, recognized by apache, and applied.

Happy Squirrelmailing.

Dylan.

----------

## kvh009

 *Nebajoth wrote:*   

> I had the same issues with getting PHP and SSL to work with Apache after following the instructions laid out in the Desktop Install portion of the Gentoo website.  After more than a little headache, I narrowed the problem area down to the "apache" file in /etc/conf.d which states:
> 
> APACHE_OPTS="-D SSL -D PHP4"
> 
> Now, I'm perfectly aware of what this line is SUPPOSED to do.  It is intended to assign the string "-D SSL -D PHP4" to the env value "APACHE_OPTS", so that when apache is started (via /etc/init.d/apache start) it is equivalent to "/etc/init.d/apache start -D SSL -D PHP4".  This enables SSL and PHP4, so that when the /etc/apache/conf/apache.conf file hits the <IfDefine PHP4> and <IfDefine SSL> sections, it runs the enclosed lines (which turn on PHP and SSL for your Apache webserver).
> ...

 

I had to comment out the <IfDefine PHP4> in apache.conf in order to get PHP4 to work ...

Someone needs to fix this ...

----------

## rojaro

just because you didnt follow the documentation during your installation someone shall fix a bug that doesnt exist????

man, you gotta learn reading docs ... MANY people here installed apache and PHP and only the very few which didnt manage to read the docs have problems with these packages.

```
genesis glibc # telnet localhost 80

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

HEAD / HTTP/1.0

HTTP/1.1 200 OK

Date: Sat, 13 Jul 2002 19:44:54 GMT

Server: Apache/1.3.26 (Unix) mod_gzip/1.3.19.1a PHP/4.2.1

Connection: close

Content-Type: text/html

Connection closed by foreign host.

genesis glibc #

```

and no, i did not comment out the IfDefine ...

----------

## Nebajoth

 *Quote:*   

> 
> 
> just because you didnt follow the documentation during your installation someone shall fix a bug that doesnt exist???? 
> 
> man, you gotta learn reading docs ... MANY people here installed apache and PHP and only the very few which didnt manage to read the docs have problems with these packages. 
> ...

 

 :Question: 

Look, you.  I beg you to return to the beginning of this thread, and read about how every person who has posted about this problem, well, DID follow the instructions on the site.

That's why it was a baffling issue.

It is also why it has been the common consensus that it is a "bug" that needs to be "fixed".

Lets go back to the happy-place where I like and respect you, and you like and respect me.

-- Nebajoth

----------

## bmph8ter

I was having problems with SSL too.  Tried all of the suggestions here, and nothing worked.  So I reset all my changes and went through the docs again.  That's when I found this part:

 *Quote:*   

> Code listing 37
> 
> # emerge net-www/apache dev-lang/php net-www/mod_ssl
> 
> # ebuild /var/db/pkg/dev-lang/php-4.1.2-r7/php-4.1.2-r7.ebuild config
> ...

 

Hmm.  So I did this:

```
ebuild /var/db/pkg/net-www/mod_ssl-2.8.10.ebuild config
```

Then I started apache again & https worked.    :Embarassed:   :Embarassed:  Perhaps this will help some others.

----------

## msb21

After looking through the list and searching the forum, I can not get mod_php, mod_ssl working. I am also not able to change the DocumentRoot directive in apache to /var/www/html rather than /home/httpd/htdocs.

Regarding getting the mocules in apache working, I have  done the ebuild mod_php.ebuild config for both respective modules. I have uncommented APACHE_OPTS in /etc/conf.d/apache, I have exported the APACHE_OPTS variable to include "-D SSL -D PHP4". When I load server-info, these two modules are not installed. The libphp4.so is in the $APACHE_HOME/extramodules as is libssl.so. Any ideas?  I have the proper settings in the config files....

Secondly, I created the directories /var/www/html, /var/www/icon etc. and made root the user and group owner, with a permission of 755.  I then changed the DocumentRoot directive in apache.conf to point to /var/www/html. When I load the index.html that I copied to /var/www/html I get a "Do not have permissions to access /" in the browser.

I have been able to add mod_php, as well as change DocumentRoot's to apache on other distros but am puzzled.

Any ideas would be grateful and appreciated.

----------

## rac

 *msb21 wrote:*   

> When I load the index.html that I copied to /var/www/html I get a "Do not have permissions to access /" in the browser.

 

Look for directives like "deny from xxx" and "allow from xxx" in your apache configuration files, and relax them as you see fit.  Perhaps you have "deny from all" on /.

----------

## grakker

For what it's worth, after reading this, I emerged mod_ssl then mod_gzip, edited /etc/init.d/apache, restarted apache and everything works fine:

```
 1 HTTP/1.1 200 OK

 2 Date: Sat, 31 Aug 2002 19:08:09 GMT

 3 Server: Apache/1.3.26 (Unix) PHP/4.2.1 mod_gzip/1.3.19.1a mod_ssl/2.8.10 OpenSSL/0.9.6e

 4 X-Powered-By: PHP/4.2.1

 
```

msb21:  Change the user to what the user that apache runs under (on my system that's set to apache)  As far as the group user, I have practically the entire /htdocs directory chown'd apache.apache.  I'm not sure about the security, but it works for me.

----------

## OdinsDream

I, too, cannot seem to get mod_php working. I've commented out the IfDefine sections around both the LoadModule and AddModule sections, yet server-info still does not show mod_php or any other php-related things as being loaded.

Please help... I've tried the suggestions outlined above.

----------

## grakker

Not exactly sure what the problem may be.  I remember something strange when I first set up php.  Not sure if this will help but:

```
> grep php /etc/apache/conf/*apache.conf

/etc/apache/conf/apache.conf:# LoadModule php4_module        extramodules/libphp4.so

/etc/apache/conf/apache.conf:LoadModule php4_module        modules/libphp4.so

/etc/apache/conf/apache.conf:AddModule mod_php4.c

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

/etc/apache/conf/commonapache.conf:    DirectoryIndex index.php index.html index.php3 index.shtml index.cgi index.pl index.htm Default.htm default.htm

/etc/apache/conf/commonapache.conf:    AddIcon /icons/p.gif .pl .py .php .php3

/etc/apache/conf/commonapache.conf:    #php3

/etc/apache/conf/commonapache.conf:    Addtype application/x-httpd-php3 .php3

/etc/apache/conf/commonapache.conf:    Addtype application/x-httpd-php3-source .php3s

/etc/apache/conf/commonapache.conf:    #php4

/etc/apache/conf/commonapache.conf:    Addtype application/x-httpd-php .php

/etc/apache/conf/commonapache.conf:    Addtype application/x-httpd-php-source .phps

```

And

```
> grep -v ^# /etc/conf.d/apache

APACHE_OPTS="-D SSL -D PHP4 -D GZIP"

```

Sorry I said /etc/init.d instead of /etc/conf.d in my previous post.  Hop that helps a little.

----------

