# Apache2 & PHP4 - Frustration reaching boiling point

## Crimson Rider

Help, I can't make it any plainer then this. Help!

I've recently upgraded apache2 and now no matter what I do I can't get it to work with PHP anymore. 

I've recompiled, I've reinstalled. I've cleared the caches and I've followed just about every link, article and post I could find.

Bottom line, it no worky.

I've installed dev-php/php and apache2, I've modified conf/apache2 to use OPT=-D DEFAULT_VHOSTS -DAV - PHP4

But every time I load up the page, it prompts me to save the php file, and doesn't process it. Please, somebody, alleviate my frustration as my keyboard is not going to survive it otherwise.

I am using virtual hosts, so that could complicate things, I am trying without them now actually.

----------

## Taily

A good start would be to clear firefoxes cache, sometimes if you try when it's not actually working, then try the same file when it is working it will still want to download it.

Also as i pointed out in this topic, you shouldn't use dev-php anymore.

After you've emerged =dev-lang/php-4* just edit /etc/conf.d/apache2 to include -D PHP4

Hope this helps

also

 *Quote:*   

> OPT=-D DEFAULT_VHOSTS -DAV - PHP4

 

should be

```
OPT="-D DEFAULT_VHOSTS -D PHP4"
```

no?

----------

## Crimson Rider

Okidoki.

I cleared firefox cache so often by now it has forgotten all my passwords  :Smile: 

I am gonna kick dev-php out, and take dev-lang/php in 

I saw the typo, thanx

Thanks for the reply.

----------

## Taily

By no means did i mean that you can't use dev-php/php and mod_php  :Wink: 

Also remember some things come default with dev-php/php and not with dev-lang/php.

Some flags in /etc/portage/package.use you might want are

dev-lang/php session pcre

refrence: http://svn.gnqs.org/projects/gentoo-php-overlay/wiki/NewUseFlags

Well for me atleast  :Wink: 

----------

## Crimson Rider

Well, the good news, PHP works again. The bad news, not with SquirrelMail, is there a way to make that work, or do I need PHP4 for that?

thanks in advance.

----------

## Taily

Sorry i know nothing about squirrelmail, in what way is it associated with php? Is it some kind of php interface for users to access via the web?

If that's the case then what are the errors etc :/?

----------

## Monkeh

Squirrelmail is a PHP powered webmail interface.  :Wink:  And a very common one.. Probably broken by PHP5. *googles for info*

----------

## DNAspark99

i've got squirrelmail and php5 working together, no problems, so what errors are you getting?

----------

## Crimson Rider

These kinds, also in PhpBB

```
Fatal error: Call to undefined function session_id() in /var/www/localhost/htdocs/squirrelmail/functions/global.php on line 293
```

```

Fatal error: Call to undefined function preg_match() in /opt/bluepelt/forum/includes/sessions.php on line 227
```

Ring any bells? Any hints?

----------

## Crimson Rider

Indeed, Squirrelmail is great. It's webmail for nuts. It uses IMAP to connect to my local server and give me a nice webinterface to enable me to read mail everywhere. It's so common a use of PHP that I assumed everyone knew it, my bad.

Give it a try sometimes, it's a great piece of software. On another note, I also got problems using phpBB atm.

----------

## Monkeh

What USE flags did you compile php with?

----------

## Taily

Yes, those are exactly the errors you get unless you have the use options pcre and session  :Wink: 

Check my above post with refrence to the new useflags for dev-lang/php

----------

## Crimson Rider

I just checked phpinfo, and there I saw this

'./configure' '--prefix=/usr/lib/php5' '--sysconfdir=/etc' '--cache-file=./config.cache' '--disable-cli' '--with-apxs2=/usr/sbin/apxs2' '--with-config-file-path=/etc/php/apache2-php5' '--with-config-file-scan-dir=/etc/php/apache2-php5/ext' '--without-pear' '--disable-bcmath' '--without-bz2' '--disable-calendar' '--disable-ctype' '--with-curl' '--without-curlwrappers' '--disable-dbase' '--disable-exif' '--without-fbsql' '--without-fdftk' '--disable-filepro' '--disable-ftp' '--with-gettext' '--without-gmp' '--without-hwapi' '--without-iconv' '--without-informix' '--without-jpeg-dir' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--without-mcve' '--disable-memory-limit' '--without-mhash' '--without-ming' '--without-msql' '--without-mssql' '--with-ncurses' '--without-oci8' '--without-oracle' '--with-openssl' '--with-openssl-dir=/usr' '--without-ovrimos' '--disable-pcntl' '--without-pcre-regex' '--without-pfpro' '--without-pgsql' '--disable-posix' '--without-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--disable-soap' '--disable-sockets' '--disable-spl' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--without-xmlrpc' '--without-xsl' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--with-db4' '--without-flatfile' '--with-gdbm' '--without-inifile' '--without-qdbm' '--without-freetype-dir' '--without-t1lib' '--enable-gd-jis-conv' '--disable-gd-native-ttf' '--without-png-dir' '--with-tiff-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-mysql=/usr/lib/mysql' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--without-mysqli' '--with-readline' '--without-libedit' '--disable-session' '--without-sqlite'

