Getting PHP4 in Virtualmin GPL

17 posts / 0 new
Last post
#1 Wed, 01/07/2009 - 16:21
zugg

Getting PHP4 in Virtualmin GPL

OK, I've searched through many forum posts and documentation articles, but I still cannot figure out how to get PHP4 on my system. I am a linux novice, so please try to explain things clearly...I don't know a lot of the "linux geek speak" stuff yet.

My system is CentOS 5.2. When I use "yum list" I can see that there are several php4* packages available via the virtualmin repository. So I did:

yum install php4*

and it seemed to work ok. However, when I do "php4 -v" I get this:

PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib64/php4/mysqli.so' - /usr/lib64/php4/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib64/php4/pdo_mysql.so' - /usr/lib64/php4/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP 4.4.8 (cgi-fcgi) (built: Jun 24 2008 15:14:16) Copyright (c) 1997-2008 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

So it looks like there is something for PHP4 and MySQL missing from this.

At this point I can't even start trying to get PHP4 working for one of my virtual sites that needs it because of this error.

Could someone please give me some step-by-step instructions on how to get PHP4 and PHP5 both running on my CentOS system. I'm happy to do stuff manually at the root linux shell outside of Virtualmin as necessary.

I know that the "easy" switch between PHP4 and PHP5 are only in the Pro paid version of Virtualmin. Several people in other forum threads seem to think that it is straight-forward to do this manually in the GPL version, but I cannot figure it out.

If someone can help me get this working, then I can buy VirtualminPro. But until I can see PHP4 and PHP5 sites running on the same server, I cannot buy anything.

Fri, 01/09/2009 - 07:28
zugg

sgrayban: give us a break.

We all *know* that PHP4 is dead and no longer supported. But some of us have some very complex PHP4 sites that do not work with PHP5 and it takes a lot of time and effort to convert.

I know that I'm not getting paid anything to convert my site from PHP4 to PHP5 and it's probably going to take me over a month of night-time work to get it done. Yes, some of us actually have some large and complex sites that are not trivial to convert. It's not the conversion itself that takes most of time, but it's the testing of every little nook and cranny of the site to make sure it's really all working properly and doesn't have any new security holes.

So that's a month of work for no tangible benefit, except to be running php5 instead of php4. When there wasn't anything wrong with the php4 site in the first place.

The fact that PHP 4.4.8 is stable, does not have security bugs (at least not in the code that I use on my site), and it not being updated will actually make it attractive to some people.

But this is not a thread about whether to use php4 or not. This is a thread to help people who *need* to use php4 for whatever reason. So please don't hijack this thread and turn it into a php4 vs php5 argument.

tabletguy: as far as I know, just the php4-mysql is required for PHPBB. However, when I looked at my old site, I found that it was also using php4-gd, so I installed that too just to be safe. The only other thing my old site used was the Zend Optimizer, and trying to install that for both php4 and php5 is next on my list. There isn't any yum package for that, so it will require installing it from scratch. But I might not be able to get to that until Monday. I don't think that is needed for PHPBB though...it's a requirement of another module on my site.

