PHP5.2 and PHP4 on Virtualmin GPL

I know there’s an option on Virtualmin Pro to setup virtual servers with PHP4 or PHP5. I am using Virtualmin GPL with PHP5.2.6 and last week I have found a PHP script (with MySQL DB) that is written for PHP4 and doesn’t work that fine on PHP5.2.6.

So I would like to know if there maybe is a slight chance to do something with my CentOS v5.2 server with latest updates (also for Web- and Virtualmin) so I can also install PHP4 and leave PHP5 installed and working on the same server?

I only need PHP4 for this one script, too bad my PHP knowledge is too little to convert the script, so that’s why I’m hoping I could maybe solve the issue with PHP4 and PHP5 on the same server…I really really would like to use this script :slight_smile:

Molski

Hi…I’m back again :slight_smile:

After reading some topics on the forum and some of the documentation I have installed PHP4 from the Virtualmin repository.

After installing I found the php4.conf file in /etc/httpd/conf.d directory and edited with vim to the following and restarted httpd:

[code:1]

PHP is an HTML-embedded scripting language which attempts to make it

easy for developers to write dynamically generated webpages.

LoadModule php4_module modules/libphp4.so

Cause the PHP interpreter to handle files with a .php extension.

#AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4

Add index.php to the list of files that will be served as directory

indexes.

DirectoryIndex index.php4
[/code:1]

In my php.conf (for PHP5) I also added a line like this: "AddType application/x-httpd-php .php5"

Unfortunately, only disabling the libphp5.so module in my php.conf file will load PHP4.4.8 with apache, how can I make sure that PHP4 (which loads without errors on apache) will be active for a particular domain?

Regards,

Molski

Okay,

Right now I am at the following point:

  • Installed mod_fcgi from the Virtualmin repo
  • Installed PHP4 from the Virtualmin repo and enabled it in /etc/httpd/conf.d/php4.conf

[code:1]LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
DirectoryIndex index.php4[/code:1]

  • SuExec is compiled with ‘-D AP_DOC_ROOT="/home"’
  • Copied /etc/php4/php.ini to /home/domain/etc/php4/php.ini
  • Created /home/domain/fcgi-bin/php4.fcgi with the following lines:

[code:1]#!/bin/bash
export PHPRC=$PWD/…/etc/php4/php.ini
#PHPRC=$PWD/…/etc/php4/php.ini
#export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi[/code:1]

  • Created /home/domain/public_html/httpd.conf and added the following lines:

[code:1]<Directory /home/domain/public_html>
Options Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php4
FCGIWrapper /home/domain/fcgi-bin/php4.fcgi .php
</Directory>
<Directory /home/domain/cgi-bin>
allow from all
</Directory>
RemoveHandler .php
RemoveHandler .php4[/code:1]

  • chowned the new created folders and files to the correct user:group
  • Restarted httpd without any errors.

When I try to load a PHPinfo page I get the following output:

  • phpinfo.php :: PHP Version 5.2.6
  • phpinfo.php4 :: PHP Version 5.2.6
  • phpinfo.php5 :: PHP Version 5.2.6

My /var/log/https/suexec/log shows the following output:

[2008-12-21 00:24:47]: uid: (user:group) gid: (user:group) cmd: php4.fcgi

It looks like I have some misconfiguration somewhere, but I cannot find it.
Does somebody maybe sees what misconfiguration I have?

The PHP command being called by php4.fcgi in your case is "/usr/bin/php-cgi".

So, what’s the output of this:

/usr/bin/php-cgi -v

It’s possible that’s PHP5 rather than PHP4. If so, just make sure thats pointed at the right PHP version.
-Eric

Hi Eric,

The output is as follows:

[code:1][root@vm1 ~]# /usr/bin/php-cgi -v
PHP 5.2.6 (cgi-fcgi) (built: Sep 27 2008 17:51:16)[/code:1]

So it looks like something goes wrong there.
I can also not find any php-cgi file from v4 on my system…maybe it’s there, but I sure cannot find it :slight_smile:

Do you maybe got any pointers for me where to look or what to do?

Regards,

Molski

You probably have PHP4 available as something like "/usr/bin/php4-cgi".

Put that in place of the last line in your php4.fcgi file.
-Eric

Nope, unfortunately not :frowning:
I installed all PHP4 Packages from the Virtualmin repo (via yum), but in /usr/sbin only, php, php4 and php-cgi (from v5.2.6) are found.

What RPM file on the Virtualmin repo holds the php-cgi file, do you maybe know that (or Joe…) ?

What do you get when you type this:

rpm -qa | grep php

Next, what does this show:

find /usr/bin | grep php

Hi,

"rpm -qa | grep php" Shows me the following output:

[code:1][root@vm1]# rpm -qa | grep php
php-common-5.2.6-1.el5.vmbleed
php-mbstring-5.2.6-1.el5.vmbleed
php-pecl-mailparse-2.1.4-1.fc9
php-pdo-5.2.6-1.el5.vmbleed
php-mcrypt-5.2.6-1.el5.vmbleed
php-pear-1.4.9-4.el5.1
php-mysql-5.2.6-1.el5.vmbleed
php-5.2.6-1.el5.vmbleed
php-xml-5.2.6-1.el5.vmbleed
php-cli-5.2.6-1.el5.vmbleed
php-imap-5.2.6-1.el5.vmbleed
php4-4.4.8-1vm.i386.rpm
php4-mbstring-4.4.8-1vm.i386.rpm
php4-domxml-4.4.8-1vm.i386.rpm
php4-mysql-4.4.8-1vm.i386.rpm
php4-gd-4.4.8-1vm.i386.rpm
php4-pear-4.4.8-1vm.i386.rpm
php4-imap-4.4.8-1vm.i386.rpm
php4-xmlrpc-4.4.8-1vm.i386.rpm
[/code:1]

And the command "find /usr/bin | grep php" shows me:

[code:1][root@vm1]# find /usr/bin | grep php
/usr/bin/php-cgi
/usr/bin/php
/usr/bin/php4[/code:1]

And "/usr/bin/php-cgi -v" shows me:

[code:1][root@vm1]# /usr/bin/php-cgi -v
PHP 5.2.6 (cgi-fcgi) (built: Sep 27 2008 17:51:16)[/code:1]

Looks like php-cgi is only available for PHP5, do I maybe need a file called php-cgi4 or soomething, or php-cgi but in another directory?

So if you type "yum whatprovides php4-cgi", does anything show up?

Also, what does this show:

/usr/bin/php4 -v