Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##########################################################################
- # ntPHPselector version: 2.5.1
- # Url : https://www.nixtree.com/ntphp.php
- # Email : support@nixtree.com
- ##########################################################################
- # Heavy modifications (reductions) to remove any functionality
- # outside of simple downloading and compiling new PHP versions,
- # so that the scripts could be used in fastcgi environment
- # instead of suphp. Note that no user interface is provided, so
- # some other selection must be used
- # (e.g. /usr/local/cpanel/cgi-sys/php5)
- #
- # Modified by : lastguru@gmail.com
- ##########################################################################
- if [ -z $1 ]; then
- echo "Valid options are install, recompile and uninstall"
- echo "Exiting installation"
- exit
- fi
- NATIVE=`php -v | head -1 | awk -F" " {'print $2'}| awk -F"." {'print $2'}`
- echo "5.3" >> /tmp/phpver.txt
- echo "5.4" >> /tmp/phpver.txt
- echo "5.5" >> /tmp/phpver.txt
- cat /tmp/phpver.txt | grep -v 5.$NATIVE > /tmp/phpver1.txt
- ADD1=`head -1 /tmp/phpver1.txt| awk -F"." {'print $2'}`
- ADD2=`head -2 /tmp/phpver1.txt| tail -1| awk -F"." {'print $2'}`
- SUPHPCONFIG='/opt/suphp/etc/suphp.conf'
- ########Functions Start Here###########
- clean_install() {
- rm -f /tmp/phpver.txt
- rm -f /tmp/phpver1.txt
- rm -f /tmp/phpverinst.txt
- rm -rf /usr/local/src/ntphpselector
- rm -f /tmp/phpconf.txt
- }
- phpinstall() {
- MAJVER=`echo $1 | awk -F"_" {'print $1'}`
- php-cli -i |grep configure|sed 's/Configure Command => //g' | sed "s/'//g" > /tmp/phpconf.txt
- sed -i -e "s/prefix=\/usr\/local/prefix=\/opt\/ntphp\/php5$MAJVER/g" -e 's/.\/configure//g' -e 's/--with-apxs2=\/usr\/local\/apache\/bin\/apxs//g' -e 's/--with-config-file-path=\/usr\/local\/lib//g' -e 's/--with-config-file-scan-dir=\/usr\/local\/lib\/php.ini.d//g' /tmp/phpconf.txt
- if grep enable-pdo /tmp/phpconf.txt >> /dev/null; then
- yum -yv install sqlite-devel
- if [ $MAJVER -eq 3 ] || [ $MAJVER -eq 2 ]; then
- sed -i -e "s/$/ --with-sqlite=shared/g" -e "s/$/ --with-sqlite3=shared/g" /tmp/phpconf.txt
- fi
- fi
- cd /usr/local/src/ntphpselector
- wget --no-check-certificate http://httpupdate.cpanel.net/cpanelsync/easy/targz/Cpanel/Easy/PHP5/$1.pm.tar.gz.bz2
- bunzip2 $1.pm.tar.gz.bz2
- tar -xvzf $1.pm.tar.gz
- cd php-*
- wget --no-check-certificate https://www.nixtree.com/download/free/ntphp/sqlite.patch
- /usr/bin/patch -p1 < ./sqlite.patch
- ./configure `cat /tmp/phpconf.txt` && make && make install
- if [ ! -d /opt/ntphp/php5$MAJVER ]; then
- echo "COMPILE ERROR FOR 5$MAJVER"
- echo "Exiting Installation"
- clean_install
- echo " Please open a new thread at http://forum.nixtree.com/ if you meet with any issues"
- exit
- else
- echo "SUCCESSFULLY COMPILED 5$MAJVER"
- fi
- sleep 5
- if [ ! -f /opt/ntphp/php5$MAJVER/lib/php.ini ]; then
- /bin/cp -rf php.ini-production /opt/ntphp/php5$MAJVER/lib/php.ini
- fi
- if grep enable-pdo /tmp/phpconf.txt >> /dev/null; then
- if ! grep pdo.so /opt/ntphp/php5$MAJVER/lib/php.ini >> /dev/null; then
- if [ $MAJVER -eq 4 ] || [ $MAJVER -eq 5 ]; then
- echo "extension=pdo.so" >> /opt/ntphp/php5$MAJVER/lib/php.ini
- echo "extension=pdo_mysql.so" >> /opt/ntphp/php5$MAJVER/lib/php.ini
- else
- echo "extension=pdo.so" >> /opt/ntphp/php5$MAJVER/lib/php.ini
- echo "extension=pdo_mysql.so" >> /opt/ntphp/php5$MAJVER/lib/php.ini
- echo "extension=pdo_sqlite.so" >> /opt/ntphp/php5$MAJVER/lib/php.ini
- fi
- fi
- fi
- TZONE=`cat /etc/sysconfig/clock | grep ZONE | sed -e "s/ZONE=//g" | sed -e 's/\//\\\\\//g'`
- echo "System timezone: $TZONE set to date.timezone param in php.ini"
- sed -i -e "s/;date.timezone =/date.timezone=$TZONE/g" /opt/ntphp/php5$MAJVER/lib/php.ini
- sed -i -e "s/short_open_tag = Off/short_open_tag = On/g" /opt/ntphp/php5$MAJVER/lib/php.ini
- cd /usr/local/src/ntphpselector
- rm -rf php-*
- rm -rf $1.pm.tar.gz
- }
- ########Main############################
- echo "Cleaning left-over files if you have attempted to run this script previously"
- clean_install
- sleep 1
- rm -f /tmp/phpver1.txt
- wget --no-check-certificate --directory-prefix=/tmp https://www.nixtree.com/download/free/phpver1.txt
- cat /tmp/phpver1.txt | grep -v $NATIVE"_" | grep -v "2_" > /tmp/phpverinst.txt
- if [ $1 == "install" ]; then
- if [ -d /opt/ntphp ]; then
- echo "ntPHPSelector installation detected. Please uninstall and then install"
- exit
- fi
- echo "You have PHP 5.$NATIVE is installed on the server. This script will install 5.$ADD1 and 5.$ADD2"
- sleep 2
- mkdir /usr/local/src/ntphpselector
- mkdir /opt/ntphp
- for ver in `cat /tmp/phpverinst.txt`; do
- phpinstall $ver
- done
- clean_install
- elif [ $1 == "recompile" ]; then
- if [ -z $2 ]; then
- echo "Possible compile options are 4 and 5"
- exit
- fi
- if [ $2 -eq $NATIVE ]; then
- echo "To recompile PHP installed via cPanel, use EasyApache"
- clean_install
- exit
- fi
- if [ $2 -eq 2 ] || [ $2 -eq 3 ] || [ $2 -eq 4 ] || [ $2 -eq 5 ]; then
- mkdir /usr/local/src/ntphpselector
- mkdir /opt/ntphp
- phpinstall `grep $2_ /tmp/phpverinst.txt`
- clean_install
- elif [ $2 == "00" ]; then
- echo "You have PHP 5.$NATIVE is installed on the server. This script will install 5.$ADD1 and 5.$ADD2"
- sleep 2
- mkdir /usr/local/src/ntphpselector
- mkdir /opt/ntphp
- for ver in `cat /tmp/phpverinst.txt`; do
- phpinstall $ver
- done
- else
- echo "Wrong compile option given"
- exit
- fi
- clean_install
- elif [ $1 == "uninstall" ]; then
- clean_install
- rm -rf /opt/ntphp
- clean_install
- echo "Uninstallation Completed....."
- echo "Thank you for using ntPHPSelector"
- else
- echo "Wrong choice"
- exit
- fi
- rm -f /usr/local/src/ntphpselector*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement