====== 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. **PHP Overview** If you're new to PHP, or want a general introduction to developing and deploying PHP scripts and applications, start off by reading the **[[all-accelerators:kb:php|PHP Overview]]** in the [[all-accelerators:kb:start|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.6 (cli) (built: Jun 16 2008 12:18:20) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.0, 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 | Some important extensions are completely missing in PHP4 ( //domxml//, //imap//, and //xslt//). We have not been able to build them successfully yet on our Solaris shared systems, but are working on that. The APC extension cannot be used with PHP5 on the shared accelerators (see http://pecl.php.net/bugs/bug.php?id=10157 for details). ==== 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 host and then can 'share' the memory amongst 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-config]]. - Sign in to Virtualmin (see [[Logins]]). - 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**. Changes made to your PHP configuration will not take effect until your local PHP process is restarted, which occurs after 2 minutes of inactivity. If you are impatient or receive heavy traffic to your site, you will want to manually restart PHP by logging into your account via SSH and executing ''pkill php''. Some PHP extensions depend on others that may also be disabled by default. If you prefer, you may also edit ~/etc/php5/php.ini or ~/etc/php4/php.ini within your account to achieve the same effect. (For your secondary virtual servers, that's ~/domains/**yourdomain.tld**/etc/php**x**/php.ini).