PHP migrations

This article presents tips and guides to help you migrate between PHP versions on Simple Hosting.

Migrating to PHP 7 on Simple Hosting

A PHP 7 instance is now available with MySQL 5.6 (Percona), PostgreSQL 9.4 or MongoDB 2.4.

This document lists known differences or compatibility issues between the PHP 7 instance and other PHP instances (5.4 and 5.6).

It also provides instructions on how to migrate your code, VHOSTS and databases from an existing PHP instance to a new PHP 7 instance.

Known differences from older versions

Timezone management

Like PHP 5.6 instances, PHP 7 instances use the UTC (Universal Coordinated Time) timezone by default.

You can change the date.timezone setting in the php.ini file to use the timezone of your choice.

For example :

date.timezone = "America/New_York"

Your own binaries

You can install your own libraries, binaries and modules on the PHP 7 instance.

  • With sFTP, place your files in the /lamp0/home/ folder
  • When connected via SSH, the places should be in the /srv/data/home/ folder

PHP 7 versus PHP 5.6

PHP 7 includes several differences and new features compared to older versions of the language.

We recommend that you read the official documentation to learn more:

PHP 7 versus PHP 5.4

The PHP 7 instance is very similar to the PHP 5.6 instance, to which our customers first had the opportunity to migrate from PHP 5.4.

We recommend that you take a look at the PHP 5.6 migration guide below to know more about the differences between the PHP 5.4 instance and the PHP 7 instance.

MySQL 5.6 (Percona)

The PHP 7 instance comes with MySQL 5.6 (Percona) pre-installed. Percona Server is an optimized and stable version of MySQL 5.6.

You can learn more about MySQL 5.6 (Percona) server in their official documentation:

It should work seamlessly with data from MySQL 5.5 (the version installed in other Simple Hosting PHP images). We recommend that you test your application before migrating your production data to the new version. Please check out the guide below to learn more.

PostgreSQL 9.4

You can also opt for PostgreSQL 9.4, which comes with native support for the JSON data format. Migration from PostgreSQL 9.2 or 9.3 should work without issues – we recommend that you checkout the official documentation for more information.

http://www.postgresql.org/docs/9.4/static/upgrading.html

The information below offers guidance on how to migrate your current database to a new PHP 7 instance with PostgreSQL 9.4.

MongoDB 2.4

The new PHP 5.6 and PHP 7 instances require you to include the “mongodb” library. We recommend that you use Composer to manage your application's dependencies and make this process easier.

Please learn more about how to use MongoDB with PHP in the dedicated section of the instance documentation.

How to test your application with PHP 7

The following generic examples should provide some ideas about how you can test your application on your own computer or on a new Simple Hosting instance before migrating.

1 - Test locally

  • Install and run PHP 7 and Percona Server 5.6 on your computer
  • Dump your database on the old instance
  • Import the database dump into your local database engine
  • Run and test your application to see if everything is working correctly

2 - Test on a new PHP 7 instance

  • Create a new PHP 7 instance

