Skip to content

Instantly share code, notes, and snippets.

@mavieth
Created May 2, 2017 01:38
Show Gist options
  • Select an option

  • Save mavieth/b6b3b622dd9f863ca2c7db2da04ab215 to your computer and use it in GitHub Desktop.

Select an option

Save mavieth/b6b3b622dd9f863ca2c7db2da04ab215 to your computer and use it in GitHub Desktop.
Upgrade from PHP 5.X.X to PHP 7 on an AWS EC2 Linux Server
#!/bin/bash
echo "==============================="
echo "Installing PHP 7"
echo "==============================="
sudo yum install php70
echo "==============================="
echo "Installing PHP 7 additional commonly used php packages"
echo "==============================="
sudo yum install php70-gd
sudo yum install php70-imap
sudo yum install php70-mbstring
sudo yum install php70-mysqlnd
sudo yum install php70-opcache
sudo yum install php70-pecl-apcu
echo "==============================="
echo "Linking PHP 7"
echo "==============================="
sudo ln -sf /etc/httpd/conf.d/php-conf.7.0 /etc/alternatives/php.conf
sudo ln -sf /etc/httpd/conf.modules.d/15-php-conf.7.0 /etc/alternatives/10-php.conf
echo "==============================="
echo "Choose PHP 7 as an Alternative"
echo "==============================="
sudo alternatives --config php
@hcumbicusr

Copy link
Copy Markdown

Muy bueno, pude actualizar mi php5.6 a php7.0 al primer intento e incluso seteó el path a v7.
Muchas gracias.

@vijayk2017

Copy link
Copy Markdown

how to select php 7 for specific project on on my one vhost on ec2

@luiscordero29

Copy link
Copy Markdown

Muchas Gracias, por el aporte!

@mrf

mrf commented Oct 23, 2017

Copy link
Copy Markdown

Super solid, saved me a ton of time stringing this together myself.

@LondonWebFactory

Copy link
Copy Markdown

You are a star! Many thanks.

@doctortheisen

Copy link
Copy Markdown

Rock 'n roll! Thanks for putting this together and sharing.

@asmendez

asmendez commented Jan 9, 2018

Copy link
Copy Markdown

Hello
Do you know, how can I do it in "Amazon Linux 2.0 (2017.12) LTS Release Candidate?

It seems that default repository do not have php70 package

@blasto333

Copy link
Copy Markdown

Will this allow php56 packages to stay installed? Could I switch to php56 after installing php 7?

@lambfrier

Copy link
Copy Markdown

@asmendez re:

Do you know, how can I do it in "Amazon Linux 2.0 (2017.12) LTS Release Candidate?

Maybe start with this:
amazon-linux-extras install php7.2

https://stackoverflow.com/a/50673146/7010923

@lvdopqt

lvdopqt commented Jun 8, 2018

Copy link
Copy Markdown

awesome work! thanks 👍

@darrowj

darrowj commented Jul 16, 2018

Copy link
Copy Markdown

Thank you very much for this. I have been avoiding this upgrade for a while. I kept running into issues with the existing php5.6 version on my server. This did the trick perfectly. Many thanks.

@kirilledelman

Copy link
Copy Markdown

Thank you! Worked without mangling up my configuration.

@kilinkis

kilinkis commented Aug 3, 2018

Copy link
Copy Markdown

thank you buddy

@NLeone

NLeone commented Sep 8, 2018

Copy link
Copy Markdown

Sorry, a query, it is not necessary to uninstall php5.6 first? how would the process for such an uninstall be, thank you very much! Regards!

@SupaMic

SupaMic commented Dec 27, 2018

Copy link
Copy Markdown

Awesome!! this also seemed to work seamlessly with PHP 7.2 by replacing all the 70 or 7.0 to 72 or 7.2!

@juaniemen

Copy link
Copy Markdown

TY so much!

@alangumer

Copy link
Copy Markdown

Useful, thanks!

@gbutiri

gbutiri commented May 10, 2019

Copy link
Copy Markdown

Few hiccups, but those were on my end. Great job! Thank you!! As an alternative, I would offer the command line sudo update-alternatives --config php

@fmangat

fmangat commented Dec 19, 2019

Copy link
Copy Markdown

thank you so much

@mavieth

mavieth commented Dec 19, 2019

Copy link
Copy Markdown
Author

thank you so much

No problem I'am glad that you found it useful!

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