Skip to content

Instantly share code, notes, and snippets.

@alflanagan
Last active June 13, 2017 20:33
Show Gist options
  • Save alflanagan/e7554a977ae4728edc86e635d0559e59 to your computer and use it in GitHub Desktop.
Save alflanagan/e7554a977ae4728edc86e635d0559e59 to your computer and use it in GitHub Desktop.
Script to install PHP 7 into a Cloud9 (https://c9.io) PHP5 workspace.
#!/bin/bash
# Script to set up PHPBrew in a Cloud9 (https://c9.io) container
# install PHP 7.1.6, and configure apache to run it
# install phpbrew
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod a+x phpbrew
sudo mv phpbrew /usr/local/bin
sudo chown root:root /usr/local/bin/phpbrew
# setup phpbrew for user
phpbrew init
echo 'export PHPBREW_SET_PROMPT=1' >> ~/.bashrc
echo 'source ${HOME}/.phpbrew/bashrc' >> ~/.bashrc
. ~/.bashrc
# missing dependencies
sudo apt-get update
sudo apt-get install libmcrypt-dev apache2-dev
# temporarily set permissions to allow install from userland -- be careful!!!
sudo chmod o+w /usr/lib/apache2/modules
sudo chmod -R o+w /etc/apache2/
sudo chmod o+w /var/lib/apache2/module/enabled_by_admin/
# install 7.1.6. Will also build and install Apache modules
# check phpbrew docs for appropriate args for your setup
phpbrew install -j $(nproc) 7.1.6 +mb +default +apxs2 -- --with-openssl
# Don't leave those permissions open!
# TODO: set up trap to do this in event of failure
sudo chmod o-w /usr/lib/apache2/modules
sudo chmod -R o-w /etc/apache2/
sudo chmod o-w /var/lib/apache2/module/enabled_by_admin/
# for some strange reason, php7 configuration file not created
# borrow php5's
# TODO: update conf to accept *.php7 files
sudo cp /etc/apache2/mods-available/php5.conf /etc/apache2/mods-available/php7.conf
# enable the new configuration
sudo a2dismod php7
sudo a2enmod php7
echo "Be sure to set PHP options (phpbrew config) and restart your project."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment