====== Installing PHP as an RPM for CentOS systems====== For LSWS (native) and OpenLiteSpeed, Installing PHP with LiteSpeed SAPI from a repository is much faster than compiling it yourself. Some users also may be unused to compiling PHP and will find this method more comfortable. PHP for LiteSpeed (LSAPI) is available in two repositories — Remi Repository and our own LiteSpeed Repository. Choose the repository that best fits your needs. ===== LiteSpeed Repository ===== * PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 and 7.3 * CentOS and RHEL 5/6/7. * Contains most up-to-date versions of LSAPI. (Do not have to wait for a new PHP version to be released.) * Easily install multiple versions of PHP (by default installed to different locations). * Contains all frequently used PHP packages. * Contains multiple possible MySQL support packages (via native driver or client library). * Contains multiple opcode caching options: APC, Xcache, Zend Opcache. ===== Les RPM de Remi (Remi Repository) ===== * PHP 5.4, 5.5, 5.6, 7.0, and 7.1 * CentOS and RHEL 5/6/7 and Fedora 17-26. * Allows installation of multiple builds of PHP through SCL. * Contains packages for many rare use cases as well as more common use cases. ====== Installing PHP from the LiteSpeed Repository ====== The easiest way to get up and running with PHP is to use the LiteSpeed Repository. The LiteSpeed Repository comes with prebuilt PHP packages with LiteSpeed support already built in. ===== Add EPEL Repository ===== PHP requires certain packages not available in the default CentOS repos. Because of this, it is required to install the Extra Packages for Enterprise Linux (EPEL) to account for the missing packages. This can be done by running the following command via a command line: yum install epel-release ===== Add LiteSpeed Repository ===== We currently maintain repositories for CentOS 5, 6, and 7. You can add our repository with the following commands: CentOS 5: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el5.noarch.rpm CentOS 6: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm CentOS 7: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm Note: On CentOS 5, you may need to install the package python-hashlib to avoid the error : "[Errno -3] Error performing checksum" when using the repo ===== Install a PHP Build ===== Once you've added our repository, you can use yum to install PHP for LiteSpeed with a variety of modules. The following command will install LSPHP 5.5: yum install lsphp55 Listing multiple packages will install PHP with multiple modules. ==== Full list of available packages ==== [[litespeed_wiki:php:rpm:packages|Full list of all available packages]] ==== Useful PHP Install Commands ==== Install PHP 5.6 ( 5.4, 5.5, 7.0, 7.1, 7.2 or 7.3, please check with the corresponding application for PHP version and packages requirement) with packages to support most commonly used web applications (WordPress, Joomla, Drupal, Magento, SugarCRM, etc.): yum install lsphp56 lsphp56-common lsphp56-mysqlnd lsphp56-gd lsphp56-process lsphp56-mbstring lsphp56-xml lsphp56-mcrypt lsphp56-pdo lsphp56-imap lsphp56-soap lsphp56-bcmath lsphp56-intl lsphp56-opcache or yum install lsphp70 lsphp70-common lsphp70-mysqlnd lsphp70-gd lsphp70-process lsphp70-mbstring lsphp70-xml lsphp70-mcrypt lsphp70-pdo lsphp70-imap lsphp70-soap lsphp70-bcmath lsphp70-intl lsphp70-json lsphp70-opcache **Note:** opcache may sometimes cause a problem and you can remove it/disable it when it happens. ==== Installing Multiple PHP Versions ==== The LiteSpeed Repository automatically installs PHP to ''/usr/local/lsws/lsphp5x/bin/lsphp'' where ''5x'' is the version and subversion. Thus PHP 5.6 would be installed to ''/usr/local/lsws/lsphp56/bin/lsphp''. This allows you to easily install multiple versions of PHP because different versions of PHP are installed to different directories. If you want to install all lsphp52/53/54/55/56, do a group installation. yum groupinstall lsphp-all It can be updated by: yum groupupdate lsphp-all ==== Direct LSWS to the Location of the Installed PHP ==== As noted above, the LiteSpeed Repository installs PHP to ''/usr/local/lsws/lsphp5x/bin/lsphp''. This is not the place LSWS normally looks for PHP, so we will now need to direct LSWS to look there. Go to the WebAdmin console > External App > your external application > Command. Change the Command setting to match the location PHP was installed to (for example, ''/usr/local/lsws/lsphp56/bin/lsphp'' for PHP 5.6). {{litespeed_wiki:php:php_lsrepo_extapp.png?700}} {{litespeed_wiki:php:php_lsrepo_command.png?700}} Default php external app settings are: Name: lsphp5 (Note:It should be unique to other external apps) Address: uds://tmp/lshttpd/lsphp5.sock (Note:socket name can be anything but unique to other external apps, usually the same as external apps name) Note: Not Set Max Connections: 35 Environment: PHP_LSAPI_MAX_REQUESTS=5000 PHP_LSAPI_CHILDREN=35 Initial Request Timeout (secs):60 Retry Timeout (secs): 0 Persistent Connection: Yes Connection Keepalive Timeout: Not Set Response Buffering: No Start By Server: Yes Command: /usr/local/lsws/lsphp56/bin/lsphp ( Note: it should change to the binary you need to point to) Back Log: 100 Instances: 1 Run As User: Not Set Run As Group: Not Set umask: Not Set Run On Start Up: Not Set Max Idle Time: 10 Priority: 0 Memory Soft Limit (bytes): 2048M Memory Hard Limit (bytes): 2048M Process Soft Limit: 400 Process Hard Limit: 500 Leave as default from beginning and you can adjust it later according to your needs. You can refer above setting when you create new php external apps. Click Save and then perform a Graceful Restart for the changes to take effect. {{litespeed_wiki:php:php_lsrepo_restart.png?700}} If you prefer using the command line instead of the GUI tool, you can edit the LSWS configuration file (usually /usr/local/lsws/conf/httpd_config.xml) by adding the following to the section, assuming to create a lsphp56 which not exist yet, others like lsphp52/lsphp53/lsphp54/lsphp55 can be created the same way with minor change accordingly. lsapi lsphp56
uds://tmp/lshttpd/lsphp56.sock
35 PHP_LSAPI_MAX_REQUESTS=5000 PHP_LSAPI_CHILDREN=35 60 0 0 1 /usr/local/lsws/lsphp56/bin/lsphp 100 1 2048M 2048M 400 500
==== Set proper php handler ==== Ensure php handler set to be associated to the newly created/updated external app. Please refer to this [[litespeed_wiki:php:configuring-lsws-for-php#the_script_or_context_handler|wiki]]. ==== Check your PHP installation ==== You can check that your PHP installation is correct by viewing a phpinfo() page. The phpinfo() page should show the correct version of PHP and LiteSpeed as the server API. {{litespeed_wiki:php:php_lsrepo_phpinfo.png?700}} ====== Installing PHP from Remi Repo ====== The following steps can be used to install PHP 5.6 with LSAPI. ==== Add the repositories ==== CentOS5: rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-5.rpm CentOS6: rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-6.rpm CentOS7: rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm Remi Repository requires the EPEL repository as well. yum install epel-release ==== Enable Remi Repo ==== Open the Remi repo file: vi /etc/yum.repos.d/remi.repo In the ''[remi-php56]'' section, set ''enabled'' to ''1''. **Note:** The ''[remi-php55]'' section is for PHP 5.5. The ''[remi-php56]'' section is for PHP 5.6. ==== Install PHP for LSWS from the repository ==== Remi's PHP for LSWS (PHP with LSAPI) package is called "php-litespeed". yum install php-litespeed For PHP 5.6: yum install php php-common php-mysql php-gd php-process php-mbstring php-xml php-mcrypt php-pdo php-imap php-soap php-bcmath php-opcache php-litespeed For PHP 7.0/7.1: yum install php php-common php-mysqlnd php-gd php-process php-mbstring php-xml php-mcrypt php-pdo php-imap php-soap php-bcmath php-intl php-json php-iconv php-opcache php-litespeed **Note:** You can, of course, also install any other packages you wish. Php-opcache may sometimes cause a problem and you can remove it/disable it when it happens. ==== Direct LSWS to the Location of the Installed PHP ==== By default, Remi Repo installs PHP with LSAPI to ''/usr/bin/lsphp''. This is not the place LSWS normally looks for PHP, so we will now need to direct LSWS to look there. Go to the WebAdmin console > External App > your external application > Command. Change the Command setting to match the location PHP was installed to (''/usr/bin/lsphp''). {{litespeed_wiki:php:php_remi_extapp.png?700}} {{litespeed_wiki:php:php_remi_command.png?700}} Click Save and then perform a Graceful Restart for the changes to take effect. {{litespeed_wiki:php:php_remi_restart.png?700}} Ensure php handler set to be associated to the newly created/updated external app. Please refer to this wiki. ==== Check your PHP installation ==== You can check that your PHP installation is correct by viewing a phpinfo() page. The phpinfo() page should show the correct version of PHP and LiteSpeed as the server API. {{litespeed_wiki:php:php_remi_phpinfo.png?700}}