# mod_php: not starting?

## idiotprogrammer

I'm installing apache, mod_php, mod_perl, and mod_dav

things emerge ok and i can get apache to work, but i can't tell if mod_php is working

i wrote a phpinfo script, which only showed text

the apache logs shows that the server information is just apache with no php inolved.

I ran the ebuild scripts and changed APACHE_OPTS="-D SSL -D PHP4" in the startup file. 

The problem is that the config files usually have configuration about php in If containers, so it's hard to tell if apache is even php aware. is there a setting I need to make  on php config file? 

I looked at the apache config files, and nothing looks strange on the mod_php lines. (and anyway, isn't gentoo supposed to make these sort of difficulties old-fashioned? 

Anything I've missing? 

Robert Nagl e

----------

## sergio

Check your /etc/apache/conf/apache and then is necessary add the lines follow

```

<IfDefine PHP4> 

LoadModule php4_module    extramodules/libphp4.so 

</IfDefine> 

.... 

<IfDefine PHP4> 

AddModule mod_php4.c 

</IfDefine> 

..... 

Include  conf/addon-modules/mod_php.conf 

```

Don't forget to restart apache after...

Bye

----------

## idiotprogrammer

actually I was surprised to find that these lines weren't in commonapache.conf 

I put the lines you mentioned in both conf/apache.conf and commonapache.conf

Still does not work. I'm looking at the server signature when I do http. I see neither mod_ssl or mod_php.

Other ideas? 

rj

----------

## sergio

- Check if apache is started (ps -ef)

- Check the error_log file in /var/log/apache

- Check the syntax of apache's configurations files with 

```

apache -t

```

if you have some virtual hosts check its with

```

apache -S

```

From my side, i will try to install apache and mod_php on my workstation to perform some test...

A+ (bye)

----------

## sergio

Check the "apache" file in /etc/conf.d

uncomment the line follow

```

# APACHE_OPTS="-D SSL -D PHP4"

```

Then save the file, and restart apache...

I think it will work fine now !!

A+ (Bye)

----------

## axxackall

Same problem here. I think we need Gentoo-PHP-HOWTO about, b/c with current php ebuilds it doesn't work. There is some magic trick that PHP people know, but still did not tell us.

One more time:

```

ebuild mod_php ;

uncomment APACHE_OPTS="-D SSL -D PHP4" in /etc/conf.d ;

check for the for LoadModule and AddModule line in /etc/apache/conf.apache.conf (in fact, they have already been there);

ebuild phpBB ;

/etc/init.d/apache restart

lynx http://localhost/phpbb

```

and all php code is right in the browser screen.

So, what's the secret?

----------

## jgaynor

I seem to be have the same problem as you, idiotprogrammer.  After some wrestling I was able to succesfully install php using the java USE option.  Mod_php was the same way.  My apache.conf and apache file look kosher but no go with apache serving any php files.  Im testing using phpsysinfo, and apache just attempts to send the index file as a download.  Glad this isn;t just me - I was beginning to think I had gotten in over my head with gentoo  :Smile: .

----------

## waverider202

I noticed this problem back when 4.3 was released.  I couldn't figure out for the life of me what was causing it not to work, so I solved the problem in the most elagent way I could:

emerge php-4.2.3.ebuild

----------

## idiotprogrammer

in response to jgaynor: 

interestingly, I  used use="-java" because of another emerge bug related to java.  Perhaps these two bugs are related.

https://forums.gentoo.org/viewtopic.php?t=36518&highlight=modphp

It's worth trying everything again from scratch to make sure I didn't forget anything. 

Problems.

----------

## axxackall

Sometime I wonder, why packages with so obvious bugs are unmasked, while many packages, good and stable, are still masked.

----------

## tdrobinson

I have the fix.  I tell you this really frustrated me.

It is the order that the modules are loaded in the /etc/apache/conf/apache.conf file.  Make sure that the following vhost line is after the php module line.

LoadModule vhost_alias_module   modules/mod_vhost_alias.so

Like so:

<IfDefine PHP4>

LoadModule php4_module    extramodules/libphp4.so

</IfDefine>

<IfDefine SSL>

LoadModule ssl_module    extramodules/libssl.so

</IfDefine>

LoadModule vhost_alias_module   modules/mod_vhost_alias.so

----------

## idiotprogrammer

You know, last time, I came home exhausted and instead of trying to investigate this problem further, I ended up watching tv and falling asleep. 

This solution sounds very hopeful. I'll try it tonight. Thanks!

rj

----------

## b0d0r

also if you comment out or remove the <ifdefine> and </ifdefine> for each module that you want to use... you will find that will get it to work...

well i did it and it works for me  :Smile: 

----------

## barnaclebarnes

 *axxackall wrote:*   

> Same problem here. I think we need Gentoo-PHP-HOWTO about, b/c with current php ebuilds it doesn't work. There is some magic trick that PHP people know, but still did not tell us.
> 
> One more time:
> 
> ```
> ...

 

I did all of this and it still wouldn't work. The issue is that apache was not picking up the APACHE_OPTS directives. Try and start apache by just typing:

```

apache -D PHP4

```

Then try and load a test php page. This worked for me. I agree that the php install does seem to be a nightmare. It should really add the correct lines to the apache configuration files, after all a standard php compile will do it for you.

----------

## Mord

Gah!  Thanks for this thread.

I just updated apache and php, and I manually clobbered my own /etc/conf.d/apache file.  PHP wasn't starting.....

Just had to remove the comment by the line

APACHE_OPTS="-D SSL -D PHP4"

and all was well.

----------

## ultraslacker

 *b0d0r wrote:*   

> also if you comment out or remove the <ifdefine> and </ifdefine> for each module that you want to use... you will find that will get it to work...
> 
> 

 

apachectl will not read the apache opts found in config file /etc/conf.d/apache.  For that config file to be effective, you have to start apache via the script in /etc/init.d/

----------

## jgaynor

WOOHOO!  FINALLY!

Man this problem took a LONG time to fix - truthfully its STILL not fixed but I've got it jury-rigged enough to work.  I decided to restart from square one.  Uninstalled apache, php & mod_php . . .

```
emerge unmerge apache php mod_php
```

reinstalled apache - no problems . . .

```
emerge apache
```

reinstalled php (can't remember what options I used to get that to work and mod_php - had to use the -jave and -qt options to get them to work (props to darktux on that one) . . .

```
USE="-qt -qtmt -java" emerge mod_php
```

I removed the comment from this line in my /etc/conf.d/apache file:

APACHE_OPTS="-D SSL -D PHP4"

but still no luck after restarting apache  :Sad:  .  So I stopped it and started it using the following command (thanks barnaclebarnes):

```
apache -D PHP4 
```

and IT WORKED!  Now this will not work when I reboot the box but it's a start.  Obviously apache is not getting its variables from /etc/conf.d/apache correctly.  Anyone have any thoughts as to why?  I'd be happy to post my conf files.

----------

## sebgarden

OK, here I have an interesting thing:

```

bash-2.05b# apache2ctl stop

Syntax error on line 79 of /etc/apache2/conf/apache2.conf:

Cannot load /etc/apache2/extramodules/libphp4.so into server: /etc/apache2/extramodules/libphp4.so: undefined symbol: mysql_drop_db

bash-2.05b#

```

 :Sad: 

This error appear only when the following line in apache2.conf is uncommented:

```

LoadModule php4_module    extramodules/libphp4.so

```

This is an error of php binding with mysql ? The other modules loaded without a hint from /etc/apache2/conf/modules.d/ and /etc/apache2/conf/extramodules/.

From the php page, I read that they don't assure the good compatibility of the bleeding-edge php and mysql. Has someone an idea about this issue ?

Regards,

Sébastien.

----------

## sebgarden

And I forgot to mention that commenting this line doesn't enable my browser to read phpinfo.php !

Sébastien

----------

## marsf

Ok, I'm willing to try a little experiment if anyone else is up for it.  I've been working on this for a while and for all intents and purposes it looks like PHP is running, but it just won't execute any script!

So, here is my proposition.  I've posted a tarball of my /etc/apache directory on my web site at http://www.redplanet.ca/temp/apache.tar.  All someone has to do is untar it to /tmp and run the command:

diff /etc/apache /tmp/apache -r {some other options, wbB maybe}

I am running apache-1.3.27-r3 with mod_php-4.3.1

This setup should be out-of-the-box.  As far as I can tell the config files are fine and all the needed settings are in there.  I have tried running the server with the "/etc/inid.d/apache" script, as well as with "/sbin/apache -D PHP4" and both commands would appear to be working from the log files as well as the http://localhost/server-status page.  These show the PHP 4.3.1 module being loaded up and configured.  However, the server will only spit PHP code back at me, no matter what I try.

So I would really like to know what is different between my setup and everyone else's?  What are the differences between a working setup and my own?  Comparing the config tree should at the least indicate whether or not the problem is in the configuration or elsewhere.

It is also worth noting that I had to use the USE="-qt -java" flags to get mod_php to compile in the first place.

So, who has a working configuration using these two packages, and what are the differences between that configuration and mine?

Mars

----------

## sebgarden

Well, I'm running apache-2.0.44, mysql-3.23.55 (downgrading last night), php-4.3.1 with mod_php-4.3.1-r1 and it's just running fine (Now  :Smile:  ).

Sébastien

----------

## sweede

as it is said above, check the /etc/init.d/apache script to see if it is loading the APACHE_OPTS in /etc/conf.d/apache

rename the stop() function to something like, _stop()

and then add the following,

stop() {

        ebegin ${APACHE_OPTS}

}

running /etc/init.d/apache stop (you must start it first) should return 

```

sweede@soulfly sweede $ sudo /etc/init.d/apache stop

 * -D SSL -D PHP4...

```

if not, you have other issues either in the rc script or in your /etc/conf.d/apache file

----------

## karl11

 *Quote:*   

> 
> 
>  * 
> 
>  * To have Apache run php programs, please do the following:
> ...

 

for all with mod_php problems, did you at least do the above like the ebuild says? This was my problem....looking over directions since I emerge mod_php with a bunch of other builds.

Karl

----------

## marsf

Well, PHP finally works, but I don't know how.

I unmerged mod_php, and then as an expriment built and installed normal PHP 4.3.1.   The normal PHP didn't work either.

Just now I reinstalled mod_php so that I could try the above solution.  But I didn't get that far, because everything works perfectly now?

Maybe it has something to do with having normal non-gentoo PHP and gentoo mod_php installed at the same time.

Strange.

Mars

----------

## olivierweb

I've got some problem for running mod_php. So I do the changes for the /etc files

 *axxackall wrote:*   

> USE="-java -qt" ebuild mod_php ;
> 
> uncomment APACHE_OPTS="-D SSL -D PHP4" in /etc/conf.d ;
> 
> check for the for LoadModule and AddModule line in /etc/apache/conf/apache.conf 

 

this was not enough, so I do this :

 *b0d0r wrote:*   

> also if you comment out or remove the <ifdefine> and </ifdefine> for each module that you want to use... you will find that will get it to work...
> 
> well i did it and it works for me 

 

And mod_php works !

Thanks everybody !

----------

## axxackall

 *olivierweb wrote:*   

> 
> 
> this was not enough, so I do this :
> 
>  *b0d0r wrote:*   also if you comment out or remove the <ifdefine> and </ifdefine> for each module that you want to use... you will find that will get it to work...
> ...

 

Certainly it's a bug related to Gentoo as such ifdefine constructs work fine on redhat, slackware, freebsd and win2k.

----------

## tgoodaire

Is this apache-1 or apache-2 that you're having problems with? I successfully installed apache-2 with mysql and mod_php today with hardly any problems. The only problem that I had was convincing mod_php that I don't want xfree and qt installed. A quick search through the forums found the fix for that...

----------

## azote

how did ou do that?

----------

## hungarian

This worked for me:

You need to follow the order of includes, see the comments in

/etc/apache/conf/apache.conf

Here is what works for me using Apache 1.3.27 and PHP 4.3.1

# $Header: /home/cvsroot/gentoo-x86/net-www/apache/files/conf/apache.conf,v 1.2 2002/05/04 23:23:01 woodchip Exp $

### Main Configuration Section

### You really shouldn't change these settings unless you're a guru

###

ServerType standalone

ServerRoot /etc/apache

ServerName localhost

#LockFile /etc/httpd/httpd.lock

PidFile /var/run/apache.pid

ScoreBoardFile /etc/apache/apache.scoreboard

ErrorLog logs/error_log

LogLevel warn

ResourceConfig /dev/null

AccessConfig /dev/null

DocumentRoot /home/httpd/htdocs

### Dynamic Shared Object (DSO) Support

### 

###

LoadModule mmap_static_module modules/mod_mmap_static.so

LoadModule env_module         modules/mod_env.so

LoadModule config_log_module  modules/mod_log_config.so

LoadModule agent_log_module   modules/mod_log_agent.so

LoadModule referer_log_module modules/mod_log_referer.so

LoadModule mime_magic_module  modules/mod_mime_magic.so

LoadModule mime_module        modules/mod_mime.so

LoadModule negotiation_module modules/mod_negotiation.so

LoadModule status_module      modules/mod_status.so

LoadModule info_module        modules/mod_info.so

LoadModule includes_module    modules/mod_include.so

LoadModule autoindex_module   modules/mod_autoindex.so

LoadModule dir_module         modules/mod_dir.so

LoadModule cgi_module         modules/mod_cgi.so

LoadModule asis_module        modules/mod_asis.so

LoadModule imap_module        modules/mod_imap.so

LoadModule action_module      modules/mod_actions.so

LoadModule speling_module     modules/mod_speling.so

LoadModule userdir_module     modules/mod_userdir.so

LoadModule proxy_module       modules/libproxy.so

LoadModule alias_module       modules/mod_alias.so

LoadModule rewrite_module     modules/mod_rewrite.so

LoadModule access_module      modules/mod_access.so

LoadModule auth_module        modules/mod_auth.so

LoadModule anon_auth_module   modules/mod_auth_anon.so

LoadModule dbm_auth_module    modules/mod_auth_dbm.so

LoadModule db_auth_module     modules/mod_auth_db.so

LoadModule digest_module      modules/mod_digest.so

LoadModule cern_meta_module   modules/mod_cern_meta.so

LoadModule expires_module     modules/mod_expires.so

LoadModule headers_module     modules/mod_headers.so

LoadModule usertrack_module   modules/mod_usertrack.so

LoadModule example_module     modules/mod_example.so

LoadModule unique_id_module   modules/mod_unique_id.so

LoadModule setenvif_module    modules/mod_setenvif.so

<IfDefine PHP4>

LoadModule php4_module        extramodules/libphp4.so

</IfDefine>

LoadModule vhost_alias_module	modules/mod_vhost_alias.so

#  Reconstruction of the complete module list from all available modules

#  (static and shared ones) to achieve correct module execution order.

#  [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]

ClearModuleList

AddModule mod_mmap_static.c

AddModule mod_env.c

AddModule mod_log_config.c

AddModule mod_log_agent.c

AddModule mod_log_referer.c

AddModule mod_mime_magic.c

AddModule mod_mime.c

AddModule mod_negotiation.c

AddModule mod_status.c

AddModule mod_info.c

AddModule mod_include.c

AddModule mod_autoindex.c

AddModule mod_dir.c

AddModule mod_cgi.c

AddModule mod_asis.c

AddModule mod_imap.c

AddModule mod_actions.c

AddModule mod_speling.c

AddModule mod_userdir.c

AddModule mod_proxy.c

AddModule mod_alias.c

AddModule mod_rewrite.c

AddModule mod_access.c

AddModule mod_auth.c

AddModule mod_auth_anon.c

AddModule mod_auth_dbm.c

AddModule mod_auth_db.c

AddModule mod_digest.c

AddModule mod_cern_meta.c

AddModule mod_expires.c

AddModule mod_headers.c

AddModule mod_usertrack.c

AddModule mod_example.c

AddModule mod_unique_id.c

AddModule mod_so.c

AddModule mod_setenvif.c

<IfDefine PHP4>

AddModule mod_php4.c

</IfDefine>

AddModule mod_vhost_alias.c

###

### Global Configuration

###

# Splitting up apache.conf into two files makes it possible to support

# multiple configurations on the same serer.  In commonapache.conf

# you keep directives that apply to all implementations and in this

# file you keep server-specific directives.  While we don't yet have

# multiple configurations out-of-the-box, this allows us to do that

# in the future easily.

Include conf/commonapache.conf

###

### IP Address/Port

###

#BindAddress *

Port 80

Listen 80

###

### Log configuration Section

###

# Single logfile with access, agent and referer information

# This is the default, if vlogs are not defined for the main server

CustomLog logs/access_log combined env=!VLOG

# If VLOG is defined in conf/vhosts/Vhosts.conf, we use this entry

#CustomLog "|/usr/sbin/apachesplitlogfile" vhost env=VLOG

###

### Virtual Hosts 

###

# We include different templates for Virtual Hosting. Have a look in the 

# vhosts directory and modify to suit your needs.

#Include conf/vhosts/Vhosts.conf

#Include conf/vhosts/DynamicVhosts.conf

#Include conf/vhosts/VirtualHomePages.conf

###

### Performance settings Section

###

#

# Timeout: The number of seconds before receives and sends time out.

#

Timeout 300

#

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

#

KeepAlive On

#

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you leave this number high, for maximum performance.

#

MaxKeepAliveRequests 100

#

# KeepAliveTimeout: Number of seconds to wait for the next request from the

# same client on the same connection.

#

KeepAliveTimeout 15

#

# Server-pool size regulation.  Rather than making you guess how many

# server processes you need, Apache dynamically adapts to the load it

# sees --- that is, it tries to maintain enough server processes to

# handle the current load, plus a few spare servers to handle transient

# load spikes (e.g., multiple simultaneous requests from a single

# Netscape browser).

#

# It does this by periodically checking how many servers are waiting

# for a request.  If there are fewer than MinSpareServers, it creates

# a new spare.  If there are more than MaxSpareServers, some of the

# spares die off.  The default values are probably OK for most sites.

#

MinSpareServers 4

MaxSpareServers 10

#

# Number of servers to start initially --- should be a reasonable ballpark

# figure.

#

StartServers 4

#

# Limit on total number of servers running, i.e., limit on the number

# of clients who can simultaneously connect --- if this limit is ever

# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.

# It is intended mainly as a brake to keep a runaway server from taking

# the system with it as it spirals down...

#

MaxClients 150

#

# MaxRequestsPerChild: the number of requests each child process is

# allowed to process before the child dies.  The child will exit so

# as to avoid problems after prolonged use when Apache (and maybe the

# libraries it uses) leak memory or other resources.  On most systems, this

# isn't really needed, but a few (such as Solaris) do have notable leaks

# in the libraries. For these platforms, set to something like 10000

# or so; a setting of 0 means unlimited.

#

# NOTE: This value does not include keepalive requests after the initial

#       request per connection. For example, if a child process handles

#       an initial request and 10 subsequent "keptalive" requests, it

#       would only count as 1 request towards this limit.

#

MaxRequestsPerChild 500

Include  conf/addon-modules/mod_php.conf

---------END of apache.conf--------------

----------

## wody

I have a very strange apache / mod_php problem here.

I just followed all your suggestions, included "apache" in USE flag, loaded the module in the apache configs und if i try to start it via

/etc/init.d/apache start

there are NO problems as log as the -D PHP4 option is _NOT_ specified in /etc/conf.d/apache...

If I include that line, the apache server doesn't even start. The script returns no error, indeed it says [OK]; but ps tells me, no apache is running at all....

Any way for me to get the php module running here... ??

P.S. With apache2, the same problems...

Thanks a lot

----------

## itkovian

Well, as of this morning I got PHP working with Apache and MySQL. I use apache2 and mysql-3.23.54a. PHP is 4.3.1. What did I do?

I looked though the above suggestions. 

a) I have included -D PHP in /etc/conf/apache2 in the APACHE2_OPTS, -D SSL was already present there

b) I have looked at /etc/apache2/conf/apache2.conf and notices that 70_mod_php.conf from

/etc/apache2/conf/modules.d was included (in fact all stuff from the aforementioned dir was included)

c) I have started apache with the /etc/init.d/apache2 start script. 

Hope this helps somewhat.

----------

## hungarian

Not meant to be flaming, but why bother using mysql when you can have PostgreSQL.

I used to start with mysql and I do not even think about using it now.

The speed argument do not work either according to the devshed articles and benchmarks.

Comments are welcome.

----------

## flickerfly

I'm having the same problem, but have an intersting thing to note.  It asks me to download/run w/ an external program with phoenix from a remote machine, but if I use lynx on localhost I am able to get php to work.  (Good old lynx  :Smile:  )  lynx on the same remote machine as phoenix asks me to download.  This seems (with me at least) to be related to a remote and local issue.  I don't have X installed on the server to test another browser.

Let me put what I just said in chart form (I like it that way better):

on localhost

lynx 127.0.0.1/install.php .......... works

lynx 192.168.x.x/install.php ...... works

on remote workstation

phoenix 192.168.x.x/index.html . works

phoenix 192.168.x.x/index.php .. error

phoenix 192.168.x.x/install.php . broken

lynx 192.168.x.x/install.php ...... broken

KEY

works == shows normally

error == shows a php error (due to yet to be installed PostNuke)

broken == asks to download the file

I've instituted all the suggestions above and re-emerge it all to the masked versions (except mysql).  I'm now running :

apache2 (2.045) 

mod_php-4.3.1-r1  

php-4.3.1-r1  

mod_ssl-2.8.14  

mysql-3.23.56 

The only thing with apache2 I couldn't find anything to do with AddModule so I didn't mess with that suggestion after upgrading to apache2.  I can see html pages on the same server from the remote sight.

Any help to get this running would be of great appreciation.

----------

## itkovian

I had the same with phoenix. Iirc, I cleaned the disk and memory cache of the browser and all was well.

----------

## flickerfly

 *itkovian wrote:*   

> I had the same with phoenix. Iirc, I cleaned the disk and memory cache of the browser and all was well.

 

That didn't change a thing for me, beside there was nothing there for it to cache before I started trying to get to it.  I don't know if lynx even has a cache.

----------

## flickerfly

Funny thing happened.  Once I setup postnuke on the server, I was able to login and php worked as advertised.  If you're using postnuke, try setting it up in lynx first.

----------

