Upgrading PHP: Overview and FAQs

=Overview on the PHP Upgrade=

How does the PHP upgrade affect me?
On June 24, 2014, we will begin to automatically upgrade domains to PHP 5.4, which is the version we recommend our customers use for all their sites.

As you may know, most modern websites already run on the latest version of PHP, and the following provides important information about the PHP upgrade which may affect some hosting accounts at DreamHost.

We’re upgrading PHP because:


 * PHP.net is no longer releasing security updates for version 5.2,
 * PHP 5.3 will be unsupported by php.net by the middle of 2014, and most importantly...
 * PHP 5.4 is well tested, stable, and has been in production on sites around the world since March 2012.

Delaying the upgrade
If you wish to upgrade at your own pace, then turn off the auto-upgrade option in the Dashboard (see instructions below). We strongly recommend that you begin testing soon though, because PHP 5.2 will be completely removed from our hosting environment in November 2014.

To delay the upgrade:


 * 1) Log in to the DreamHost Dashboard.
 * [[file:SeeWhatSitesPHP.fw.png]]
 * 1) Click See what sites need upgrades.
 * The upgrade dialog box opens which shows all of your domains ready for upgrade.
 * [[file:PHPdelay.fw.png]]
 * 1) Click the Delay button next to the domains if you wish to hold off on upgrading.

Backup your account!
We recommend you backup your account now before upgrading to the latest PHP version.

You can visit the DreamHost web panel backup page to generate a complete backup of your account:


 * [[file:DHbackup.fw.png]]


 * Click Back me up! to begin the backup.
 * You can also check out our backup wiki for further information on various backup techniques and other resources.

What do I need to do?
You don't need to do anything! We're letting you know ahead of time that beginning on June 24th, 2014, the PHP settings on your domain will automatically upgrade to the latest version, 5.4. We will send you an email when the upgrade is complete and at that point we do recommend that you check your site to make sure everything is working as expected.


 * It's likely that you won't even notice the switch and your website(s) will perform as they usually do. But, in certain cases, there is a possibility that some sites may break, such as those that run older or custom-built software.
 * We don't anticipate any issues for most of our customers, but please test your site, or have a developer do this for you. Instructions for testing are provided below.
 * Upgrading to PHP5.4 is a good thing! It's the latest and greatest, and also provides the best security for modern websites. In fact, all the major web hosting companies have upgraded from 5.2 to 5.4, not just us!

So, we strongly recommend that you begin testing NOW, especially if you have custom-built software or still run an older site. The good news is that testing is easy: just upgrade your domain to PHP 5.4 in the panel. And if it breaks, you can always revert it back!

=Testing your website and FAQs=

How do I tell what version of PHP my site is running?

 * The easiest way-

The PHP version for each site is displayed in the DreamHost panel, and you can access by going to the Domains > Manage Domains section and then view the PHP setting under "Web Hosting".

There, you’ll see a setting which lists the current PHP version for the domain:


 * [[file:php_settings_panel.fw.png]]


 * The advanced way-

PHP has a special function that can retrieve information about a particular installation of itself, and the environment in which it has been installed. To retrieve this information, all you have to do is save the following in a text file with a .php extension, upload the file to a web server, and then view it with a conventional web browser:



Once you visit the page, the results will display the following:
 * information about PHP compilation options and extensions
 * the PHP version
 * server information and environment (if compiled as a module)
 * the PHP environment
 * OS version information
 * paths
 * master and local values of configuration options
 * HTTP headers, and
 * the PHP License.

How can I test my site?

 * The easiest way-

To test your site, you can change the PHP version in the DreamHost Panel going to the Domains > Manage Domains section and then click Edit next to the domain. Scroll down to Web Options, and there you’ll see a PHP Mode setting which lists the current PHP version for the domain.

Go ahead and change the PHP version to your desired version. In the event of any errors, you can switch it back to the previous PHP version:


 * [[file:php_settings_panel_select.fw.png]]


 * The advanced way-

Aside from changing the settings in the DreamHost panel, you can also change the PHP settings using an .htaccess file.

Simply add the following two lines in your .htaccess file which forces PHP to use php5.4:

AddHandler fcgid-script .php FCGIWrapper "/dh/cgi-system/php54.cgi" .php

