History: Linux-PHP4cgiAndPHP5on CentOS5Source of version: 5 (current)__WARNING:__ The data on the server were damaged due to the fire in Hosting.UA DC. All files will be restored shortly.
!!Introduction As you know, [http://centos.org|CentOS5] is being shipped with [http://www.php.net|PHP5] which, especially, is being installed in ISAPI mode and thus makes the installation of additional PHP4 modules not available. The solution is to run PHP4 in CGI mode. So, to get it working CGI mode we have to: * download latest PHP4 source from [http://php.net/get/php-4.4.8.tar.bz2/from/a/mirror|here] * compile it and place somewhere * ask Apache 2.2 to use just compiled php binaries as a PHP-processor on particular virtual hosts. Well, I did so and was very upset - PHP wasn't working as expected. Problems with UTF-8 encoding, unexpected sigfaults and other staff made this approach useless. Fortunately, I found that the issue is already solved by [http://www.labcoding.com/|LabCoding] team, here is [http://www.labcoding.com/linux/php-448-and-eaccelerator-0952-srpms-for-centos-5/|the article]. Anyway, there was one major thing which wasn't satisfying me. Their package is being installed into the standard OS folders and was causing conflicts with some of my existing files. So, I decided to rebuild the PHP4 RPM packages to make PHP4 being installed into /opt/php4 directory and thus to make it separated from the entire filesystem. !!How does it work? Package [http://repo.conforge.com/conforge/CentOS/5/i386/RPMS/php4-4.4.8-LAB4.i386.rpm|php4-4.4.8-LAB4] installs ''php4'' binaries into ''opt/php4/bin'' folder. Also, other files are being installed into ''/opt/php4/etc/'', ''/opt/php4/lib/'', ''/opt/php4/share/'' folders. Extensions are being installed into ''/opt/php4/lib/php4'' directory and their configurations - into ''/opt/php4/etc/php.d''. To get PHP4 working we have to set up a CGI handler set to process *.php files using ''/opt/php4/bin/php4-cgi'' binary. !!Installation and Configuration * Configure YUM installer by creating file /etc/yum.repos.d/conforge.repo with the following content: ~pp~ [conforge] name=Conforge package for CentOS $releasever - $basearch baseurl=http://repo.conforge.com/conforge/CentOS/$releasever/$basearch enabled=1 gpgcheck=0~/pp~ More info about Conforge repository is available [http://wiki.conforge.com/wiki/tiki-index.php?page=Linux-ConforgeRepository|here]. * Enable/install [http://fedoraproject.org/wiki/EPEL|EPEL] RPM repository. Follow the instructions from http://fedoraproject.org/wiki/EPEL/FAQ#howtouse * Install PHP4 using YUM: ~pp~ ~# yum install php4 php4-pear php4-mysql~/pp~ * Use the following command in case you need to install all available extensions: ~pp~ ~# yum install php4*~/pp~ * Configure Apache HTTPD. We assume PHP4 will setup for particular ))VirtualHost(( so in its block (the one surrounded with <VirtualHost></VirtualHost> directives) place these instructions: ~pp~ ScriptAlias /php-bin/ /opt/php4/bin/ SetEnv PHPRC "/opt/php4/bin" Action php4-script "/php-bin/php4-cgi" AddHandler php4-script .php~/pp~ __NOTE:__ In case you will do that for global server then you will turn off PHP5 support at all. * Cyrillic users would probably like to add the following in ''/etc/httpd/conf/httpd.conf'': ~pp~ AddDefaultCharset windows-1251~/pp~ * __NOTE:__ Actual build of PHP4 is not able to run if [http://httpd.apache.org/docs/2.2/suexec.html|SuExec] is enabled for particular virtual host. You should disable that feature otherwise all you'll see is just white screen instead of webpage. * Reload HTTPD daemon and yo will get your PHP4 installation working: ~pp~ ~# /etc/init.d/httpd reload~/pp~ |
Login |