Skip to content

Instantly share code, notes, and snippets.

@vhr
Last active January 18, 2019 12:22
Show Gist options
  • Save vhr/836c178c520535d48163ef26800283c2 to your computer and use it in GitHub Desktop.
Save vhr/836c178c520535d48163ef26800283c2 to your computer and use it in GitHub Desktop.
Bash script for migration to PHP v7.2
#!/bin/bash
#######################################################
# Install PHP 7.2 on CentOS 7 https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/
# PHP Roadmap http://php.net/supported-versions.php
#######################################################
# Add PHP 7.2 repo
yum -y install wget
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php72
# Install PHP 7.2
yum -y install php72 php72-php-fpm php72-php-cli php72-php-mbstring php72-php-opcache php72-php-pdo_mysql php72-php-intl php72-php-curl php72-php-gd php72-php-gmp php72-php-ldap php72-php-pecl-apcu php72-php-json php72-php-pecl-zip php72-php-xml php72-php-gnupg
# Add and start php-fpm as service
systemctl enable php72-php-fpm
systemctl daemon-reload
systemctl start php72-php-fpm
# netstat -an | grep :9000
systemctl status php72-php-fpm
# Redirect request from Apache to php-fpm
sed -i 's/php_value/#php_value/g' /etc/httpd/conf.d/php.conf
sed -i 's/SetHandler\ application\/x\-httpd\-php/SetHandler\ \"proxy\:fcgi\:\/\/127.0.0.1\:9000\"/g' /etc/httpd/conf.d/php.conf
# Backup php-fpm configuration
cp /etc/opt/remi/php72/php-fpm.d/www.conf /etc/opt/remi/php72/php-fpm.d/www.conf.bkp
# Updated session path and add timezone
sed -i 's/\/var\/opt\/remi\/php72\/lib\/php\/session/\/var\/lib\/php\/session/g' /etc/opt/remi/php72/php-fpm.d/www.conf
sed -i 's/;date.timezone =/date.timezone = "Europe\/London"/g' /etc/opt/remi/php72/php.ini
systemctl restart php72-php-fpm
# Backup old php5-cli
mv /usr/bin/php /usr/bin/php5
ln -s /usr/bin/php72 /usr/bin/php
# Restart Apache service
systemctl restart httpd
# Show PHP version
php -v
curl -I http://127.0.1.1/centreon/
@vhr
Copy link
Author

vhr commented Apr 30, 2018

Install bash script on the local machine

# curl -OsSL https://gist.github.com/vhr/836c178c520535d48163ef26800283c2/raw/migrate-to-php72.sh
# chmod +x migrate-to-php72.sh
# ./migrate-to-php72.sh

Copy link

ghost commented May 2, 2018

Error log can be found under:

/var/opt/remi/php72/log/php-fpm/www-error.log

@victorvassilev
Copy link

victorvassilev commented May 2, 2018

++ yum install php72-php-xml

@victorvassilev
Copy link

victorvassilev commented May 11, 2018

also: set default timezone in php.ini:

sed -i "s/^;date.timezone =$/date.timezone = "Europe/London"/" /etc/opt/remi/php72/php.ini |grep "^timezone" /etc/opt/remi/php72/php.ini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment