PHP on Shared Accelerators
Introduction
This page is a guide to creating and deploying scripts and applications developed in the PHP programming language on Shared Accelerators.
If you're new to PHP, or want a general introduction to developing and deploying PHP scripts and applications, start off by reading the PHP Overview in the All Accelerators Knowledge Base.
Versions
We provide PHP 5.2.x by default. The command line version is at /usr/local/bin/php. The FastCGI version that is used to provide PHP for your virtual servers is at /usr/local/bin/php5-cgi.
PHP 5.2.9 with Suhosin-Patch 0.9.7 (cli) (built: May 9 2009 13:01:41)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
PHP 4.4.x is also available, but without a command line version. The CGI/FastCGI binary is at /usr/local/bin/php4-cgi.
PHP 4.4.7 (cgi-fcgi) (built: Aug 4 2007 14:54:13) Copyright (c) 1997-2007 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
Extensions
The most popular PHP extensions are loaded with each version by default. You can enable/disable any of these by editing the php.ini file that is present in the etc/php5 or etc/php4 directories on each of your virtual servers.
| Default | Optional | |
|---|---|---|
| PHP5 | ctype, date, filter, gd, hash, iconv, libxml, mbstring, mcrypt, mysql, mysqli, openssl, pcre, Reflection, session, SimpleXML, SPL, standard, tokenizer, xml, xmlreader, xmlwriter, Zend Optimizer | apc, bcmath, bz2, calendar, curl, dba, dbase, dbx, dom, dtrace, eaccelerator, exif, fileinfo, ftp, gettext, gmp, http, imap, json, ldap, mhash, mssql, pcntl, pdf, pdo, pdo_dblib, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, posix, pspell, radius, shmop, snmp, soap, sockets, sqlite, suhosin, sysvsem, sysvshm, tidy, wddx, xmlrpc, xsl, zip, zlib |
| PHP4 | ctype, gd, iconv, mbstring, mcrypt, mysql, openssl, overload, pcre, session, standard, tokenizer, xml | apc, bcmath, bz2, calendar, curl, dba, dbase, dbx, eaccelerator, exif, filepro, ftp, gettext, gmp, ldap, mhash, mssql, pcntl, pdf, pgsql, posix, shmop, sockets, sysvsem, sysvshm, wddx, xmlrpc, zip, zlib |
Using Shared Memory on Shared Accelerators
What it boils down to, is that if you want to use advanced caching features for PHP (e.g. memcache, APC, eAccelerator etc.) that involve any kind of shared memory at all, you're looking for dedicated hosting (e.g. a standard Accelerator). All caching helpers were typically designed with mod_php in mind (which we don't provide on shared hosting for several good reasons), and while some of them claim to work fine with FastCGI (like eAccelerator), you only get part of the fun, and not the shared memory. Either you 'share' the server with others, or you get a dedicated Acceclerator and then can 'share' the memory between your processes and applications.
Enabling & Disabling Extensions
This is a simple overview of turning an extension on or off. For more on modifying your configuration, see PHP configuration.
- Sign in to Virtualmin (see Account logins and important URLs).
- From the left-hand navigation, click Webmin Modules to expand it, then click PHP Configuration.
- A list will load. There are 2 rows for each virtual server you have setup (one for PHP4 and one for PHP5).
- In the list, locate the row for the configuration file you wish to edit, and click Edit (under the Actions column on the right) for that row.
- In the text box that loads with the PHP configuration, scroll down to the area where there are a bunch of lines that start with “;extension=…”.
- The ; (semicolon) is a comment marker.
- To enable an extension, remove the ; from the beginning of the line (e.g. ”;extension=dom.so” becomes “extension=dom.so”).
- To disable an extension, add a ; to the beginning of the line.
- Click Save.
pkill php.
Custom PHP Extensions
mkdir ~/php cp -pr /usr/local/lib/php/20040412/* ~/php/
edit the php.ini for your website to use the /users/home/username/php/ as it's extension_dir so that it loads the extensions from ~/php/ rather than from /usr/local/lib/php/20040412/ that way you can install additional php extensions when you need to.
The location for the php.ini's are /users/home/username/etc/php5/php.ini for your main domain and then /users/home/username/domains/domainame/etc/php5/php.ini for your secondary domains.
IonCube
Download the latest version of the ioncube loaders from http://www.ioncube.com/loaders.php for Solaris (x86). At the time of writing this it was http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_sun_x86.tar.bz2 and extract the tarball moving the ioncube/ioncube_loader_sun_5.2_ts.so into your ~/php/ directory.
Add an extension=ioncube_loader_sun_5.2_ts.so to your websites php.ini and the ioncube loader should load and you can verify this by putting a page that outputs from the following php code:
<?php phpinfo(); ?>
