CentOS 6.8 の PHP のバージョンを 7 に上げる

このページは約 35分51秒で読めます。

VPSのPHPのバージョンを5.4からPHP7.0へアップした作業メモ。WordPress も高速化されるというのでいつまでも古いバージョン使っていても仕方ないですね。

ざっくりと。

インストールされているパッケージを確認

$ yum list installed | grep php
php.x86_64 5.4.24-1.el6.remi @remi
php-cli.x86_64 5.4.24-1.el6.remi @remi
php-common.x86_64 5.4.24-1.el6.remi @remi
php-devel.x86_64 5.4.24-1.el6.remi @remi
php-gd.x86_64 5.4.24-1.el6.remi @remi
php-mbstring.x86_64 5.4.24-1.el6.remi @remi
php-mcrypt.x86_64 5.4.24-1.el6.remi @remi
php-mysql.x86_64 5.4.24-1.el6.remi @remi
php-pdo.x86_64 5.4.24-1.el6.remi @remi
php-pear.noarch 1:1.9.4-23.el6.remi @remi
php-pecl-igbinary.x86_64 1.1.2-0.1.git3b8ab7e.el6.remi @remi
php-pecl-imagick.x86_64 3.1.2-2.el6.remi.5.4 @remi
php-pecl-memcached.x86_64 2.1.0-7.el6.remi.5.4 @remi
php-process.x86_64 5.4.24-1.el6.remi @remi
php-snmp.x86_64 5.4.24-1.el6.remi @remi
php-xml.x86_64 5.4.24-1.el6.remi @remi

remiから入れていたので、レポジトリの内容だけ更新。

$ wget wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ sudo rpm -ivh ./remi-release-6.rpm
$ ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Base.repo.rpmnew CentOS-Media.repo CentOS-fasttrack.repo epel.repo remi-php71.repo remi.repo
CentOS-Base.repo.orig CentOS-Debuginfo.repo CentOS-Vault.repo epel-testing.repo remi-php70.repo remi-safe.repo

旧パッケージを削除。

$ sudo yum -y remove php php-cli php-common php-devel php-gd php-mbstring php-mcrypt php-mysql php-pdo php-pear.noarch php-pecl-igbinary php-pecl-imagick php-pecl-memcached php-process php-snmp php-xml

PHP7 をインストール。サイトによってはパッケージ名が実際と異なっていたこともあったので、 yum search してパッケージ名確認してから入れた方がいいみたいです。

