Tag Archives: PHP

How to change default PHP version in plesk

How to change default PHP version in plesk

In this article, I am referring to change default php version in plesk. In latest plesk versions are come with all the php versions installed ( we have the option to install all the php versions ). So no need to install a separate php in the server for setting the default PHP to the latest version. Creating symlink and some additional commands to bring the default handler to the required version.

Here is the environment in which the command worked.

Plesk Version : 17.5.3 CentOS 7

List the php handlers

/usr/local/psa/admin/bin/php_handlers_control --list

Verify the default php version.

php -v

Check the PHP version 5.6

/opt/plesk/php/5.6/bin/php -v

Find the default php binary

which php

Backup the php, php-cgi and php-fpm binaries.

mv /usr/bin/php /usr/bin/php.backup
mv /usr/bin/php-cgi /usr/bin/php-cgi.backup
mv /sbin/php-fpm /sbin/php-fpm.backup

Create symlink from php 5.6 binaries

ln -s /opt/plesk/php/5.6/bin/php /usr/bin/php
ln -s /opt/plesk/php/5.6/bin/php-cgi /usr/bin/php-cgi
ln -s /opt/plesk/php/5.6/sbin/php-fpm /sbin/php-fpm

You can set symlink from any other php version installed in the server. Following are the php bnaries for other versions, find the same for php-cgi and php-fpm too.

/opt/plesk/php/5.3/bin/php 
/opt/plesk/php/5.4/bin/php 
/opt/plesk/php/5.5/bin/php
/opt/plesk/php/5.6/bin/php
/opt/plesk/php/7.0/bin/php 
/opt/plesk/php/7.1/bin/php
/opt/plesk/php/7.2/bin/php

Once the symlink is created, the php version will show the new version we set. You can check it using the following command.

php -v

Next option is to update the plesk database with the changed versions. The reread option will update plesk database with the new versions.

/usr/local/psa/admin/bin/php_handlers_control --reread

After that reconfigure all the domains or the domains using the default php versions. And proceed with a service restart.

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
service httpd restart

Once this is completed, the sites will load with new php version.

Note: Make sure to do this by a qualified technician.

If you need us to do these changes for your server, please get it touch without support

18Jan/18

ntPHPSelector version 4.2.0 released

New version of ntPHPselector with 7.2 support is released. It is added with email notification for any license check related errors. Server owner/administrator needs to update the contact email address via ntPHPselector WHM front end. Also added fix for the scanning of additional ini files for php 5.3

Features
[+] Fixed the additional scanning of ini files.
[+] Alert for license error
[+] Added 7.2 support

Current users will get instructions for updating the plugin from the plugin support department. New users can order the service from the following page.

https://www.nixtree.com/nt-php-selector.php

09Jul/14

Install Redis Daemon and Redis PHP extention on CentOS/RHEL/cPanel

Redis is an open-source, networked, in-memory, key-value data store with optional durability. It is written in ANSI C. It’s a “NoSQL” key-value data store. More precisely, it is a data structure server.

To install Redis as daemon on a CentOS/RHEL/cPanel server, do the following steps

cd /usr/local/
wget http://download.redis.io/releases/redis-2.8.12.tar.gz
tar -xvzf redis-2.8.12.tar.gz
cd redis-2.8.12
make
cp src/redis-server /usr/local/bin
cp src/redis-cli /usr/local/bin
mkdir -p /etc/redis
mkdir -p /var/redis
cp redis.conf /etc/redis/redis.conf

Open /etc/redis/redis.conf using vi edirot and set the values as follows.

daemonize yes
port 6379
bind 127.0.0.1
dir  /var/redis/
logfile  /var/log/redis.log
pidfile  /var/run/redis.pid

Now create the startup script. Create a new file as /etc/init.d/redis and add the following contents to it ( Reference https://gist.github.com/paulrosania/257849 ). And make it executable ( chmod 755 /etc/init.d/redis ).

#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig:   - 85 15 
# description:  Redis is a persistent key-value database
# processname: redis-server
# config:      /etc/redis/redis.conf
# config:      /etc/sysconfig/redis
# pidfile:     /var/run/redis.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
redis="/usr/local/bin/redis-server"
prog=$(basename $redis)
 
REDIS_CONF_FILE="/etc/redis/redis.conf"
 
[ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis
 
lockfile=/var/lock/subsys/redis
 
start() {
    [ -x $redis ] || exit 5
    [ -f $REDIS_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $redis $REDIS_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
 
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
 
restart() {
    stop
    start
}
 
reload() {
    echo -n $"Reloading $prog: "
    killproc $redis -HUP
    RETVAL=$?
    echo
}
 
force_reload() {
    restart
}
 
rh_status() {
    status $prog
}
 
rh_status_q() {
    rh_status >/dev/null 2>&1
}
 
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
	    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac

Now make sure the daemon will start after server reboot.

chkconfig --add redis
chkconfig redis on

Now we can start redis using command /etc/init.d/redis start

To make sure redis is working, run command “redis-cli ping” from commandline. If you get result “PONG”, that shows redis is working.

Now install redis PHP extension, using following command.

pecl install redis

Now open php.ini ( /usr/local/lib/php.ini on cPanel servers ) file and add the following line to it

extension=redis.so

Now restart Apache to apply the changes to php.ini file.

12Apr/14

ntPHPselector : Bug fix #New Line entry error with AddHandler

Bug # New Line entry error with AddHandler

Description: If an htaccess file is not end with a new line the newly added “AddHandler” entry will be append to the end of the last line. The issue is occur with the .htaccess files eithout ending a newline (normally it ends with new line). The bug is fixed in the new version 2.0.4 by adding the AddHandler Entry as new Line. Since there is no major changes, no need to recompile, reinstall the ntphpselector plugin. The old users can fix this bug by running the following commands from root terminal.

Fix:

cd /usr/local/src
wget -N http://nixtree.com/download/free/ntphp/ntphp_patch204.sh
sh ntphp_patch204.sh

Continue reading

07Jan/14

ntPHPselector :: Released v2.0.0

ntPHPselector plugin allows user to select preferred PHP version per directory on the same domain.

Added features

  • The textbox has been removed and directory listing is enabled. So now the user can click and select and directory from the list.
  • Enabled sqlite support for PHP 5.4 and 5.5
  • Enabled server timezone in each php.ini files
  • PHP 5.2.17 download is now from NixTree’s website as cPanel will remove the tarballs from their repo after a while. Continue reading
11Oct/13

mysqli_connect(): (HY000/2002): Can’t connect to local MySQL server through socket – SugarCRM – cron.php

PHP Warning: mysqli_connect(): (HY000/2002): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) in sugarcrm/include/database/MysqliManager.php on line

We have faced such an error with SugarCRM today. The above error was reporting in error_log file every time the cron.php is executed via cron job. We have taken a closer look and couldn’t find any real reason why it cannot connect via MySQL socket. Everything looks good and every testing via command line were giving good results. What we have checked is for the existence of the socket file ( the errors 2 states it canbot find the sock file ) and whether running the cron as user from command line can return the error. If it is cPanel system, all cron jobs are running in a Jailed shell from version 11.38. Make sure it is disabled, as it can cause this issue. We have find many similar threads in INTERNET, but  could not find any real reason which can cause it. Finally we have decided to go ahead and force it to use TCP connection rather than using MySQL socket file. To do that we have edited config.php and changed the value of db_host_name parameter to “127.0.0.1” from “localhost. That fixed the issue and the error is not reporting so far. It may slow down MySQL connection a bit, as using socket file is stated to be the faster method.