Fri, 01/16/2009 - 22:45 (Reply to #2)
tabletguy

<b>sgrayban wrote:</b>
<div class='quote'>So you are going to use php4 years down the road instead of doing hosting the proper way ? How insecure your servers will be in 5 years and hacked..</div>

<b>sgrayban</b>:

I assume this is addressed to me, since you've already gotten an even handed and well thought out reply from <b>zugg</b>.

Thanks for the warning, and yes, I also am planning on moving away from php4.

I understand your viewpoint, but, since I don't know you personally, I don't really know if you are aware or not that using a particular OS and release often comes with a lot of testing by that company (Red Hat, Centos, etc), and they often do not offer this type of &quot; version upgrade&quot;, due to cited &quot;stability and security&quot;. At least that's what Joe recently said when I asked if there was a PHP 5.2 package for Centos 5.2, which he indicated would not happen, in his opinion.

So, should I be &quot;hopping&quot; OS every year, to stay on the leading edge of things? (Rhetorical question here) I don't know the answer to that, but I think perhaps the answer isn't the same for every circumstance or for every administrator.

Of course, that means I cannot make use of some scripts / packages. That's because developers (I am also a developer, btw), often make decisions based on their world view, and often that world view considers more &quot;features&quot; to be more important than a wide customer base. *shrug*

Can I make my own decision to add a package anyways? (Rhetorical). Sure, but first I search for issues and discussions, and then sometimes also post on Virtualmin forums (where the majority of Virtualmin specific discussion takes place) to either verify or inquire about the ramifications (quality, support burden, security, cost, etc) before proceeding.

This often means that I don't make a decision as quick as someone who's main line is only linux support or only Virtualmin usage and support. I'm OK with that.

So, please don't feel that a non-response to a particular posting means it was ignored. In this case, the preceding reply, although succinct, was adequate for the time being, and I didn't read into zugg's reply that they were going to maintain their software for years to come with php4. But, I personally (because I am less experienced) would have perhaps inquired more into what they were actually running with PHP4 before determining if it was insecure or not, and what time frame is needed to migrate.

I am moving to php5 as soon as I can, so thank you for your encouragement.

Wed, 01/07/2009 - 20:59
sgrayban

yum install php4-mysql

Wed, 01/07/2009 - 21:00 (Reply to #4)
sgrayban

btw PHP4 will be removed from all distros by the end of the year since that version has been put to the grave as of Dec 2008.

Wed, 01/07/2009 - 21:02 (Reply to #5)
Joe
Joe's picture

Scott's right...with the PHP developers calling PHP 4 dead, it simply won't be possible to keep it secure going forward. I have to recommend you begin upgrading your applications to use PHP 5 as soon as possible.

--

Check out the forum guidelines!

Thu, 01/08/2009 - 02:21
tabletguy

Well, I have to ask...

Is there a way to do this through Virtualmin Pro without using the command line?

It seems the Virtualmin Package Updates can handle things that are already installed, but I don't see a way (using that interface) to add a new package, similar to the PEAR interface...

Also, the Virtualmin Package Updates module doesn't say &quot;PHP5&quot;, it just says &quot;PHP&quot; (and shows the version number to the right).

So, is there any danger of overwriting existing packages?

I did a yum list on my Centos 5.2 box, and it listed a large number of files.

Do I choose ALL of the files that I want? (one-by-one)? Or only the single MsSql one? (I don't want postgress, but would like both MySql and SqlLite -- which I don't see here)

php4.i386 4.4.8-1vm virtualmin
php4-devel.i386 4.4.8-1vm virtualmin
php4-domxml.i386 4.4.8-1vm virtualmin
php4-gd.i386 4.4.8-1vm virtualmin
php4-imap.i386 4.4.8-1vm virtualmin
php4-ldap.i386 4.4.8-1vm virtualmin
php4-mbstring.i386 4.4.8-1vm virtualmin
php4-mysql.i386 4.4.8-1vm virtualmin
php4-ncurses.i386 4.4.8-1vm virtualmin
php4-odbc.i386 4.4.8-1vm virtualmin
php4-pear.i386 4.4.8-1vm virtualmin
php4-pgsql.i386 4.4.8-1vm virtualmin
php4-snmp.i386 4.4.8-1vm virtualmin
php4-xmlrpc.i386 4.4.8-1vm virtualmin

Thu, 01/08/2009 - 05:07 (Reply to #7)
andreychek

Howdy,

<div class='quote'>
Is there a way to do this through Virtualmin Pro without using the command line?
</div>

Sure! And this works in both the GPL and Pro versions.

If you log into Virtualmin, click Webmin -&gt; System -&gt; Software Packages, do a search for &quot;php4&quot; -- and you'll get the same list as above.

Yes, you'd just choose the ones you want, you don't need all of them (if one depends on another, it will install both for you).
-Eric

Thu, 01/08/2009 - 07:55
zugg

Sigh...
<div class='quote'>yum install php4-mysql</div>
Of course I already did that. In fact I also tried

yum install php4*

That doesn't fix the problem. I still get the error about mysqli.so being missing. There is a mysql.so file, but not a mysqli.so file. So there is still something missing in the php4-mysql package.

<div class='quote'>btw PHP4 will be removed from all distros by the end of the year since that version has been put to the grave as of Dec 2008.</div>
Of course I know that. Why do you think I'm trying to get both PHP4 and PHP5 working? So I can convert my huge PHP4 site to a PHP5 site. But this conversion is going to take many weeks. My current PHP4 site is huge, complex, and uses a bunch of other 3rd party code that doesn't work in PHP5. So I have to spend the next month or so rewriting my whole site. But during that time I need the current site to continue to run. That is exactly why I need one virtual site running PHP4 and another virtual site running PHP5. Once the PHP5 site is working, then I'll remove the PHP4 site.

BACK TO THE ORIGINAL TOPIC:

I am still looking for step-by-step instructions on getting PHP4 working on this system. Can't someone who has Virtualmin Pro give me the manual steps that I need to get it working in Virtualmin GPL?

Thu, 01/08/2009 - 08:05
zugg

I have another clue with the mysqli.so problem. It seems that PHP4 is looking at the /etc/php.ini file (which is for PHP5) instead of looking at the /etc/php4/php.ini file. Is this path hardcoded into the PHP4 build, or is there some easy way to change this so PHP4 uses the correct INI file?

Thu, 01/08/2009 - 10:07
zugg

OK, so if I use

yum remove php4-mysql

then I can do &quot;php4 -v&quot; and it works without error. It's only when I install php4-mysql that I get the error with php4. So it seems like somehow the pyhp4-mysql package has NOT been built properly to look in the /etc/php4 directory for the php.ini file and is looking in the main /etc/php.ini instead (which is for php5).

Is *anyone* using PHP4 with MySQL on a CentOS 5.x system running Virtualmin?

At this point, all I can think of is to remove all of the PHP4 stuff that got downloaded from the Virtualmin repository and try to build it all from scratch myself.

But since Virtualmin supposedly supports PHP4 in the Pro version, I find it hard to imagine that the files in the Virtualmin repository don't work. Isn't anyone using Virtualmin Pro using PHP4 with MySQL connectivity?

Thu, 01/08/2009 - 12:11
zugg

OK, I've finally gotten this to work I think. Unfortunately, I'm not sure what I did to fix it (yeah, I hate that).

From what I remember, I removed all php4 stuff using &quot;yum remove php4*&quot; and then rebooted. I confirmed that the /etc/php.ini was for php5 and that doing &quot;php -v&quot; properly showed the PHP5 version.

Then I installed PHP4 using &quot;yum install php4&quot;, which also installed php4-pear. Doing &quot;php4 -v&quot; properly showed the PHP4 version. Then I did &quot;yum install php4-mysql&quot; and this time it worked. The mysql.so file was properly placed into the /etc/php4/php.d directory. So far so good.

Now, in the Apache configuration, what I didn't realize is that not all of the configuration is stored in /etc/httpd/conf/httpd.conf. There are many other *.conf files loaded from /etc/httpd/conf.d. In that directory was the php.conf for PHP5 and the php4.conf for PHP4.

If you do a &quot;ls /usr/bin/php*&quot; you will see &quot;php&quot; (PHP5), &quot;php4&quot; (PHP4-FCGI) and &quot;php-cgi&quot; (PHP-FCGI). So, don't be confused like I was thinking that I didn't have the PHP4 CGI binary. The php4 file *is* the FCGI binary and not the command line php tool. This was confusing until I read the output of &quot;php4 -v&quot; more carefully.

OK, back to Apache. Now you have to decide which version of PHP will run via the Apache module, and which via FastCGI (FCGI). In my case I plan to run more PHP4 right now, so I want it to be the fastest. Once all of my sites are converted to PHP5 then I'll come back and make PHP5 run as an Apache module.

Since I want PHP4 to run as an Apache module, I edited the &quot;php4.conf&quot; file in the /etc/httpd/conf/conf.d folder. I uncommented the &quot;LoadModule php4_module modules/libphp4.so&quot; line, and uncommented the &quot;AddType application/x-httpd-php .php .php4&quot; line (and added the .php so that PHP4 is used by default).

Next, I edited the &quot;php.conf&quot; for PHP5. To convert this to use FCGI instead of an Apache module I commented out the &quot;LoadModule...libphp5.so&quot; line. And I changed the &quot;AddHandler php5-script .php&quot; to &quot;AddHandler php5-script .php5&quot; so that PHP5 is only executed by files with *.php5 extensions. Then I added the line:
&quot;Action php5-script /cgi-bin/php5&quot; to the file. This tells Apache to call the php5 CGI binary when running *.php5 files.

Now restart Apache (/sbin/service httpd restart). The next step is to create the CGI link. This is the step that I was missing (and is missing from a lot of tutorials). Go to the cgi-bin directory for the virtual host that you want to use PHP5 CGI. Like /home/mysite/cgi-bin. Now create a link for the PHP5 CGI using &quot;ln /usr/bin/php-cgi php5&quot;. This points the php5 that we called from Apache config to the actual PHP5 FCGI binary (php-cgi).

The final step that took me a while to figure out is that you need to set the permissions of this file properly. You need to do a &quot;chown username php5&quot; and &quot;chgrp groupname php5&quot; in the cgi-bin directory to match the username and groupname of the directory. Just do a &quot;ls -al&quot; to see the username and group of the cgi-bin directory and make the php5 have the same values. Otherwise you will just get a blank page for *.php5 files and you'll see the error message in your /etc/httpd/logs/suexec.log file.

In general, it's good to look at the Apache log files in /etc/httpd/logs to see what it says when Apache restarts or when you try to request a PHP page. That is what helped me.

With all of this, you can then create some files: phpinfo.php, phpinfo.php4, and phpinfo.php5. In each file, just put:

&lt;?php
phpinfo();
?&gt;

And then try to load each one from your browser. You should see that the *.php and *.php4 files will show PHP v4.4.8, and the *.php5 will show PHP v5.1.6

As I said, in this example I am making PHP4 the default, and PHP5 the exception. For any site that you want to run PHP5, you need to add the link to the PHP5 CGI in the cgi-bin directory of that virtual host. You can also add a .htaccess file to map *.PHP files to *.PHP5 for those sites where you want PHP5 by default.

So this is finally working for me. Seems straight-forward now that I review it all. The tricks were noticing all of the extra *conf files in the conf.d directory, and then setting the proper ownership of the CGI link. Hope this helps someone else.

Sorry this no longer has much to do with Virtualmin...you do all of this stuff from the root shell prompt. I'm sure there are ways to do it within the Virtualmin interface, but I got so frustrated with Virtualmin GPL that I just gave up and used the command line.

Thu, 01/08/2009 - 12:47
tabletguy

<div class='quote'>If you log into Virtualmin, click Webmin -&gt; System -&gt; Software Packages, do a search for &quot;php4&quot; -- and you'll get the same list as above.</div>

I tried the above advice. There are 2 different &quot;Search&quot; boxes on that page. Entering &quot;php4&quot; did not return anything for either of them. Neither did &quot;php4*&quot;

Searching for &quot;php&quot; by itself does return php5 specific packages.

Selecting &quot;Package Tree&quot;, and then &quot;Open All&quot; I can find php5 under languages, but no mention of php4 or php 4 (with space)

Next, I tried the &quot;Browse Yum&quot; button. This gave me another &quot;search&quot; dialog window, but in a separate window. While using &quot;php4&quot; DID return the same list as in the previous post, clicking on any of those names does nothing.

Lastly, I used the names from that list and manually entered them into the &quot;Package from YUM&quot; and click install.

This DOES install the package, and any dependencies, as noted.

I did this first for php4, and then for php4-mysql. I suspect that if I had just entered &quot;php4-mysql&quot; it would have also installed php4 as a &quot;dependency&quot;, but I was following the <b>zugg's</b> sequence.

I have a phpBB2 site that needs php4 until I can get it migrated.

I posted the above to complete the step by step, and also, to ask if there are any additional &quot;php4&quot; items needed for phpBB?

Thanks for the help.

Thu, 01/08/2009 - 23:04 (Reply to #13)
sgrayban

php4 is *DEAD* as in NO LONGER SUPPORTED -- why are you insisting to install and use it? It will *never ever* be updated for any reason including *any* future security bugs..... You following now ?

In fact I highly recommend that Joe/Jamie stop supporting anything but php5 from now on.

Thu, 01/15/2009 - 08:56
zugg

Just wanted to update this topic with more information.

Once I got my VM working with both PHP4 and PHP5 as described above, then the last step was to control which VMs use PHP4 as the default and which use PHP5 as the default. It's easy to control the default version of PHP in your Apache httpd.conf file. You can edit this file manually by going into the WebMin/Servers/Apache area, then click the Global Configuration tab and then click the Edit Config files.

Scroll down to the &quot;VirtualHost&quot; entry that you want to change. In my case (shown in the previous posts), I have PHP4 loaded as an Apache module, and PHP5 loaded via FCGI. If you want PHP5 to be used for the .php extension by default instead of PHP4, then add the following lines within your &lt;Virtual Host...&gt; section:

AddHandler php5-script .php .php5
AddType application/x-httpd-php .php4

Then go to the /home/mysite/cgi-bin directory and create the CGI link to your PHP5 fcgi binary:

cd /home/mysite/cgi-bin
ln /usr/bin/php-cgi php5

and make sure the owner and group of this php link is set to the owner and group of the mysite directory. E.g.:

chown mysite php5
chgrp mysite php5

and then restart your Apache server. Now your phpinfo.php file should show that this VM is running PHP5 by default.

Using the information in this thread, I now have multiple VMs on my system, most using PHP5 by default, but some old sites using PHP4 by default.

Running PHP as an Apache module is slightly faster than using the FCGI, so in my case, PHP4 is a bit more efficient than PHP5. This is fine since the site using the most bandwidth on my server is my old PHP4 site. Once that site is converted to PHP5, then I'll probably reverse my Apache configuration and load PHP5 as the Apache module and use PHP4 via FCGI.

Anyway, I hope this post helps other people trying to still use PHP4 on their CentOS system with Virtualmin GPL.

Fri, 01/16/2009 - 20:41 (Reply to #15)
sgrayban

So you are going to use php4 years down the road instead of doing hosting the proper way ? How insecure your servers will be in 5 years and hacked.

Fri, 01/16/2009 - 22:48 (Reply to #16)
Joe
Joe's picture

Simmer down, everybody.

We'll all have to deal with PHP4 a little longer (at least, I will, since a few of our customers still have to). It's the nature of the business...sometimes we gotta make lemonade out of lemons. And if PHP 4 aint a lemon, I don't know what is. ;-)

--

Check out the forum guidelines!

Topic locked