PDA

View Full Version : php5 and php4 at the same time


Hans
10th February 2006, 14:05
I have read this "how to" with great interest:

http://www.howtoforge.com/apache2_with_php5_and_php4

I have a question about it:

Is it possible to add this as a little extra to a server running Debian 3.1 according "the perfect setup" including ISPConfig?

Or do i have to do this in another way?

falko
10th February 2006, 15:58
Is it possible to add this as a little extra to a server running Debian 3.1 according "the perfect setup" including ISPConfig?


Yes, but I'd then put AddHandler php-script .php4
Action php-script /cgi-bin/php4 into each Vhost seperately (using the Apache Directives field of ISPConfig) because otherwise PHP4 is always on (for every web site).
Also check the PHP5 configuration: PHP5 should not be enabled globally, so you must change /etc/apache2/mods_available/php5.conf (otherwise PHP5 is enabled for every web site, no matter what you specify in ISPConfig).

gog
15th February 2006, 01:23
I've done it just today. I had a stable debian sarge system, running apache2, mysql-4.1, and php4 (all the modules installed in "the perfect setup").

I've decided to let php4 run like apache2 module, as it is in "the perfect setup", and I just wanted to add php5 as a cgi.

I just ran:

apt-get install php5-cgi

Then I had to edit my "httpd.conf" file, or better to say one virtaul host's directives. A added a line in one of the <VirutalHost...> entries:


AddHandler php-scriptt .php
Action php-scriptt /cgi-bin/php5


Notice the 2 tt's in the config file!!! I had to do it this way cause otherwise php4 always parsed the file in that directory, even when I tried to use .php5 extension.

I also added "Options +ExecCGI" to that directory, just in case, not shure if it's really needed.

This works like a charm, a can set php4/php5 on "per virtualhost" bases, or even per directory if I want to. Also, I don't need to change extension and do a search&replace on every skript that needs to be in PHP5. Not to mention the trouble you have to go, upgradeing one og these scripts...

It's kinda late now, have to catch some sleep :) I just need to install a cople more things, I want to install


apt-get install php5-curl php5-dev php5-gd php5-gmp php5-imap php5-ldap php5-mcrypt php5-mhash php5-ming php5-mysql php5-mysqli php5-odbc php5-pdo-mysql php5-pdo-sqlite php5-pear php5-pspell php5-snmp php5-sybase php5-tidy

(I'm not touching any php4 modules)

but I get a warning

The following packages will be REMOVED:
php4-dev php4-pear

Hm, what to do? :) I would really like to leave pear repository for php4...

falko
15th February 2006, 10:32
It's kinda late now, have to catch some sleep :) I just need to install a cople more things, I want to install


apt-get install php5-curl php5-dev php5-gd php5-gmp php5-imap php5-ldap php5-mcrypt php5-mhash php5-ming php5-mysql php5-mysqli php5-odbc php5-pdo-mysql php5-pdo-sqlite php5-pear php5-pspell php5-snmp php5-sybase php5-tidy

(I'm not touching any php4 modules)

but I get a warning

The following packages will be REMOVED:
php4-dev php4-pear

Hm, what to do? :) I would really like to leave pear repository for php4...
If you want to keep Pear for PHP4, then don't install the Pear package for PHP5 (php5-pear).

gog
15th February 2006, 10:46
Yep, that's it. It work great! Maybe you should think of rewriting your original article? Or would you like me to write a new article "PHP5 extends The Perfect Setup - Debian Sarge (3.1)" :) ?

falko
15th February 2006, 21:46
Maybe you should think of rewriting your original article?
Why should I rewrite it? It's working... :)

fbnewtz
28th September 2006, 07:17
Whenever I try and run the following line I get the following output:

apt-get install php5-curl php5-dev php5-gd php5-gmp php5-imap php5-ldap php5-mcrypt php5-mhash php5-ming php5-mysql php5-mysqli php5-odbc php5-pdo-mysql php5-pdo-sqlite php5-pear php5-pspell php5-snmp php5-sybase php5-tidy php4-curl php4-domxml php4-gd php4-gmp php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-ming php4-mysql php4-odbc php4-pspell php4-recode php4-snmp php4-xslt php4-xdebug curl libwww-perl imagemagick


Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
php5-curl: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-gd: Depends: phpapi-20041225
php5-gmp: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-imap: Depends: phpapi-20041225
php5-ldap: Depends: phpapi-20041225
php5-mcrypt: Depends: phpapi-20041225
php5-mhash: Depends: phpapi-20041225
php5-ming: Depends: phpapi-20041225
php5-mysql: Depends: phpapi-20041225
php5-mysqli: Depends: phpapi-20041225
php5-odbc: Depends: phpapi-20041225
php5-pdo-mysql: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-pdo-sqlite: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-pear: Depends: php5-cli but it is not going to be installed
php5-pspell: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-snmp: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-sybase: Depends: libct1 but it is not going to be installed
Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
php5-tidy: Depends: phpapi-20041225
Depends: php5-common (= 5.1.6-0.dotdeb.2) but 5.1.6-1 is to be installed
E: Broken packages


Any ideas? I had different servers in my sources.list file, but I made a copy and created a new sources.list file with the same source as you specify in the server config.

I am running the Debian Perfect server setup with Ruby and FastCGI.

Thanks,

Fred

falko
29th September 2006, 14:52
I had different servers in my sources.list file
That's the reson for your problem.

