Sunday, May 8, 2016

Auto Updating phpMyAdmin without hassle

You can use below bash code on CentOS/Fedora and RedHat to auto update phpMyAdmin:

GitHub Code: https://github.com/mason-chase/phpMyAdmin-auto-update

Edit two options: PHPMYADMIN_FULL_PATH=/var/www/ and PHPMYADMIN_FOLDER_NAME=phpmyadmin

install.sh
#!/bin/bash  
# Copyright Mason Chase (sid@moontius.com)
# DISCLAIMER: install.sh SCRIPT AND ITS CONTENT ARE DESIGNED AND TESTED UNDER CENTOS/FEDORA/REDHAT AND YOU MAY USE IT AT YOUR RISK ONLY.

# Download latest rpmforge to get 7zip in our system
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm -O /usr/src/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

# install yum reposity
rpm -ivh  rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

# install 7zip with yum
yum install p7zip -y

# append some cron entry 
crontab -l | { cat; echo "
# Auto Update phpMyAdmin everyday at 4AM
0 4 * * * /usr/bin/phpmyadmin_update.sh"; } | crontab -

# 
cat >/usr/bin/phpmyadmin_auto_update.sh << 
EOL
#!/bin/bash  

# Copyright Mason Chase (sid@moontius.com)
# DISCLAIMER: install.sh SCRIPT AND ITS CONTENT ARE DESIGNED AND TESTED UNDER CENTOS/FEDORA/REDHAT AND YOU MAY USE IT AT YOUR RISK ONLY.

#echo on
set -x


# must have beginning slash and trailing slash
PHPMYADMIN_FULL_PATH=/var/www/

# must not have beginning or trailing slash
PHPMYADMIN_FOLDER_NAME=phpmyadmin

#  Download phpmyadmin download page
/usr/bin/wget https://www.phpmyadmin.net/downloads/ -O /tmp/phpmyadmin-download.html
# Map Latest phpmyadmin English with 7-zip format using regex
MYSQL_URL=\$(cat /tmp/phpmyadmin-download.html|grep -e "

Then:
sudo ./install.sh

Thursday, May 5, 2016

Upgrade/Update PHP 5.5 or PHP 5.6 to PHP 7.0

Install latest remi (6.6)
Below is the series of yum commands to easily upgrade php 5.5 or PHP 5.6 to PHP 7.0
# install latest remi (6.6)
rpm -Uvh http://rpms.famillecollet.com/store/remi/release/6.6/remi-release-6.6-2.el6.remi.noarch.rpm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

# Install yum-config-manager
yum install yum-utils  yum-plugin-replace -y

# Disable PHP 5.5 or 5.6 repository
yum-config-manager --disable remi-php56 
yum-config-manager --disable remi-php55

# Enable PHP 7.0
yum-config-manager --enable remi-php70

# Upgrade to PHP 7.0 and all dependencies
yum upgrade php php-common php-*


Verify the last step and press "Y"
---> Package php-pdo.x86_64 0:7.0.6-3.el6.remi will be an update
---> Package php-pecl-amqp.x86_64 0:1.7.0-1.el6.remi.5.5 will be updated
---> Package php-pecl-amqp.x86_64 0:1.7.0-1.el6.remi.7.0 will be an update
---> Package php-pecl-apfd.x86_64 0:1.0.1-1.el6.remi.5.5 will be updated
---> Package php-pecl-apfd.x86_64 0:1.0.1-5.el6.remi.7.0 will be an update
---> Package php-pecl-http.x86_64 0:2.5.6-1.el6.remi.5.5 will be updated
---> Package php-pecl-http.x86_64 0:3.0.1-1.el6.remi.7.0 will be an update
---> Package php-pecl-json-post.x86_64 0:1.0.1-1.el6.remi.5.5 will be updated
---> Package php-pecl-json-post.x86_64 0:1.0.1-3.el6.remi.7.0 will be an update
---> Package php-pecl-jsonc.x86_64 0:1.3.9-1.el6.remi.5.5 will be obsoleted
---> Package php-pecl-jsonc-devel.x86_64 0:1.3.9-1.el6.remi.5.5 will be obsoleted
---> Package php-pecl-propro.x86_64 0:1.0.2-1.el6.remi.5.5 will be updated
---> Package php-pecl-propro.x86_64 0:2.0.0-1.el6.remi.7.0 will be an update
---> Package php-pecl-raphf.x86_64 0:1.1.2-1.el6.remi.5.5 will be updated
---> Package php-pecl-raphf.x86_64 0:2.0.0-1.el6.remi.7.0 will be an update
---> Package php-pecl-zip.x86_64 0:1.13.2-1.el6.remi.5.5 will be updated
---> Package php-pecl-zip.x86_64 0:1.13.2-1.el6.remi.7.0 will be an update
---> Package php-process.x86_64 0:5.5.35-1.el6.remi will be updated
---> Package php-process.x86_64 0:7.0.6-3.el6.remi will be an update
---> Package php-soap.x86_64 0:5.5.35-1.el6.remi will be updated
---> Package php-soap.x86_64 0:7.0.6-3.el6.remi will be an update
---> Package php-xml.x86_64 0:5.5.35-1.el6.remi will be updated
---> Package php-xml.x86_64 0:7.0.6-3.el6.remi will be an update
---> Package php-xmlrpc.x86_64 0:5.5.35-1.el6.remi will be updated
---> Package php-xmlrpc.x86_64 0:7.0.6-3.el6.remi will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                     Arch            Version                         Repository           Size
=======================================================================================================
Installing:
 php-devel                   x86_64          7.0.6-3.el6.remi                remi-php70          1.3 M
     replacing  php-pecl-jsonc-devel.x86_64 1.3.9-1.el6.remi.5.5
 php-json                    x86_64          7.0.6-3.el6.remi                remi-php70           50 k
     replacing  php-pecl-jsonc.x86_64 1.3.9-1.el6.remi.5.5
Updating:
 php                         x86_64          7.0.6-3.el6.remi                remi-php70          2.7 M
 php-cli                     x86_64          7.0.6-3.el6.remi                remi-php70          4.0 M
 php-common                  x86_64          7.0.6-3.el6.remi                remi-php70          976 k
 php-gd                      x86_64          7.0.6-3.el6.remi                remi-php70           62 k
 php-mbstring                x86_64          7.0.6-3.el6.remi                remi-php70          971 k
 php-mcrypt                  x86_64          7.0.6-3.el6.remi                remi-php70           47 k
 php-mysqlnd                 x86_64          7.0.6-3.el6.remi                remi-php70          209 k
 php-opcache                 x86_64          7.0.6-3.el6.remi                remi-php70          138 k
 php-pdo                     x86_64          7.0.6-3.el6.remi                remi-php70          103 k
 php-pecl-amqp               x86_64          1.7.0-1.el6.remi.7.0            remi-php70           69 k
 php-pecl-apfd               x86_64          1.0.1-5.el6.remi.7.0            remi-php70           10 k
 php-pecl-http               x86_64          3.0.1-1.el6.remi.7.0            remi-php70          194 k
 php-pecl-json-post          x86_64          1.0.1-3.el6.remi.7.0            remi-php70           11 k
 php-pecl-propro             x86_64          2.0.0-1.el6.remi.7.0            remi-php70           19 k
 php-pecl-raphf              x86_64          2.0.0-1.el6.remi.7.0            remi-php70           22 k
 php-pecl-zip                x86_64          1.13.2-1.el6.remi.7.0           remi-php70           45 k
 php-process                 x86_64          7.0.6-3.el6.remi                remi-php70           60 k
 php-soap                    x86_64          7.0.6-3.el6.remi                remi-php70          182 k
 php-xml                     x86_64          7.0.6-3.el6.remi                remi-php70          169 k
 php-xmlrpc                  x86_64          7.0.6-3.el6.remi                remi-php70           64 k

Transaction Summary
=======================================================================================================
Install       2 Package(s)
Upgrade      20 Package(s)

Total download size: 11 M
Is this ok [y/N]:



Verify php installation by issuing php -v
Installed:
  php-devel.x86_64 0:7.0.6-3.el6.remi                php-json.x86_64 0:7.0.6-3.el6.remi

Updated:
  php.x86_64 0:7.0.6-3.el6.remi                       php-cli.x86_64 0:7.0.6-3.el6.remi
  php-common.x86_64 0:7.0.6-3.el6.remi                php-gd.x86_64 0:7.0.6-3.el6.remi
  php-mbstring.x86_64 0:7.0.6-3.el6.remi              php-mcrypt.x86_64 0:7.0.6-3.el6.remi
  php-mysqlnd.x86_64 0:7.0.6-3.el6.remi               php-opcache.x86_64 0:7.0.6-3.el6.remi
  php-pdo.x86_64 0:7.0.6-3.el6.remi                   php-pecl-amqp.x86_64 0:1.7.0-1.el6.remi.7.0
  php-pecl-apfd.x86_64 0:1.0.1-5.el6.remi.7.0         php-pecl-http.x86_64 0:3.0.1-1.el6.remi.7.0
  php-pecl-json-post.x86_64 0:1.0.1-3.el6.remi.7.0    php-pecl-propro.x86_64 0:2.0.0-1.el6.remi.7.0
  php-pecl-raphf.x86_64 0:2.0.0-1.el6.remi.7.0        php-pecl-zip.x86_64 0:1.13.2-1.el6.remi.7.0
  php-process.x86_64 0:7.0.6-3.el6.remi               php-soap.x86_64 0:7.0.6-3.el6.remi
  php-xml.x86_64 0:7.0.6-3.el6.remi                   php-xmlrpc.x86_64 0:7.0.6-3.el6.remi

Replaced:
  php-pecl-jsonc.x86_64 0:1.3.9-1.el6.remi.5.5    php-pecl-jsonc-devel.x86_64 0:1.3.9-1.el6.remi.5.5

Complete!
[user@server folder]#php -v
Failed loading /usr/lib64/php/modules/ioncube_loader_lin_5.5.so:  /usr/lib64/php/modules/ioncube_loader_lin_5.5.so: undefined symbol: zval_update_constant_inline_change
PHP 7.0.6 (cli) (built: Apr 28 2016 22:35:28) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies


Notice that we have ioncube not matching the latest PHP and we must disable this extension by:
[user@server folder]# rm /etc/php.d/ioncube.ini


Error-free PHP output
[user@server folder]# php -v
PHP 7.0.6 (cli) (built: Apr 28 2016 22:35:28) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
[user@server folder]#

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template {php}{/php} tags not allowed. Use SmartyBC to enable them

To fix php error:

PHP ERROR:

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:XXXXXX.tpl" on line 18 "

change:
$smarty = new Smarty();

to:
$smarty = new SmartyBC();