$ yum –enablerepo=remi-php70 search php70
読み込んだプラグイン:fastestmirror, security
Loading mirror speeds from cached hostfile
* remi-php70: mirror.smartmedia.net.id
* remi-safe: mirror.smartmedia.net.id
=============================================================== N/S Matched: php70 ================================================================php70-php-pecl-propro-devel.x86_64 : php70-php-pecl-propro developer files (header)
php70-php-pecl-raphf-devel.x86_64 : php70-php-pecl-raphf developer files (header)
php70-php-pecl-xmldiff-devel.x86_64 : php70-php-pecl-xmldiff developer files (header)
php70-php-pecl-yaconf-devel.x86_64 : php70-php-pecl-yaconf developer files (header)
php70-php-yaconf-devel.x86_64 : php70-php-yaconf developer files (header)
php70-runtime.x86_64 : Package that handles php70 Software Collection.
php70-scldevel.x86_64 : Package shipping development files for php70
php70.x86_64 : Package that installs PHP 7.0
php70-build.x86_64 : Package shipping basic build configuration
php70-php.x86_64 : PHP scripting language for creating dynamic web sites
php70-php-ast.x86_64 : Abstract Syntax Tree
php70-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php70-php-cli.x86_64 : Command-line interface for PHP
php70-php-common.x86_64 : Common files for PHP
php70-php-dba.x86_64 : A database abstraction layer module for PHP applications
php70-php-dbg.x86_64 : The interactive PHP debugger
php70-php-devel.x86_64 : Files needed for building PHP extensions
php70-php-embedded.x86_64 : PHP library for embedding in applications
php70-php-enchant.x86_64 : Enchant spelling extension for PHP applications
php70-php-fpm.x86_64 : PHP FastCGI Process Manager
php70-php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php70-php-gmp.x86_64 : A module for PHP applications for using the GNU MP library
php70-php-horde-horde-lz4.x86_64 : Horde LZ4 Compression Extension
php70-php-imap.x86_64 : A module for PHP applications that use IMAP
php70-php-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases
php70-php-intl.x86_64 : Internationalization extension for PHP applications
php70-php-ioncube-loader.x86_64 : Loader for ionCube Encoded Files with ionCube 24 support
php70-php-json.x86_64 : JavaScript Object Notation extension for PHP
php70-php-ldap.x86_64 : A module for PHP applications that use LDAP
php70-php-litespeed.x86_64 : LiteSpeed Web Server PHP support
php70-php-lz4.x86_64 : LZ4 Extension for PHP
php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php70-php-mcrypt.x86_64 : Standard PHP module provides mcrypt library support
php70-php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php70-php-oci8.x86_64 : A module for PHP applications that use OCI8 databases
php70-php-odbc.x86_64 : A module for PHP applications that use ODBC databases
php70-php-opcache.x86_64 : The Zend OPcache
php70-php-pdo.x86_64 : A database access abstraction module for PHP applications
php70-php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php70-php-pear.noarch : PHP Extension and Application Repository framework
php70-php-pecl-amqp.x86_64 : Communicate with any AMQP compliant server
php70-php-pecl-apcu.x86_64 : APC User Cache
php70-php-pecl-apcu-bc.x86_64 : APCu Backwards Compatibility Module
php70-php-pecl-apcu-devel.x86_64 : APCu developer files (header)
php70-php-pecl-apfd.x86_64 : Always Populate Form Data
php70-php-pecl-apm.x86_64 : Alternative PHP Monitor
php70-php-pecl-bitset.x86_64 : BITSET library
php70-php-pecl-cassandra.x86_64 : DataStax PHP Driver for Apache Cassandra
php70-php-pecl-couchbase2.x86_64 : Couchbase Server PHP extension
php70-php-pecl-crypto.x86_64 : Wrapper for OpenSSL Crypto Library
php70-php-pecl-dbase.x86_64 : dBase database file access functions
php70-php-pecl-dio.x86_64 : Direct I/O functions
php70-php-pecl-druid.x86_64 : A Druid driver for PHP
php70-php-pecl-ds.x86_64 : Data Structures for PHP
php70-php-pecl-eio.x86_64 : Provides interface to the libeio library
php70-php-pecl-env.x86_64 : Load environment variables
php70-php-pecl-ev.x86_64 : Provides interface to libev library
php70-php-pecl-event.x86_64 : Provides interface to libevent library
php70-php-pecl-fann.x86_64 : Wrapper for FANN Library
php70-php-pecl-gearman.x86_64 : PHP wrapper to libgearman
php70-php-pecl-gender.x86_64 : Gender Extension
php70-php-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php70-php-pecl-geospatial.x86_64 : PHP Extension to handle common geospatial functions
php70-php-pecl-gmagick.x86_64 : Provides a wrapper to the GraphicsMagick library
php70-php-pecl-gnupg.x86_64 : Wrapper around the gpgme library
php70-php-pecl-hprose.x86_64 : Hprose for PHP
php70-php-pecl-hrtime.x86_64 : High resolution timing
php70-php-pecl-http.x86_64 : Extended HTTP support
php70-php-pecl-http-devel.x86_64 : Extended HTTP support developer files (header)
php70-php-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer
php70-php-pecl-igbinary-devel.x86_64 : Igbinary developer files (header)
php70-php-pecl-imagick.x86_64 : Extension to create and modify images using ImageMagick
php70-php-pecl-imagick-devel.x86_64 : imagick extension developer files (header)
php70-php-pecl-inotify.x86_64 : Inotify
php70-php-pecl-json-post.x86_64 : JSON POST handler
php70-php-pecl-krb5.x86_64 : Kerberos authentification extension
php70-php-pecl-krb5-devel.x86_64 : Kerberos extension developer files (header)
php70-php-pecl-libsodium.x86_64 : Wrapper for the Sodium cryptographic library
php70-php-pecl-lua.x86_64 : Embedded lua interpreter
php70-php-pecl-lzf.x86_64 : Extension to handle LZF de/compression
php70-php-pecl-mailparse.x86_64 : PHP PECL package for parsing and working with email messages
php70-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php70-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php70-php-pecl-memprof.x86_64 : Memory usage profiler
php70-php-pecl-mogilefs.x86_64 : PHP client library to communicate with the MogileFS storage
php70-php-pecl-mongodb.x86_64 : MongoDB driver for PHP
php70-php-pecl-msgpack.x86_64 : API for communicating with MessagePack serialization
php70-php-pecl-msgpack-devel.x86_64 : MessagePack developer files (header)
php70-php-pecl-mysql.x86_64 : MySQL database access functions
php70-php-pecl-oauth.x86_64 : PHP OAuth consumer extension
php70-php-pecl-pcs.x86_64 : PHP Code Service
php70-php-pecl-pcs-devel.x86_64 : PHP Code Service (header)
php70-php-pecl-pdflib.x86_64 : Package for generating PDF files
php70-php-pecl-propro.x86_64 : Property proxy
php70-php-pecl-radius.x86_64 : Radius client library
php70-php-pecl-raphf.x86_64 : Resource and persistent handles factory
php70-php-pecl-rdkafka.x86_64 : Kafka client based on librdkafka
php70-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
php70-php-pecl-ref.x86_64 : Soft and Weak references support in PHP
php70-php-pecl-request.x86_64 : Server-side request and response objects
php70-php-pecl-rrd.x86_64 : PHP Bindings for rrdtool
php70-php-pecl-scrypt.x86_64 : Scrypt hashing function
php70-php-pecl-seaslog.x86_64 : A effective,fast,stable log extension for PHP
php70-php-pecl-selinux.x86_64 : SELinux binding for PHP scripting language
php70-php-pecl-solr2.x86_64 : API orientée objet pour Apache Solr
php70-php-pecl-ssdeep.x86_64 : Wrapper for libfuzzy library
php70-php-pecl-ssh2.x86_64 : Bindings for the libssh2 library
php70-php-pecl-stats.x86_64 : Routines for statistical computation
php70-php-pecl-stomp.x86_64 : Stomp client extension
php70-php-pecl-swoole.x86_64 : PHP’s asynchronous concurrent distributed networking framework
php70-php-pecl-swoole-serialize.x86_64 : Fast and Small serialize
php70-php-pecl-sync.x86_64 : Named and unnamed synchronization objects
php70-php-pecl-taint.x86_64 : XSS code sniffer
php70-php-pecl-tcpwrap.x86_64 : Tcpwrappers binding
php70-php-pecl-termbox.x86_64 : A termbox wrapper for PHP
php70-php-pecl-trace.x86_64 : Trace is a low-overhead tracing tool for PHP
php70-php-pecl-trader.x86_64 : Technical Analysis for traders
php70-php-pecl-uopz.x86_64 : User Operations for Zend
php70-php-pecl-uploadprogress.x86_64 : An extension to track progress of a file upload
php70-php-pecl-uuid.x86_64 : Universally Unique Identifier extension for PHP
php70-php-pecl-vld.x86_64 : Dump the internal representation of PHP scripts
php70-php-pecl-weakref.x86_64 : Implementation of weak references
php70-php-pecl-xattr.x86_64 : Extended attributes
php70-php-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts
php70-php-pecl-xdiff.x86_64 : File differences/patches
php70-php-pecl-xmldiff.x86_64 : XML diff and merge
php70-php-pecl-xxtea.x86_64 : XXTEA encryption algorithm extension for PHP
php70-php-pecl-yac.x86_64 : Lockless user data cache
php70-php-pecl-yaconf.x86_64 : Yet Another Configurations Container
php70-php-pecl-yaf.x86_64 : Yet Another Framework
php70-php-pecl-yaml.x86_64 : PHP Bindings for yaml
php70-php-pecl-yar.x86_64 : Light, concurrent RPC framework
php70-php-pecl-yaz.x86_64 : Z39.50/SRU client
php70-php-pecl-zip.x86_64 : Une extension de gestion des ZIP
php70-php-pecl-zmq.x86_64 : ZeroMQ messaging
php70-php-pgsql.x86_64 : A PostgreSQL database module for PHP
php70-php-phalcon3.x86_64 : Phalcon Framework
php70-php-phpiredis.x86_64 : Client extension for Redis
php70-php-pinba.x86_64 : Client extension for Pinba statistics server
php70-php-process.x86_64 : Modules for PHP script using system process interfaces
php70-php-pspell.x86_64 : A module for PHP applications for using pspell interfaces
php70-php-recode.x86_64 : A module for PHP applications for using the recode library
php70-php-smbclient.x86_64 : PHP wrapper for libsmbclient
php70-php-snappy.x86_64 : Snappy Extension for PHP
php70-php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php70-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php70-php-suhosin.x86_64 : Suhosin is an advanced protection system for PHP installations
php70-php-tarantool.x86_64 : PHP driver for Tarantool/Box
php70-php-tidy.x86_64 : Standard PHP module provides tidy library support
php70-php-xml.x86_64 : A module for PHP applications which use XML
php70-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php70-php-yaconf.x86_64 : Yet Another Configurations Container
php70-zephir.noarch : Zephir language for creation of extensions for PHP.
php70-zephir-parser.x86_64 : Zephir parser extension

