Last active
January 18, 2019 12:22
-
-
Save vhr/836c178c520535d48163ef26800283c2 to your computer and use it in GitHub Desktop.
Bash script for migration to PHP v7.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/ |
++ yum install php72-php-xml
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
Error log can be found under:
/var/opt/remi/php72/log/php-fpm/www-error.log