If this causes any problems, then remove the lines to switch back to your previous settings.

I’m not sure what kind of site I have. What can I do?
Most software packages will show the name of the software in the admin section:


 * To find this info, log into your site as you normally do and search for the software name and version number.
 * If you're unable to find the software name/version, then you may want to contact your web developer and confirm that the site they created is compatible with PHP5.4.
 * If all else fails, you can always try switching the site to PHP5.4 and look for any error messages on the site.

If you do see anything wrong, note the error message for your web developer and then switch back to PHP5.2 through the DreamHost Panel.

I have a WordPress site – what does that mean for me?
You should be good to go: Wordpress works well with PHP5 and continues to work ever since WordPress v3.2 was released, though some older applications may need to be updated or modified slightly.

For more information, please see:


 * http://codex.wordpress.org/Switching_to_PHP5

What if I have One-Click Installs?
The latest versions of our one-click installs have all been tested with PHP5.4. If you’re running an older version of a one-click install app, then now is a good time to upgrade!

To upgrade your One-Click Install apps:


 * 1) Open the One-Click Installs panel.
 * [[file:OCIexamplePanel.fw.png]]
 * 1) Click the Manage Installed Applications link.
 * The Applications Catalog page opens which shows you all your domains, apps, and updates needed.
 * [[file:OCIexampleUpdate.fw.png]]
 * 1) Click Upgrade under each domain to update to the latest version of the desired application. (This example shows Upgrade to 3.9.1 for WordPress.)

I'm running Zend Optimizer – what do I do?
Zend Optimizer changed its name to Zend Guard between PHP version 5.2 and 5.3. Files encoded with Zend Optimzer using PHP 5.2 aren't compatible with Zend Guard using PHP 5.3+. To ensure a smooth transition to 5.4, make sure your files are encoded to work with Zend Guard.

It's rather simple to activate Zend Guard using a custom phprc file, and instructions for that can be found here:


 * http://wiki.dreamhost.com/ZendGuard_Loader

What if I have a custom site that was built by a developer/designer?

 * The easiest way-

You should probably ask them.


 * The advanced way-

If you’re currently using PHP5.2 or 5.3, then the upgrade to 5.4 is unlikely to cause any problems. The only issue would be if you’re using some of the deprecated functions mentioned in the Changes that affect compatibility section below. Those functions are unavailable by default in PHP5.2, so unless you’ve made custom change to the php.ini configuration, then your site probably isn’t using them and would continue to run normally using PHP5.4.

=Advanced topics on PHP 5.4=

New features of PHP 5.4

 * New language syntax including Traits, shortened array syntax, and more.
 * The session extension can now track the upload progress of files.
 * Binary number format has been added, such as:
 * 0b0111100101101111011101010110000101110010011001010111001101101101011000010111001001110100


 * Support for multibyte languages is now available in all builds of PHP at the flip of a runtime switch.
 * Improved performance and reduced memory consumption.
 * Cleaner code base thanks to the removal of multiple deprecated language features.

Changes that affect compatibility

 * Register globals, magic quotes and safe mode were removed.
 * The break / continue $var syntax was removed.
 * The ini option allow_call_time_pass_reference was removed.
 * The PHP default_charset is now "UTF-8" within the distributed php.ini files, but still defaults to "".

Customization
You can easily make changes to the php.ini settings using a phprc file as described in the following wiki article:


 * http://wiki.dreamhost.com/Php.ini#PHP_5.3_.2F_5.4

What if my scripts require a PHP Loader?
We have a few pages that explain how to add your flavor of PHP loader:


 * http://wiki.dreamhost.com/ZendGuard_Loader
 * http://wiki.dreamhost.com/Installing_php_loaders

Helpful PHP5.4 Migration guide

 * http://au1.php.net/migration54

Description of the new syntax

 * Traits

Traits is a new tool to allow methods to be defined only once and then used with multiple classes. Here is a good tutorial. http://www.sitepoint.com/using-traits-in-php-5-4/


 * Shortened array syntax

As of PHP 5.4, you can use the short array syntax, which replaces array with [].

 "bar",    "bar" => "foo", );

// as of PHP 5.4 $array = [ "foo" => "bar", "bar" => "foo", ]; ?>