I am guessing that's the problem. Is session a USE flag I can enable?

----------

## Crimson Rider

re-emerging with

/etc/portage/package.use

```
dev-lang/php apache2 gd session pcre
```

and

 emerge '=dev-lang/php-4*' '=dev-lang/php-5*'

----------

## Taily

I really think session and pcre should be enabled by default :/.. They're so common

just so you know, pcre is for all the preg_* commands

EDIT: Yeah, those useflags soud good  :Wink: 

Really doubt you need both php4 and 5 though, its upto you.. you can use eselect to select the php version you use (and -D PHP{4,5} for apache  :Smile: )Last edited by Taily on Wed Oct 19, 2005 7:09 pm; edited 2 times in total

----------

## Crimson Rider

Got it, now it's the waiting game.

Thanx for the help so far guys.

----------

## Crimson Rider

Okay, phpBB is working, but Squirrelmail still not, even after recompile, still it's faulty.

```
Fatal error: Cannot re-assign $this in /var/www/localhost/htdocs/squirrelmail/class/mime/Message.class.php on line 182
```

Any clues guys?

----------

## Taily

Yeah, i think it's a problem with using the variable $this and php5

You can try using php4, upgrading squirrelmail to a version that supports php5 or edit the files of squirrelmail not to use the variable $this.. change $this for example $foobar  :Smile: 

----------

## Monkeh

 *Quote:*   

>  Fatal error: Cannot re-assign $this
> 
>     * If you use php 5.0.x, use latest stable squirrelmail version (currently 1.4.4) or 1.5.1cvs.
> 
>     * If you still can reproduce this error in latest stable version with php register_globals set to off, provide more details to SquirrelMail developers.
> ...

 

----------

## Crimson Rider

Well, the troubles continue.

Both phpBB and Squirrelmail give me these errors as the latest and greatest version of PHP5,

Squirrelmail gives me this instead of the list of mail messages, even tough it logs in fine and shows me the mail tree.

```
Fatal error: Only variables can be passed by reference in /var/www/localhost/htdocs/squirrelmail/functions/imap_messages.php on line 480
```

phpBB gives up with this after I try to post

```
Fatal error: Only variables can be passed by reference in /opt/bluepelt/forum/posting.php on line 554
```

With register globals off or on btw.

Any clues now ?

Many thanx for the help so far, I feel I am close, but I need to get a little closer.

----------

## McManus

Same problem here.  I added in the USE flags they mentioned at first:  cli pcre xml zlib.  Then I added in the dba and the gd (it complained about having both gd and gd-external, so I left it with just gd) and the session (that was 3 additional recompiles) and here I am.

[rant] Everytime there's a major upgrade to something that involves Apache2 (most noticeably mysql and php, and the Apache2 re-org of its config files) my system goes haywire.  It's been quite painful, to be honest (mostly for my users). [/rant]

Any ideas?

----------

## llongi

 *McManus wrote:*   

> Any ideas?

 

Yup, read the docs...  :Rolling Eyes: 

http://www.gentoo.org/proj/en/php/

Also, the migration to dev-lang/php is quite easy, the only pitfall may be forgetting to enable a USE flag, but that's you that need to check them and see if you want them, like "session" is probably something you want... But we're working anyway with the arch-teams to get those "most important" USE flags into the default profiles, so they will be enabled by default in the future and if you just install a new system and type "emerge dev-lang/php", it will give you a mostly usable PHP (still check the flags, always!).

----------

## clsmyth

Actually, http://www.squirrelmail.org/wiki/BrowseProblemsByPhpError was more help for me.  It showed me I had to edit (patch) imap_messages.php .  I did as it said and I was able to see my inbox.  But then I couldn't display a message.  So I used the same technique on the file indicated by that errror (Rfc822Header.class.php) and I was able to display messages.  I am hopeful that all the "Only variables can be passed by reference" type errors can be handled this way.

----------

## McManus

 *CHTEKK wrote:*   

>  *McManus wrote:*   Any ideas? 
> 
> Yup, read the docs... 
> 
> http://www.gentoo.org/proj/en/php/
> ...

 

Oh give me a break.  Think I haven't read any docs?  I've had to dig through at least 3 separate docs to compile the list of USE flags required, and even then the migration is still painful;  it's not as simple as "you forgot to enable a USE flag".  I'm pretty sure my problem is that some (or actually, just _parts_ of) my php apps still depend on php4, where some parts could work on php5.  My complaint is that my system complained about wanting to install dev-lang/php and I so I did, not realizing that it would break php4 apps since it installs php5.

A better way to do this would have been to assign php4 flags to all current php apps, then switch the ones known to work with php5 to use a php5 flag, so portage would've automatically installed both 4 and 5.  It would be still be up to the user to configure their webserver, but at least that's one unknown solved.  That's how I would've done it, anyways.

----------

