Install Remi repository
## Remi Dependency on CentOS 7 and Red Hat (RHEL) 7 ## rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm ## CentOS 7 and Red Hat (RHEL) 7 ## rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm ## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ## rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm ## CentOS 6 and Red Hat (RHEL) 6 ## rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm ## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ## rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm ## CentOS 5 and Red Hat (RHEL) 5 ## rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Install Apache (httpd) Web server and PHP 5.6.13
yum --enablerepo=remi,remi-php56 install httpd php php-common
Install PHP 5.6.13 modules
yum --enablerepo=remi,remi-php56 install php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
Update (for nginx)
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm |
Now you can install PHP 5.6’s mod_php SAPI (along with an opcode cache) by doing:
yum install php56w php56w-opcache |
You can alternatively install PHP 5.6’s php-fpm SAPI (along with an opcode cache by doing:
yum install php56w-fpm php56w-opcache |
See the package list below for additional SAPIs and PHP extensions.
If you would like to upgrade php to this version it is recommended that you first check that your system will support the upgrade, e.g. making sure any CPanel-like software can run after the upgrade.
Unless you know what you are doing, it is risky upgrading an existing system. It’s much safer to do this by provisioning a separate server to perform the upgrade as a fresh install instead.
If you know what you are doing, you can upgrade PHP by:
yum install yum-plugin-replace yum replace php-common --replace-with=php56w-common |
It will likely give you a message “WARNING: Unable to resolve all providers …”. This is normal, and you can continue by tying “y“. You will be given a chance to see what packages will be installed and removed before again being given a chance to confirm.
SAPIs – different runtime environments of PHP
- mod_php NTS
- (non-thread safety) Contained in the php56w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd prefork mpm (the default mode httpd is ran under. It is not thread-safe, but doesn’t need to be due to prefork not using threads. It’s located at /usr/lib[64]/httpd/modules/libphp5.so
- cli
- Contained in the php56w-cli package, this SAPI allows running scripts from the command-line, and also has a built-in web server for development-use. Located at /usr/bin/php
- fpm
- Contained in the php56w-fpm package, fpm (FastCGI Process Manager) is a scalable FastCGI process, which acts similar to how Httpd prefork mpm works managing it’s forks. Located at /usr/sbin/php-fpm, it is controlled using the /etc/init.d/php-fpm service script
- phpdbg
- Contained in the php56w-phpdbg package, phpdbg has the ability to debug scripts using breakpoints from the command-line, and also supports remote-debugging using an external Java client for remote communication.
- embedded
- Contained in the php56w-embedded package, this SAPI allows embedding PHP in other applications. It’s library is located at /usr/lib[64]/libphp5.so
- cgi, fastcgi
- Contained in the php56w-cli package, these SAPIs are not recommended for use, but are available where needed. They both exist in the binary at /usr/bin/php-cgi.
- mod_php TS
- (thread safety) Contained in the php56w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd worker mpm. It’s supposed to be thread-safe, but can’t guarantee to be, and certainly not under additional PHP extensions. It’s better to use FastCGI SAPIs than this one. It’s located at /usr/lib[64]/httpd/modules/libphp5-zts.so
Packages
Package | Provides |
---|---|
php56w | mod_php, php56w-zts |
php56w-bcmath | |
php56w-cli | php-cgi, php-pcntl, php-readline |
php56w-common | php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-ereg, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib |
php56w-dba | |
php56w-devel | |
php56w-embedded | php-embedded-devel |
php56w-enchant | |
php56w-fpm | |
php56w-gd | |
php56w-imap | |
php56w-interbase | php_database, php-firebird |
php56w-intl | |
php56w-ldap | |
php56w-mbstring | |
php56w-mcrypt | |
php56w-mssql | |
php56w-mysql | php-mysqli, php_database |
php56w-mysqlnd | php-mysqli, php_database |
php56w-odbc | php-pdo_odbc, php_database |
php56w-opcache | php56w-pecl-zendopcache |
php56w-pdo | |
php56w-pear | |
php56w-pecl-apcu | |
php56w-pecl-gearman | |
php56w-pecl-geoip | |
php56w-pecl-imagick | |
php56w-pecl-memcache | |
php56w-pecl-xdebug | |
php56w-pgsql | php-pdo_pgsql, php_database |
php56w-phpdbg | |
php56w-process | php-posix, php-sysvmsg, php-sysvsem, php-sysvshm |
php56w-pspell | |
php56w-recode | |
php56w-snmp | |
php56w-soap | |
php56w-tidy | |
php56w-xml | php-dom, php-domxml, php-wddx, php-xsl |
php56w-xmlrpc |
Opcode Caches
The PHP distribution now comes with an opcode cache. This is the Zend Optimizer+ opcode cache, now known as the Zend OPcache extension. This extension is optional, so does not preclude you from using an alternate one.
Due to it being included in the PHP source distribution, it will be well maintained and more suitable for use while other Opcode cache’s are being updated over the coming months.
yum install php56w-opcache |
error_reporting E_ALL now includes E_STRICT
As mentioned in the PHP 5.4 guide:
You may get a lot more errors coming out of your error logs if by default your error_reporting is set to E_ALL now without explicitly turning off E_STRICT. The default php.ini that comes with the PHP package turns this off by default, but if you are upgrading from an existing installation, your php.ini may not be updated, meaning this will likely be turned on.
Más información en