一、安装PHP
apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-curl php7.0-mbstring php7.0-dev php7.0-gd php7.0-zip php7.0-xml
二、编辑php-fpm配置
vim /etc/php/7.0/fpm/pool.d/www.conf
修改配置项
user = www-data group = www-data listen.owner = www-data listen.group = www-data pm.max_requests = 5000 #设置每个子进程重生之前服务的请求数. 对于可能存在内存泄漏的第三方模块来说是非常有用的. 如果设置为 '0' 则一直接受请求. 等同于 PHP_FCGI_MAX_REQUESTS 环境变量. 默认值: 0. rlimit_files = 65535 #设置文件打开描述符的rlimit限制. 默认值: 系统定义值默认可打开句柄是1024,可使用 ulimit -n查看,ulimit -n 65535修改。必须制定,否则为系统默认值(1024) rlimit_core = 0 #设置核心rlimit最大限制值. 可用值: 'unlimited' 、0或者正整数. 默认值: 系统定义值. php_admin_value[error_log] = /var/log/fpm-php.www.log php_admin_flag[log_errors] = on php_admin_value[memory_limit] = 128M php_admin_value[post_max_size] = 200M php_admin_value[upload_max_filesize] = 190M php_admin_value[max_file_uploads] = 50 php_admin_value[date.timezone] = PRC php_admin_value[max_execution_time] = 300 php_admin_value[max_input_time] = 600 php_admin_value[session.save_path] = /var/lib/php/sessions php_admin_value[session.gc_probability] = 1 php_admin_value[session.gc_divisor] = 1000 php_admin_value[session.cookie_lifetime] = 0 php_admin_value[session.gc_maxlifetime] = 1440
修改session存储位置:
mkdir /mnt/sessions chmod 1733 /mnt/sessions
修改配置:
php_admin_value[session.save_path] = /mnt/sessions
三、重启php-fpm服务
service php7.0-fpm reload