You can create a new instance by selecting “PHP 7 / MySQL 5.6 (Percona)”, “PHP 7 / PostgreSQL 9.4” or “PHP 7 / MongoDB 2.4” at the following URL (you'll need to login or create a free account first):

https://www.gandi.net/hosting/simple/create

With Gandi CLI, you can run the following command replacing <tt>{instance type}</tt> with <tt>php7mysql5.6</tt>, <tt>php7pgsql9.4</tt> or <tt>php7mongodb2.4</tt>:

  $ gandi paas create --type {instance type}

Migrate your application

1 - Dump your database on the old instance

Access your instance via the SSH console or the web admin to export your databases.

2 - Create a new PHP 7 instance

You can create a new instance by selecting “PHP 7 / MySQL 5.6 (Percona)”, “PHP 7 / PostgreSQL 9.4” or “PHP 7 / MongoDB 2.4” at the following URL (you'll need to login or create a free account first):

https://www.gandi.net/hosting/simple/create

With Gandi CLI, you can run the following command replacing <tt>{instance type}</tt> with <tt>php7mysql</tt>, <tt>php7pgsql</tt> or <tt>php7mongodb</tt>:

  $ gandi paas create --type {instance type}

3 - Upload your files to the new instance

Remember to upload the database dump file so you can import it on the instance.

4 - Import the database dump (or make a new one)

5 - Migrate your VHOSTS

This step will involve a bit of downtime, as it involves changing DNS settings that take their time to propagate.

Step 1 - Remove your vhosts:

https://wiki.gandi.net/en/simple/migrate#remove_the_old_vhost

Step 2 - Create the vhosts on the new instance:

https://wiki.gandi.net/en/simple/migrate#create_the_new_vhost

6 - Shut down the old instance (you will be refunded on your prepaid account)

Now that all the traffic is being sent to the new instance, you can shutdown the old instance. Your prepaid account will be credited with the pro-rated amount corresponding to the time remaining on your subscription.

Migrating to PHP 5.6 on Simple Hosting

We have released a new PHP instance supporting PHP 5.6 and new instance creations will default this new version.

You can still create instances running PHP 5.4, but it is now considered deprecated and we encourage our users to migrate to PHP 5.6.

We can however support PHP 5.4 until Debian 7 (the instance's base system) reaches End Of Life, which is currently scheduled for April/May 2018. We will inform our customers about any evolutions to our plans.

This document lists known differences or compatibility issues between PHP 5.4 to PHP 5.6, and provides instructions on how to migrate your code, VHOSTS and databases from an existing PHP 5.4 instance to a new PHP 5.6 instance.

Known differences and issues

Timezone management

PHP 5.6 instances use the UTC (Universal Coordinated Time) timezone by default.

You can change the date.timezone setting in the php.ini file to use the timezone of your choice.

For example :

date.timezone = "America/New_York"

Your own binaries

Before we launched the PHP 5.6 instance, you could find some pre-installed binaries and libraries in /usr/local/bin/, such as the SIPS/ATOS module.

On the new PHP 5.6 instance, you must install your own libraries/modules.

  • With sFTP, place your files in the /lamp0/home/ folder
  • When connected via SSH, the places should be in the /srv/data/home/ folder

Make sure you install your own binaries and modules on the new PHP 5.6 instance.

PHP 5.4 versus 5.6

This sections contains links to official PHP resources describing the changes made between versions. We will enrich it with feedback from our customers whenever we are made aware of relevant cases.

There are some slight differences between PHP 5.4 and PHP 5.6 that might impact you. To be safe, you might want to test your application with PHP 5.6 before you attempt a migration.

How to test your application with PHP 5.6

The following generic examples should provide some ideas about how you can test your application on your own computer or on a new Simple Hosting instance before migrating.

1 - Test locally

2 - Test on a new PHP 5.6 instance

Automatic upgrade (MySQL users only)

Clients using PHP MySQL instances can automatically upgrade from PHP 5.4 to PHP 5.6. PostgreSQL and MongoDB users can learn how to perform a manual upgrade in the next section.

  • Because VHOSTS need to be migrated and the data disks are reattached to another instance, you will experience some downtime (up to 20 mins). You can have more control over downtime if you migrate your instance manually (see the manual migration section below).
  • The automatic migration is a one-way process and you won't be able to revert back to PHP 5.4 automatically.

All your code, VHOSTS, databases, log files and snapshots will be moved to the new instance running PHP 5.6. Your billing will not be impacted either, but you can expect a bit of downtime while the new DNS settings are propagated.

Please make sure you understand the differences between both versions so that you don't break your code by reading the resources listed above.

If you have any doubts, follow the instructions above to test your application with PHP 5.6. If you encounter an issue that is not a code-related problem, contact our Support team (we might not be able to help you debug your application code).

Start the migration from the website

In your instance's admin page, simply click on the Upgrade button to start the process.

Start the migration from the API

You can use the following API methods to check if an instance can be automatically upgraded and to launch the automatic upgrade process.

1. Check if upgrade is possible

The “need_upgrade” property will be set to “true” in the “paas.list()” or “paas.info()” methods.

http://doc.rpc.gandi.net/paas/reference.html#PaasListReturn

2. Upgrade an instance

Set the “upgrade” property to “true” and call the “paas.update()” method.

http://doc.rpc.gandi.net/paas/reference.html#PaasUpdateParams

Manual upgrade

1 - Dump your database on the old instance

Access your instance via the SSH console or the web admin to export your databases.

2 - Create a new PHP instance

The PHP 5.6 instance is currently the default, so you simply have to choose between PHP PostgreSQL, MongoDB or MySQL.

The PHP 5.4 instance has been renamed to reflect is deprecation status.

More information: https://wiki.gandi.net/en/simple/create-instance

3 - Upload your files to the new instance

Remember to upload the database dump file so you can import it on the instance.

4 - Import the database dump (or make a new one)

5 - Migrate your VHOSTS

This step will involve a bit of downtime, as it involves changing DNS settings that take their time to propagate.

Step 1 - Remove your vhosts:

https://wiki.gandi.net/en/simple/migrate#remove_the_old_vhost

Step 2 - Create the vhosts on the new instance:

https://wiki.gandi.net/en/simple/migrate#create_the_new_vhost

6 - Shut down the old instance (you will be refunded on your prepaid account)

Now that all the traffic is being sent to the new instance, you can shutdown the old instance. Your prepaid account will be credited with the pro-rated amount corresponding to the time remaining on your subscription.

Last modified: 06/15/2016 at 16:57 by Alexandre L. (Gandi)