but I made a copy and created a new sources.list file with the same source as you specify in the server config.

That doesn't help because your system still has the packages of the other repositories in its package database.

Berry
21st November 2006, 16:48
Sorry for reopening older post, I try to install those packages from gog's post, but I get errors
E: Package php5-mysqli has no installation candidate
E: Couldn't find package php5-pdo-mysql

I used Falco's sources links, did something change with those source links?...

EDIT: I tried also other source servers, for example :
deb http://dotdeb.pimpmylinux.org/ stable all
deb-src http://dotdeb.pimpmylinux.org/ stable all

but no success. Can someone point me to alternatives? Thanks!

falko
22nd November 2006, 17:23
Maybe there is no package for php5-mysqli. You can search for all available PHP5 packages by running
apt-cache search php5
And make sure you run
apt-get update whenever you change /etc/apt/sources.list!

Berry
22nd November 2006, 17:31
Falko,thanks for reply!

No, there are no such packages as php5-mysqli or php5-pdo-*. Are they crutial?

Here is my sources.list :
deb ftp://ftp.debian.org/debian stable main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free

#Host Europe server:
#deb ftp://80.237.136.138/mirror/ftp.debian.org/debian/ sarge main contrib non-free
deb ftp://ftp.hosteurope.de/mirror/ftp.debian.org/debian/ sarge main
deb-src ftp://ftp.hosteurope.de/mirror/ftp.debian.org/debian/ sarge main

deb http://dotdeb.pimpmylinux.org/ stable all
deb-src http://dotdeb.pimpmylinux.org/ stable all

#deb http://ftp2.de.debian.org/debian/ stable main
#deb-src http://ftp2.de.debian.org/debian/ stable main


and here apt-cache search php5 :
libapache-mod-php5 - server-side, HTML-embedded scripting language (apache 1.3 module)
libapache2-mod-php5 - server-side, HTML-embedded scripting language (apache 2.0 module)
php-pear - PEAR - PHP Extension and Application Repository
php5 - server-side, HTML-embedded scripting language (meta-package)
php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-imap - IMAP module for php5
php5-ldap - LDAP module for php5
php5-mcrypt - MCRYPT module for php5
php5-mhash - MHASH module for php5
php5-ming - Ming module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - Pspell module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-sybase - Sybase / MS SQL Server module for php5
php5-tidy - Tidy module for php5
php5-xmlrpc - XML-RPC module for php5
php5-xsl - XSL module for php5
php4-pear - PHP Extension and Application Repository (transitional package)
php5-apc - apc module for php5
php5-suhosin - suhosin module for php5

falko
23rd November 2006, 17:45
Falko,thanks for reply!

No, there are no such packages as php5-mysqli or php5-pdo-*. If the packages don't exist, then don't try to install them. ;) I don't think it's a problem.

WhosRodney
21st August 2007, 02:08
Hello,

I am running Sarge 3.1, Apache2, and php4. I installed php5-cgi in order to have php5 parse a single directory that I need parse by php5, and not php4. I followed the tutorials, and added this to my virtual host file:

<Directory /my/directory/>
AddHandler php5-cgi .php
Action php5-cgi /usr/lib/cgi-bin/php5

Options +ExecCGI
</Directory>

Unfortunately, however, when I navigate to www.example.com/my/directory/info.php, I get an Error 404, Object Not Found error. Outside of /my/directory, though, php4 works as normal.

If anybody knows how to remedy this problem, please let me know. Thanks.

sjau
21st August 2007, 12:20
Well, the path in the action is not the server path but "web path". You are actually pointing it to /my/directory/usr/lib/cgi-bin/php5

what I did is the following:

I copied the php4 binary (I use php4 now a cgi for a few things that don't run yet on php5) to my websites cgi folder:

e.g.

/my/directory/cgi-bin/php5

Then I set accordings permissions to the cgi-bin folder and the binary.

and then I just put an .htaccess file within that web - whereever I want to use php as php4.


AddHandler php-script .php
Action php-script /cgi-bin/php4


So for you, just put the php5 binary in a cgi-bin folder, make sure the folder's and the binary's permissions are ok and then you can fine-grain directory by directory where you want to use what :)

Oh, regarding the php.ini - I have now to edit /etc/php4/cgi/php.ini to alter my php4-cgi ini ;)

schmidtedv
21st October 2008, 15:01
Yes, but I'd then put AddHandler php-script .php4
Action php-script /cgi-bin/php4 into each Vhost seperately (using the Apache Directives field of ISPConfig) because otherwise PHP4 is always on (for every web site).
Also check the PHP5 configuration: PHP5 should not be enabled globally, so you must change /etc/apache2/mods_available/php5.conf (otherwise PHP5 is enabled for every web site, no matter what you specify in ISPConfig).


I got ISPConfig 2.2.27 and Debian Etch (php5) out of the Perfect HowTo and now just installed php4-cgi and some modules without a problem. If I give it a try and just put

AddHandler php-script .php4
Action php-script /cgi-bin/php4

into my vhosts-config and restart apache, i get an error by testing info.php4. Others like info.php still run on php5 so far. If I change this to

AddHandler php-script .php
Action php-script /cgi-bin/php4

just for testing it runs the info.php4 but on php5....is there something wrong or else to do within debian etch to just get php4 working on testscripts?

falko
22nd October 2008, 14:02
Any errors in Apache's error log or the web site's error log?