PHP configuration
PHP can vary between OS distributions; see the documentation specific to your installation of PHP.
-
First determine which
php.ini
file is in use by the PHP Apache module. Note that it may not necessarily be the samephp.ini
file that is in use when calling PHP from the command line (running php --ini from the command line reports this).If you're having trouble determining which
php.ini
the PHP Apache module is using, create a PHP file that can be served through Apache with the following contents:<?php phpinfo();?>
Point your browser to this file and look for this table row in the resulting table:
Loaded Configuration File
-
Ensure that
date.timezone
is set correctly for your system.Some distributions do not make a default timezone available to PHP, so the best practice to set the timezone for PHP explicitly. See the list of supported timezones.
An example
date.timezone
setting inphp.ini
:date.timezone = America/Vancouver
-
Verify that the iconv, json, and session extensions are present.
They are usually enabled by default, although you may have to install packages for them through your OS distribution. Verify they are present by searching for their respective names in the
phpinfo
output above. -
Enable P4PHP, the Perforce extension for PHP:
For Swarm to communicate with a Helix Versioning Engine, it needs the P4PHP extension. Swarm comes with a number of variants of the P4PHP binary, for Linux platforms (32- and 64-bit) and Mac OS X (Darwin), and for PHP 5.3, 5.4, and 5.5.
Note
For Linux, the default variants are compiled with glibc 2.11. We have also included PHP 5.3 variants compiled with glibc 2.3.3 to support those customers on older distributions, such as Red Hat Enterprise Linux 5.9.
To enable P4PHP, edit the web server's
php.ini
file and add the following line:extension=/path/to/swarm/p4-bin/bin.
<platform>
/perforce-<variant>
.soExample 1: for a 64-bit Linux system running PHP 5.4:
extension=/path/to/swarm/p4-bin/bin.linux26x86_64/perforce-php54.so
Example 2: for a 32-bit Linux system running PHP 5.3 with glibc older than 2.11:
extension=/path/to/swarm/p4-bin/bin.linux26x86/perforce-php53-glibc2.3.3.so
Alternatively, copy the extension file to the default location for PHP extensions, and then just add this line instead:
extension=perforce-
<variant>
.so -
Restart Apache for the changes to become active.
-
To verify that P4PHP is active, navigate to the
phpinfo
file you created above. You should then see aperforce
section (search for "Perforce Module"). It should report that the module is enabled and display the version information.
Note
Be aware that any operating system upgrades on the machine hosting Swarm
may involve updates to PHP. If this occurs, the
php.ini
needs to be updated to point to the correct
variant
of P4PHP to match the version of PHP
that the upgraded operating system is using.
Alternative PHP Cache (APC) extension for PHP
APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. Enabling APC improves Swarm performance by caching Swarm's compiled bytecode.
-
We recommend that you install APC from your OS distribution, via apt-get, yum, etc. If your distribution does not offer the APC package for PHP, do so via PECL (although you may have to resolve system dependencies):
$ sudo pecl install apc
-
Verify that APC is enabled in your PHP Apache module's
php.ini
file (as determined in the section above for P4PHP). You may need to add the following line:extension=apc.so
-
Restart Apache for the changes to become active.
-
To verify that APC is active, navigate to the
phpinfo
file you created above. You should then see anapc
section (you may have to search for "APC Support"). It should report its version information and a table for its directives.We currently do not have any specific recommendations for which APC directives to set.
Warning
Once you have completed installing and enabling P4PHP and APC, we recommend that you remove the
phpinfo
file you created to avoid disclosing information about your installation.
Zend OPCache extension for PHP
Zend OPCache, like APC, improves PHP performance by storing compiled PHP code into a cache, removing the need for PHP to load and parse scripts on each request.
Zend OPCache is bundled with PHP 5.5.x, and is recommended for use instead of APC. For PHP versions 5.3 and 5.4, Zend OPCache is not bundled, but is available via PECL.
Install Zend OPCache
-
We recommend that you install Zend OPCache from your OS distribution, via apt-get, yum, etc. If your distribution does not offer the Zend OPCache package for PHP, do so via PECL (although you may have to resolve system dependencies):
$ sudo pecl install zendopcache
-
Verify that Zend OPCache is enabled in your PHP Apache module's
php.ini
file (as determined in the section above for P4PHP). You may need to add the following line:zend_extension=/path/to/opcache.so
-
Restart Apache for the changes to become active.
-
To verify that Zend OPCache is active, navigate to the
phpinfo
file you created above. You should then see aZend OPcache
section. It should report its version information and a table for its directives.We currently do not have any specific recommendations for which Zend OPCache directives to set.
Warning
Once you have completed installing and enabling P4PHP and Zend OPCache, we recommend that you remove the
phpinfo
file you created to avoid disclosing information about your installation.
Enable Zend OPCache
For PHP 5.5+, while Zend OPCache is included, it may not be enabled. If
you choose to use it, you may need to add the following line to your PHP
Apache module's php.ini
file:
opcache.enable = 1
If you have edited php.ini
, ensure that you restart
Apache for the changes to become active.
ImageMagick (imagick) extension for PHP
Imagick is a PHP extension that integrates the ImageMagick graphics library's API for the creation and manipulation of images. Enabling Imagick improves Swarm's ability to preview graphics formats that web browsers typically cannot display.
-
We recommend that you install Imagick from your OS distribution, via apt-get, yum, etc. If your distribution does not offer the imagick package for PHP, do so via PECL (although you may have to resolve system dependencies):
$ sudo pecl install imagick
-
Verify that imagick is enabled in your PHP Apache module's
php.ini
file (as determined in the section above for P4PHP). You may need to add the following line:extension=imagick.so
-
Restart Apache for the changes to become active.
-
To verify that imagick is active, navigate to the
phpinfo
file you created above. You should then see animagick
section. It should report its version information and a table for its directives, supported image file formats, and more.Warning
Once you have completed installing and enabling P4PHP and imagick, we recommend that you remove the
phpinfo
file you created to avoid disclosing information about your installation.