yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm
yum -y install php71-php.x86_64 php71-php-cli.x86_64 php71-php-common.x86_64 php71-php-devel.x86_64 php71-php-fpm.x86_64 php71-php-gd.x86_64 php71-php-ldap.x86_64 php71-php-mbstring.x86_64 php71-php-mcrypt.x86_64 php71-php-mysqlnd.x86_64 php71-php-opcache.x86_64 php71-php-pdo.x86_64 php71-php-pear.noarch php71-php-pecl-igbinary.x86_64 php71-php-pecl-jsond.x86_64 php71-php-pecl-memcache.x86_64 php71-php-pecl-zip.x86_64 php71-php-soap.x86_64 php71-php-pecl-redis.x86_64 php71-php-mysqlnd.x86_64 php71-php-pecl-imagick.x86_64 php71-php-pecl-rdkafka.x86_64 php71-php-pecl-mongodb.x86_64 php71-php-pecl-rdkafka.x86_64 php71-php-pecl-memcached.x86_64 php71-php-pgsql.x86_64
2.修改php71的php.ini文件中的以下字段
文件位置查找:php71 -i | grep /php.ini | awk '{ print $5;}'
disable_functions = system,exec,shell_exec,passthru,proc_open,proc_close, proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport, syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept, socket_connect, stream_socket_server, stream_socket_accept,stream_socket_client,ftp_connect, ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space, disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname,phpinfo,curl_multi_exec,parse_ini_file,passthru
expose_php = Off
max_execution_time = 300
max_input_time = 300
post_max_size = 10M
upload_max_filesize = 10M
max_file_uploads = 1
date.timezone = Asia/Shanghai
[mail function]
SMTP = localhost
smtp_port = 25
session.sid_length = 32
session.trans_sid_tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[mail function]
SMTP = localhost
smtp_port = 25
3. 调优php71 realpath_cacahe
文件位置查找:php71 -i | grep /php.ini | awk '{ print $5;}'
sed -i 's/;realpath_cache_size = 16k/realpath_cache_size = 64k/g' /etc/opt/remi/php71/php.ini
sed -i 's/;realpath_cache_ttl = 120/realpath_cache_ttl = 86400/g' /etc/opt/remi/php71/php.ini
4. 调优php71 op_cache
文件位置查找: php71 -i | grep opcache.ini | awk '{ print $6; }' | sed 's/,//'
sed -i 's/opcache.memory_consumption=128/opcache.memory_consumption=256/g' /etc/opt/remi/php71/php.d/10-opcache.ini
sed -i 's/opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=16/g' /etc/opt/remi/php71/php.d/10-opcache.ini
sed -i 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=8000/g' /etc/opt/remi/php71/php.d/10-opcache.ini
sed -i 's/;opcache.validate_timestamps=1/opcache.validate_timestamps=0/g' /etc/opt/remi/php71/php.d/10-opcache.ini
sed -i 's/;opcache.fast_shutdown=0/opcache.fast_shutdown=1/g' /etc/opt/remi/php71/php.d/10-opcache.ini
sed -i 's/;opcache.save_comments=1/opcache.save_comments=0/g' /etc/opt/remi/php71/php.d/10-opcache.ini
5. 创建 /workspace/conf/www-php71.conf ,内容如下:
[www]
listen = /dev/shm/php71_9000.sock
listen.owner = www
listen.group = nginx
listen.mode = 0660
user = www
group = www
pm = static
pm.max_children = 40
pm.max_requests = 8000
pm.status_path = /fpm_status
request_terminate_timeout = 3
request_slowlog_timeout = 3
slowlog = /workspace/logs/php-fpm/php71-slow.log
;设置文件打开描述符的rlimit限制
rlimit_files = 655360
;设置核心rlimit最大限制值
rlimit_core = 0
catch_workers_output = yes
security.limit_extensions = .php
env[HOSTNAME] = $HOSTNAME
env[LANG] = $LANG
php_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /workspace/logs/php-fpm/php71-error.log
php_admin_value[memory_limit] = 256M
php_value[session.save_handler] = files
php_value[session.save_path] = /workspace/tmp/session
6. 修改php71 fpm主配文档中的以下字段
文件位置:/etc/opt/remi/php71/php-fpm.conf
include=/workspace/conf/www-php71.conf
[global]
pid = /var/opt/remi/php71/run/php-fpm/php-fpm.pid
error_log = /workspace/logs/php-fpm/php71-error.log
log_level = debug
emergency_restart_threshold = 0
emergency_restart_interval = 0
process_control_timeout = 1s
daemonize = yes
7. 启动php71 fpm
/etc/init.d/php71-php-fpm configtest
/etc/init.d/php71-php-fpm restart
8. nginx启用php71 fpm
sed -i 's/php_9000.sock/php71_9000.sock/g' /workspace/conf/vhost/*.conf