Install PHP7 under Linux
Upgrade gcc4.8 in advance , and then install PHP7, the installation steps refer to: CentOS install PHP7
1. The php compiled under Linux does not have php.ini
Workaround: Copy php.ini-development or php.ini-production from the source code directory to the php.ini directory
2. Install the zlib extension
cd /usr/local/src/php-7.0.10/ext/zlib
cp config0.m4 config.m4
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config --with-zlib=/usr
make & make install & make clean
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
extension=zlib.so //Add this line to restart the PHP service
Reference: phpize compile and install PHP zlib library extension module
3. Install the gd extension
sudo yum install php-gd2 png jpeg freetype //YUM install extension
cd /usr/local/src/php-7.0.10/ext/gd //The php-7.0.10/ folder here is what I got by decompressing the PHP installation package.
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config --with-png-dir --with-freetype-dir --with-jpeg-dir --with-gd
sudo make
make install
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
extension=gd.so //Add this line to restart the PHP service
Reference: Install PHP GD extension with PHPIZE under LINUX
4. Install the mysqli extension
cd /usr/local/src/php-7.0.10/ext/mysqli// The php-7.0.10/ folder here is what I got by decompressing the PHP installation package.
cp /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config --with-mysql-config=/usr/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-pdo=shared
sudo make
make install
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
extension=mysqli.so //Add this line to restart the PHP service
Reference: PHP independent compilation and installation of extensions (mysqli, pdo-mysql)
5. Install the pdo_mysql extension
cd /usr/local/src/php-7.0.10/ext/pdo_mysql //The php-7.0.10/ folder here is what I got by decompressing the PHP installation package.
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config --with-mysql-config=/usr/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-pdo=shared
sudo make
make install
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
extension=pdo_mysql.so //Add this line to restart the PHP service
Reference: PHP independent compilation and installation of extensions (mysqli, pdo-mysql)
6. Install the opcache extension
cd /usr/local/src/php-7.0.10/ext/opcache
/usr/local/php-7.0.10/bin/phpize
cp config0.m4 config.m4
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config
make & make install & make clean
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
//Add the following lines to restart the PHP service
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1"
opcache.file_cache=/tmp
opcache.validate_timestamps=1 //Configuration is 0 in the production environment
opcache.revalidate_freq=0 //Check whether the script timestamp is updated
opcache.memory_consumption=64 //The shared memory size of Opcache, in M
opcache.interned_strings_buffer=16 //The size of the memory used to store temporary strings, in M
opcache.max_accelerated_files=4000 //Opcache hash table can The upper limit of the number of stored script files
opcache.fast_shutdown=1 //Use fast stop to resume events
Reference: PHP5.5 Zend Opcache Installation and Configuration Tutorial
7. Install the redis extension
Redis extension: http://pecl.php.net/package/redis
wget http://pecl.php.net/get/redis-3.0.0.tgz
tar -xzvf redis-3.0.0.tgz
cd redis-3.0.0
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config
make & make install
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file e
xtension=redis.so //Add this line to restart the PHP service
Reference: Redis installation and PHP extension under Linux (for PHP7)
8. In the middle, zlib.so is obviously compiled and configured, but it is not loaded
Solution: By viewing the php-fpm log as follows, it is found that it is a compilation problem. Make clean in the root directory of the php source code and recompile zlib, and you are done.
NOTICE: PHP message: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) /usr/local/php-7.0.10/lib/php/extensions/no-debug-non-zts-20151012/zlib.so'
in
Unknown on line 0
9. Install the mbstring extension
cd /usr/local/src/php-7.0.10/ext/mbstring //The php-7.0.10/ folder here is what I got by decompressing the PHP installation package.
/usr/local/php-7.0.10/bin/phpize
./configure --with-php-config=/usr/local/php-7.0.10/bin/php-config
sudo make
make install
sudo vi /usr/local/php-7.0.10/etc/php.ini //Modify PHP configuration file
extension=mbstring.so //Add this line to restart the PHP service
10. Install the openssl extension in a similar way