Install Second Version of PHP on Plesk (2015)

1. Download php from

cd /usr/local/src/
wget http://xxx/php-5.6.11.tar.bz2
tar xjf php-5.6.11.tar.bz2
mv php-5.6.11 php5611

2. Install the necessary libraries

yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel net-snmp-devel mhash-devel libc-client-devel libicu-devel gcc postgresql-devel aspell-devel libxslt-devel gcc-c++ openldap-devel

3. Configure

./configure ‘–with-libdir=lib64’ ‘–cache-file=../config.cache’ ‘–prefix=/usr/local/php5611-cgi’ ‘–with-config-file-path=/usr/local/php5611-cgi/etc’ ‘–disable-debug’ ‘–with-pic’ ‘–disable-rpath’ ‘–with-bz2’ ‘–with-curl’ ‘–with-freetype-dir=/usr/local/php5611-cgi’ ‘–with-png-dir=/usr/local/php5611-cgi’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr/local/php5611-cgi’ ‘–with-openssl’ ‘–with-pspell’ ‘–with-pcre-regex’ ‘–with-zlib’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-sysvmsg’ ‘–enable-wddx’ ‘–with-kerberos’ ‘–with-unixODBC=/usr’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–without-sqlite3’ ‘–with-libxml-dir=/usr/local/php5611-cgi’ ‘–enable-pcntl’ ‘–with-imap’ ‘–with-imap-ssl’ ‘–enable-mbstring’ ‘–enable-mbregex’ ‘–with-gd’ ‘–enable-bcmath’ ‘–with-xmlrpc’ ‘–with-ldap’ ‘–with-ldap-sasl’ ‘–with-mysql=/usr’ ‘–with-mysqli’ ‘–with-snmp’ ‘–enable-soap’ ‘–with-xsl’ ‘–enable-xmlreader’ ‘–enable-xmlwriter’ ‘–enable-pdo’ ‘–with-pdo-mysql’ ‘–with-pdo-pgsql’ ‘–with-pear=/usr/local/php5611-cgi/pear’ ‘–without-pdo-sqlite’ ‘–with-config-file-scan-dir=/usr/local/php5611-cgi/php.d’ ‘–enable-cgi’

4. Compile php

cd /usr/local/src/php5611

5. Install php

cd /usr/local/src/php5611
make install

6. Set up php.ini

cp php.ini-development /usr/local/php5611-cgi/etc/php.ini

7. Restore SELinux contexts

restorecon -R /usr/local/php5611-cgi


Find Out Spammer

– Monitor maillog
tail -f /usr/local/psa/var/log/maillog

– Try to connect to 3rd party mail server (e.g. Yahoo Mail / Gmail) and check the error message
tail -100 /usr/local/psa/var/log/maillog
telnet IP 25

– Check qmail queue

– Check messages log
cat /var/log/messages

– Check apache log to see if there is any hacker’s script
cat /var/www/vhosts/DOMAIN/statistics/logs/access_log

– Check the email content from mailbox
cd /var/qmail/mailnames/DOMAIN/MAILBOX/Maildir/cur

– Clear qmail queue
service qmail stop
find /var/qmail/queue/mess -type f -exec rm {} \;
find /var/qmail/queue/info -type f -exec rm {} \;
find /var/qmail/queue/local -type f -exec rm {} \;
find /var/qmail/queue/intd -type f -exec rm {} \;
find /var/qmail/queue/todo -type f -exec rm {} \;
find /var/qmail/queue/remote -type f -exec rm {} \;
service qmail start

Install Second Version of PHP on Plesk

1. Download php from

2. Unpack the tarball to your home directory

tar -xjf php-5.2.10.tar.bz2

3. Get module list

php -m | grep -v -e Modules] -e ^$ > php-default-modules

4. Create a configure script

for i in $(cat php-default-modules); do echo -n “–with-$i “>> ;done

5. Edit and insert these 2 lines to the beginning of the file


6. Run the configure script


7. Correct the errors with the help of this command:

./configure –help

To correct the errors, you may need to replace ‘–with’ with ‘–enable’, and remove those modules that are enabled by default.

8. Add other options that you need, such as –enable-safe-mode

9. Create and run phpinfo.php

echo phpinfo();

10. Grab the configure entries from phpinfo.php. Remember not to include ‘–with-apxs2=/usr/sbin/apxs’, and Make sure to change ‘–with-config-file-path=/etc’ and ‘–with-config-file-scan-dir=/etc/php.d’.

A sample

./configure –prefix=/usr/share –datadir=/usr/share –libdir=/usr/lib64 –libexecdir=/usr/libexec –localstatedir=/var –sharedstatedir=/usr/com –mandir=/usr/share/man –infodir=/usr/share/info –cache-file=../config.cache –with-libdir=lib64 –includedir=/usr/include –bindir=/usr/bin –sbindir=/usr/sbin –sysconfdir=/etc –with-config-file-path=/etc/php52 –with-config-file-scan-dir=/etc/php.5.2.d –with-jpeg-dir=/usr –enable-force-cgi-redirect –enable-discard-path –with-bz2 –enable-calendar –enable-exif –enable-ftp –with-gd –with-gettext –with-gmp –with-iconv –enable-mbstring –with-mcrypt –with-mysql=/usr/bin/ –with-mysqli –with-openssl –with-pdo_mysql –with-PDO_ODBC –with-pdo_sqlite –enable-shmop –enable-sockets –with-xmlrpc –with-xsl –enable-zip –with-zlib

11. Run ./ again until all errors are fixed.

12. Run ‘make’.

13. Fix the errors.

14. Run ‘make’ again until all errors are fixed.

15. Duplicate php.ini

mkdir /etc/php52/
cp php.ini-dist /etc/php52/php.ini

16. Duplicate the additional .ini files

mkdir /etc/php.5.2.d
cp /etc/php.d/*.* /etc/php.5.2.d/

17. Change permission of the cgi-bin folder

chmod 755 /var/www/vhosts/

18. Copy the php-cgi to the cgi-bin folder

cp sapi/cgi/php-cgi /var/www/vhosts/
chown domain.psacln /var/www/vhosts/
chmod 755 /var/www/vhosts/

19 . Create the apache config file

vim /var/www/vhosts/
ScriptAlias /cgi-bin/ /var/www/vhosts/
Action php52-cgi /cgi-bin/php-cgi
AddHandler php52-cgi .php

20. Ask Plesk to reconfigure the domain

/usr/local/psa/admin/bin/httpdmng –reconfigure-domain