$ sudo yum –enablerepo=remi-php70 install php70 php70-php php70-php-cli php70-php-common php70-php-devel php70-php-gd php70-php-mbstring php70-php-mcrypt php70-php-mysql php70-php-pdo php70-php-pear.noarch php70-php-process php70-php-snmp php70-php-xml

インストール直後だとPHP7のバイナリへパスが通っていないので、 /opt/remi/php70/enable の記述に従いパスを追加します。

$ cat /opt/remi/php70/enable
export PATH=/opt/remi/php70/root/usr/bin:/opt/remi/php70/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php70/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php70/root/usr/share/man:${MANPATH}
$ sudo source /opt/remi/php70/enable

php.ini の場所は /etc/opt/remi/php70/php.ini にあるので、タイムゾーンの設定や日本語関係の mbstring の設定を変更しておきます。

Apacheを再起動して、サイトが正しく表示されれば更新完了。

……なのですが、旧バージョンからの非互換で動きませんでした。

PHP Parse error: syntax error, unexpected ‘new’ というエラーを吐く

検索して、php7でpear/http_requestが動かなくなった – パンクはいつも突然に を参考に & newnew に修正。

PHP Fatal error: Uncaught Error: Call to undefined function split() というエラーを吐く

先取り!PHP 7 と WordPress を参考にsplitexplode に修正。

とうに非推奨になっていた split が残っているコードって……。

まぁ、他にも色々エラーメッセージは出ているんですがひとまず警告レベルで致命傷にはなっていないのでいいかなと(良くない)

以上、こんな感じで。

スポンサーリンク

Trackback URL

No Trackback to CentOS 6.8 の PHP のバージョンを 7 に上げる

Still quiet here.

Comments are closed.