yum install wget autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap libXpm* gcc gcc-c++ bison git -y
#加强系统对支持字符编码转换的功能
cd /usr/local/src
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
tar zvxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
cd srclib
sed -i -e '/gets is a security/d' ./stdio.in.h
cd ..
make && make install
ln -sf /usr/local/lib/libiconv.so.2 /usr/lib64/
ldconfig
#加密算法库,PHP扩展mcrypt功能对此库有依赖关系
cd /usr/local/src
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar zvxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install
cd libltdl/
./configure --enable-ltdl-install
make && make install
ln -sf /usr/local/lib/libmcrypt.* /usr/lib64/
ln -sf /usr/local/bin/libmcrypt-config /usr/lib64/
ldconfig
#mcrypt的编译依赖mhash
cd /usr/local/src/
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar zvxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure && make && make install
ln -sf /usr/local/lib/libmhash.* /usr/lib64/
ldconfig
cd /usr/local/src/
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar zvxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure && make && make install
cd /usr/local/src/
wget http://sourceforge.net/projects/re2c/files/0.16/re2c-0.16.tar.gz
tar zvxf re2c-0.16.tar.gz
cd re2c-0.16
./configure && make && make install
ln -s /usr/lib64/libldap* /usr/lib
ln -s /usr/lib64/liblber* /usr/lib
ldconfig
cd /usr/local/src/ wget http://am1.php.net/distributions/php-7.0.13.tar.gz tar zvxf php-7.0.13.tar.gz cd php-7.0.13 ./configure \ --prefix=/usr/local/php7 \ --with-config-file-path=/usr/local/php7/etc \ --with-openssl \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-iconv-dir=/usr/local \ --with-libxml-dir=/usr \ --with-freetype-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib \ --with-curl \ --with-mhash \ --with-ldap \ --with-ldap-sasl \ --with-mcrypt \ --with-gd \ --with-xmlrpc \ --with-libdir=/lib/ \ --with-kerberos \ --with-pcre-regex \ --with-zlib-dir \ --with-bz2 \ --with-gettext \ --disable-rpath \ --enable-pdo \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --enable-zip \ --enable-soap \ --enable-opcache \ --enable-calendar \ --enable-ctype \ --enable-exif \ --enable-session \ --enable-ftp make ZEND_EXTRA_LIBS='-liconv' make install
cp php.ini-production /usr/local/php7/etc/php.ini
sysctl vm.nr_hugepages=512 cat /proc/meminfo | grep Huge
ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012 vim /usr/local/php7/etc/php.ini
在文件中搜索; extension_dir = “./” ,并在下面添加以下内容(如果extension_dir已存在,只添加后面的内容)
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" zend_extension="opcache.so" opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable=1 opcache.enable_cli=1 opcache.huge_code_pages=1 opcache.file_cache=/tmp
:wq 保存退出
vim /usr/local/php7/etc/php.ini
在文件中搜索; extension_dir = “./” ,并在下面添加以下内容(如果extension_dir已存在,只添加后面的一行)
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" extension = "pdo_mysql.so" extension = "mysqli.so"
:wq 保存退出
cd /usr/local/src/
wget http://xdebug.org/files/xdebug-2.4.0rc3.tgz
tar zvxf xdebug-2.4.0rc3.tgz
cd xdebug-2.4.0RC3
/usr/local/php7/bin/phpize
./configure --enable-xdebug --with-php-config=/usr/local/php7/bin/php-config
make && make install
修改php配置文件,支持xdebug
vim /usr/local/php7/etc/php.ini
在文件中搜索; extension_dir = “./” ,并在下面添加以下内容(如果extension_dir已存在,只添加后面的一行)
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" [xdebug] zend_extension = "xdebug.so" xdebug.remote_enable=1 xdebug.remote_connect_back=on xdebug.remote_port=8080 xdebug.idekey=PHPSTORM xdebug.remote_autostart=1
:wq 保存退出
cd /usr/local/src wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar zvxf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.18 ./configure --with-memcached --prefix=/opt/libmemcached make && make install cd /usr/local/src yum install git git clone https://github.com/rlerdorf/php-memcached.git cd php-memcached git checkout php7 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config --with-libmemcached-dir=/opt/libmemcached make && make install ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
修改php配置文件,支持memcached
vim /usr/local/php7/etc/php.ini
在文件中搜索; extension_dir = “./” ,并在下面添加以下内容(如果extension_dir已存在,只添加后面的一行)
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" extension = "memcached.so"
cd /usr/local/src yum install git git clone https://github.com/phpredis/phpredis/ cd phpredis git checkout php7 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config make && make install ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
修改php配置文件,支持redis
vim /usr/local/php7/etc/php.ini在文件中搜索; extension_dir = “./” ,并在下面添加以下内容(如果extension_dir已存在,只添加后面的一行)
extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" extension = "redis.so"
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/web.conf vim /usr/local/php7/etc/php-fpm.conf
修改内容,并且让其它生效
[global] pid = run/php-fpm.pid error_log = log/php-fpm.log emergency_restart_threshold = 10 emergency_restart_interval = 1m process_control_timeout = 5s
:wq 保存退出
vim /usr/local/php7/etc/php-fpm.d/web.conf
修改内容,并且让其它生效.[user和group根据实际情况修改]
user = nobody group = nobody pm.max_children = 35 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35
:wq 保存退出
cd /usr/local/src/php-7.0.13 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on
systemctl start php-fpm
参考资料:
[1].http://www.cnblogs.com/vicowong/p/5024792.html
[2].http://www.phpddt.com/php/php-fpm-reload.html