Upgade Cloud9 Workspace to PHP 7.2

Update: 05 May 2019

I’ve discovered a page at https://www.soupbowl.io/2018/04/using-php-7-on-ubuntu-14-04-with-codeanywhere/ as an alternate source for updating PHP to version 7.2. Look for the section “Updating PHP 5.4 to PHP 7”. I haven’t tried the process, but it looks pretty good.

 

Updated: 14 April 2019

According to this announcement, the old Cloud9 service (c9.io) is soon to be no more, with all functionality ending 30 June 2019, and complete shutdown 30 November 2019.
What is the future of C9? It will be 100% within Amazon Web Services as AWS Cloud9.
I – like many others – am not a fan of AWS. In fact, I think AWS is one of the worst development services I’ve used, and Cloud9 proves it. They took an incredibly powerful and easy to use service and… well, totally fucked it to be honest. To the point I spent an hour of my Sunday afternoon swearing while trying to setup a new AWS Cloud9 WordPress environment.

As such, I am unsure at this time if I will continue to work with AWS Cloud9 or find an alternate cloud IDE (I now use https://codeanywhere.com). I use IDEs in a professional capacity and I’m happy to pay for convenience and ease-of-development experience.

Anyway, I won’t be attempting any C9.io workspace upgrades in future. I will, however, create a new post when I decide which development environment to use.

 

Updated: 03 March 2019
After my original environment upgrade I started to see CPU maxing on page loads. I thought it was code changes, but it wasn’t. I run WordPress in my environment and even /wp-admin was causing a 5-20x increase in page load times with 100% CPU spikes.

I happened to find a copy of my environment that was still the original PHP 5.5.9 version and have been using that since a week after this original post. CPU has been fine.

Today I cloned my working environment, did some more searching, and tested a PHP upgrade again. The section “Updated Solution (03 March 2019)” below contains the results of that upgrade. So far, so good. The upgrade process is not that different to the original.

However, /phpmyadmin shows an error “The mbstring extension is missing. Please check your PHP configuration.” I’m not surprised because I my script excluded that (see notes within the 03 March section).
I will work on this next, but I wanted to publish updated results before that happens.


Updated Solution (03 March 2019)

Today’s results are modified from [and thanks to] https://www.joeferguson.me/install-and-configure-php-7-1-on-cloud-9-workspaces/.

Run the following commands, but note:

sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y

#sudo apt-get install php7.2-curl php7.2-cli php7.2-dev php7.2-gd php7.2-intl php7.2-mcrypt php7.2-json php7.2-mysql php7.2-opcache php7.2-bcmath php7.2-mbstring php7.2-soap php7.2-xml php7.2-zip -y
sudo apt-get install php7.2-curl php7.2-cli php7.2-dev php7.2-gd php7.2-intl php7.2-json php7.2-mysql php7.2-opcache php7.2-bcmath php7.2-mbstring php7.2-soap php7.2-xml php7.2-zip -y

sudo mv /etc/apache2/envvars /etc/apache2/envvars.bak
sudo apt-get remove libapache2-mod-php5 -y
sudo apt-get install libapache2-mod-php7.2 -y
sudo cp /etc/apache2/envvars.bak /etc/apache2/envvars

sudo a2dismod php5
sudo a2enmod php7.2

sudo service apache2 restart

 

 

 

 


Original Post Solution

Cloud9 is a great online IDE (or it was before the Amazon AWS team got their hands on it).

The problem is the default PHP version in my workspace was 5.6, well out of date and unsupported.

It turns out, upgrading PHP version’s isn’t a simple matter. After much search in found this solution on StackOverflow that worked for me:

https://stackoverflow.com/a/51028239/115704

sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y

sudo apt-get install php7.2 php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml -y

sudo mv /etc/apache2/envvars /etc/apache2/envvars.bak
sudo apt-get remove libapache2-mod-php5 -y
sudo apt-get install libapache2-mod-php7.2 -y
sudo cp /etc/apache2/envvars.bak /etc/apache2/envvars

sudo a2dismod php5
sudo a2enmod php7.2

sudo service apache2
sudo service apache2 restart

Cloud9 – Manually installing WordPress

  1. Create a WorkSpace (or clone from a repository).
  2. Download the latest WordPress source (https://wordpress.org/download/).
  3. Extract the file. Copy the files/folders upload to your Cloud9 workspace root.
  4. Make sure MySQL is running and open myPHPAdmin (see https://kb.vylesk.com/59/cloud9-setting-up-and-using-phpmyadmin-mysql-web-interface/).
  5. Create a new database for the site.
    1. I use utf8_general_ci collation.
  6. Create a new user for the site (give appropriate permissions – for right or wrong I give all permissions because I have seen Cloud9 do this when doing a 5-minute install).
    1. I set host to “%” (all).
  7. Create a wp-config.php from the wp-config-sample.php. Update the database name, username, password, and set an alternative table prefix if needed.
  8. Run the site and browse to the root of the site. The WordPress install process should automatically begin (starting with language selection) and complete the rest of the setup.

Cloud9 – Setting up and using phpMyAdmin MySQL web interface

This page – https://community.c9.io/t/setting-up-phpmyadmin/1723 – says it all, but here are the keys points again:

Using PHPMyAdmin with Cloud9

First, create a PHP workspace so you have PHP, MySQL, and Apache installed right away. You can then make sure you have MySQL installed by running:

mysql-ctl install

Then install phpMyAdmin:

phpmyadmin-ctl install

After the installation is complete you’ll just want to make sure mysql is running once more:

mysql-ctl start

After installing phpMyAdmin, you were given a link to access PHPMyAdmin which will follow the pattern of: https://[workspacename]-[username].c9users.io/phpmyadmin. From that link, you can log in with your Cloud9 username and a blank password.

Cloud9 (C9) – Add a Workspace to Bitbucket

When you need to add a clean workspace in Cloud9 online IDE (c9.io) to a Bitbuck (or GitHub) repository after it is created (that is, when it is not already connected to source control).

Steps to make it happen:

  1. Create a new repo in Bitbucket.
  2. “git init” from command-line in the directory to act as the root of the new repo.
  3. Run “git remote add …” (e.g. “git remote add origin git@bitbucket.org:jsnelders/wp-test.git”)
  4. Run “git add” and “git commit -m” command to add files to Git staging, then commit (with a comment).
  5. Run “git push” to push the committed files to the origin

You can also:

  1. Add a .gitignore file.
  2. For WordPress, it may be worth adding “wp-config.php” to the .gitignore, depending on whether you store sensitive information (passwords, API keys) in the file.

See also: