How to install PHP 7 GA on CentOs Server

One of blogger in my town came and ask me to help him with his server. Actually his server is enough to handle his wordpress blog but he don’t know what to do. I suggest him to upgrade his server or reinstall server to support latest PHP 7. I told him that newest PHP is twice fast as legacy PHP that he use. I promise to show him the steps and put it public. Maybe other blogger need and find it useful too.

Lets get start!

I use DigitalOcean VPS (1GB package) – You get free $10 if you’re new user.

Choose CentOS 6.7 64 bit with 1 GB memory.

Login to vps and install :

# curl -O https://centminmod.com/installer.sh && chmod 0700 installer.sh && bash installer.sh

Wait till you see # sign . Follow by type

# centmin

Choose 5

Next view is straight through, I bold my respond :

Custom configure CSF settings…set

Do you want to run YUM install checks ? [y/n]

This will increase your upgrade duration time wise.
Check the change log centminmod.com/changelog.html
to see if any Nginx or PHP related new additions
which require checking YUM prequisites are met.
If no new additions made, you can skip the
YUM install check to speed up upgrade time.

[y/n]: n

PHP Upgrade – Would you like to continue? [y/n] y
—————————————————————-
Install which version of PHP? (version i.e. 5.4.45, 7.0.0, NGDEBUG)
PHP 7.0.0 is GA Stable but still may have broken PHP extensions.
NGDEBUG is PHP 7.1.0 minus incompatible PHP extensions
—————————————————————-
Enter PHP Version number you want to upgrade/downgrade to: 7.0.0
—————————————————————-
Want to update to latest php-fpm.conf ? (overwrites will auto backup existing php-fpm.conf)
existing php.ini will be backed up at /usr/local/lib/php.ini-oldversion_161215-085056
existing php-fpm.conf will be backed up at /usr/local/etc/php-fpm.conf-oldversion_161215-085056
—————————————————————-
Update & overwrite your existing php-fpm.conf [y/n]: y
—————————————————————-

—————————————————————————————–
Detected PHP 7.0 branch.
You can compile Zend OPcache (Zend Optimizer Plus+) support
as an alternative to using APC Cache or Xcache cache.
But Zend OPcache only provides PHP opcode cache and
DOESN’T do data caching, so if you web apps such as WordPress,
Drupal or vBulletin require data caching to APC or Xcache,
it won’t work with Zend OPcache.

—————————————————————————————–
Do you want to use Zend OPcache [y/n] ? y

Follow everything in monitor till you see a bunch of error then success at the end.
Type 24.

Checking for PHP upgrade result.

# php -v

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/igbinary.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20151012/igbinary.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/memcache.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20151012/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mongo.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mongo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/redis.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20151012/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 7.0.0 (cli) (built: Dec 16 2015 09:11:07) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Yes, PHP 7 sucessfully replace PHP 5.

Time to clean up.

Basically the steps here is delete related .ini file.

# cd /etc/centminmod/php.d/

# ls
a_customphp.ini curlcainfo.ini igbinary.ini memcached.ini mongodb.ini zendopcache.ini
a_customphp.ini-bak_161215-085056 geoip.ini imagick.ini memcache.ini redis.ini

Yes, delete these .ini files (igbinary.ini, memcache.ini, mongodb.ini and redis.ini ).

# rm igbinary.ini memcache.ini mongodb.ini redis.ini
rm: remove regular file `igbinary.ini’? y
rm: remove regular file `memcache.ini’? y
rm: remove regular file `mongodb.ini’? y
rm: remove regular file `redis.ini’? y

#

# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done

#

Re test

# php -v
PHP 7.0.0 (cli) (built: Dec 16 2015 09:11:07) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Nice.

A few notes :

  1. Default location aka documentroot located in : /usr/local/nginx/html/
  2. Location of mysql username and password : /root/.my.cnf
  3. To add virtualhost / domain, type : centmin and choose no. 2.
  4. Use php upgrade anytime you want. I recently upgrade to latest version (7.0.24) without problem. Just redo previous steps.

One Comment

  1. Pingback: Testing PHP 7 on Centos 7

Comments are closed.