Skip to content

Instantly share code, notes, and snippets.

@manish-pragma
Forked from heathdutton/upgrade-php7.sh
Created July 9, 2018 10:37
Show Gist options
  • Save manish-pragma/fec8a3df6f4ed6e89e4eb4258292900a to your computer and use it in GitHub Desktop.
Save manish-pragma/fec8a3df6f4ed6e89e4eb4258292900a to your computer and use it in GitHub Desktop.
Upgrade PHP 7.0 to 7.1 on Amazon Linux (specifically for Elastic Beanstalk but should work elsewhere)
#!/usr/bin/env bash
# Upgrade an Amazon Linux PHP 7.0 EC2 to PHP 7.1
#
# Must be ran as sudo:
# sudo bash upgrade-php71.sh
#
# Can be added to ./.ebextensions/20_php.config like so:
# container_commands:
# 20_php71_upgrade:
# command: sudo bash scripts/upgrade-php71.sh
set -e
cd /tmp
# Enable remi-php71 (rpm no longer needed)
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm
yum-config-manager --enable remi-php71
# Get RPM package (rpm no longer needed)
# wget ftp://195.220.108.108/linux/epel/6/x86_64/scl-utils-20120229-1.el6.x86_64.rpm
# rpm -Uvh scl-utils-20120229-1.el6.x86_64.rpm
# Remove PHP 7.0 (excessive, but deterministic)
yum remove php70 -y
yum remove php70-cli -y
yum remove php70-bcmath -y
yum remove php70-common -y
yum remove php70-devel -y
yum remove php70-gd -y
yum remove php70-intl -y
yum remove php70-json -y
yum remove php70-mbstring -y
yum remove php70-mcrypt -y
yum remove php70-mysqlnd -y
yum remove php70-odbc -y
yum remove php70-opcache -y
yum remove php70-pdo -y
yum remove php70-pecl-apcu -y
yum remove php70-pecl-igbinary -y
yum remove php70-pecl-imagick -y
yum remove php70-pecl-memcache -y
yum remove php70-pecl-memcached -y
yum remove php70-pecl-oauth -y
yum remove php70-pecl-ssh2 -y
yum remove php70-pecl-uuid -y
yum remove php70-pgsql -y
yum remove php70-process -y
yum remove php70-soap -y
yum remove php70-xml -y
yum remove php70-xmlrpc -y
# Install PHP 7.1
yum install php71 -y
yum install php71-cli -y
yum install php71-bcmath -y
yum install php71-common -y
yum install php71-devel -y
yum install php71-gd -y
yum install php71-intl -y
yum install php71-json -y
yum install php71-mbstring -y
yum install php71-mcrypt -y
yum install php71-mysqlnd -y
# Shouldn't be necessary
yum install php71-php-pecl-mysql -y
yum install php71-odbc -y
yum install php71-opcache -y
yum install php71-pdo -y
yum install php71-pecl-apcu -y
yum install php71-pecl-igbinary -y
# yum install php71-pecl-imagick -y
yum install php71-pecl-memcache -y
yum install php71-pecl-memcached -y
# yum install php71-pecl-oauth -y
# yum install php71-pecl-ssh2 -y
# yum install php71-pecl-uuid -y
yum install php71-pgsql -y
yum install php71-process -y
yum install php71-soap -y
yum install php71-xml -y
yum install php71-xmlrpc -y
# Restart Apache.
service httpd restart
@manish-pragma
Copy link
Author

Hi,
getting the following error. Please suggest any solution

Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
1483 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package php71-gd.x86_64 0:7.1.17-1.32.amzn1 will be installed
--> Processing Dependency: libwebp.so.4()(64bit) for package: php71-gd-7.1.17-1.32.amzn1.x86_64
--> Finished Dependency Resolution
Error: Package: php71-gd-7.1.17-1.32.amzn1.x86_64 (amzn-updates)
Requires: libwebp.so.4()(64bit)
Available: libwebp-0.3.0-3.5.amzn1.x86_64 (amzn-main)
libwebp.so.4()(64bit)
Installed: libwebp-0.4.3-3.el6.x86_64 (installed)
~libwebp.so.5()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
You have new mail in /var/spool/mail/ec2-user

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