Wednesday, September 17, 2008

PHP5 Support along with PHP4

PHP5 Support along with PHP4; the following are the steps to run php5+gd+mysql support (with the default install of php4) working with Plesk 8.2.0 and Non-Plesk hosted sites on RHEL 4.

1.1. Install GD support for PHP5.

a) # mkdir /usr/local/php5libpng
b) # cd /usr/local/php5libpng
c) # wget http://kent.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8-config.tar.gz
d) # tar -zxvf libpng-1.2.8-config.tar
e) # ./configure --prefix=/usr/local/php5libpng --exec-prefix=/usr/local/php5libpng
f) # make
g) # make install

1.2. Check for this packages or install it.

a) mysql-devel
b) libjpeg-devel


1.3. Download and Install PHP.

a) # mkdir /usr/local/php5
b) # cd /usr/local/php5
c) # wget http://museum.php.net/php5/php-5.1.4.tar.gz
d) # tar -zxvf php-5.1.2.tar

e) # ./configure --host=i386-redhat-linux --build=i386-redhat-linux --target=i386-redhat-linux-gnu --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --program-suffix=5 --enable-force-cgi-redirect --enable-discard-path --enable-exif --enable-ftp --with-curl --with-bz2 --enable-memory-limit --enable-inline-optimization --with-openssl --with-png --with-regex=system --with-xml --with-zlib --enable-sockets --enable-mbstring=shared --enable-mbstr-enc-trans --with-png-dir=/usr/local/php5libpng --with-gd --with-jpeg-dir=/usr/local/php5libjpeg --enable-gd-native-ttf --with-mysql --with-gmp --with-iconv --enable-magic-quotes --enable-calendar --enable-dbx --enable-dio --enable-libxml --enable-session --with-pcre-regex --enable-xml --enable-simplexml --enable-spl --enable-sigchild --enable-soap --enable-zend-multibyte --with-kerberos=/usr/kerberos --enable-fastcgi

f) # make
g) # make install

2. Now go to the root folder of the domain and configure php5 as default php application. Create the file vhost.conf with the following in it for each site running in PHP5:

a) # cd /var/www/vhosts/domain-name/conf/
b) # vi vhost.conf and add the following lines.

AddHandler fcgid-script .php5 .php
SuexecUserGroup psacln

FCGIWrapper /var/www/vhosts/domain-name/bin/php5 .php
FCGIWrapper /var/www/vhosts/domain-name/bin/php5 .php5
Options ExecCGI
allow from all

Save and exit with ":wq".

Note1: for replacing string in vi editor use the command: [:n,$s/string/newstring/g] - Where 'n' will replace with the starting line NO.


c) # cd /var/www/vhosts/domain-name/
d) # mkdir bin
e) # chown ftpuser.psaserv bin
f) # cd bin
g) # cp /usr/local/php5/bin/php5 php5
h) # chown ftpuser,psacln php5
i) # chmod 755 php5 (optional if the permission is wrong)

Note2: PHP5 needs to be copied and run locally, since otherwise you get issues with suexec. If you have problems run cat /var/log/httpd/suexec_log and check any errors.


3. Reconfigure domain with PHP5

a) Run: # /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com
b) # service httpd restart

Recheck with "phpinfo" as it is properly configure or not.

Local Server Installation: For Non Plesk Server
4.0.0. Now configure the same in a Non Plesk Environment. Run the step One (download and compile the PHP 5).

4.1.0. Now you can configure in a way so that only the file with .php5 extension will run through PHP 5.

4.1.1. # vi /etc/httpd/conf/httpd.conf, and add this lines.

# Enabling PHP 5 as CGI Application

ScriptAlias /php5 /usr/local/php5/bin

Options +ExecCGI +FollowSymLinks
AllowOverride All

AddType application/x-httpd-php-5 .php5
Action application/x-httpd-php-5 /php5/php


4.1.2. # service httpd restart

4.2.0. Alternatively you can use port base configuration, so that the file with .php extension with this option e.g. http://domain.com/test.php runs with PHP4 and for http://domain.com:88/test.php with PHP 5.

4.2.1. # vi /etc/httpd/conf/httpd.conf, add these lines.

# Coustom Port for PHP 5
Listen 88

# VirtualHost PHP 5 Based hosting


ScriptAlias /php5 /usr/local/php5/bin

Options +ExecCGI +FollowSymLinks
AllowOverride None

AddHandler php-cgi-script .php
Action php-cgi-script /php5/php
Options +ExecCGI


4.2.2. # service httpd restart

No comments:

Powered By Blogger