1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- $filepath = "/etc/php7-fpm.d/www.conf";
- $data = file_get_contents($filepath);
- // +------------------------------
- // | 替换配置
- // +------------------------------
- // pm.max_children = 12 改为 pm.max_children=4
- if(preg_match("/pm\.max_children[ ]*=[ ]*(\d+)/", $data, $matches) && count($matches) == 2) {
- $oldStr = $matches[0];
- $value = $matches[1];
- $newStr = str_replace($value, "4", $oldStr);
- $data = str_replace($oldStr, $newStr, $data);
- }
- // pm = dynamic 改为 pm = static
- if(preg_match("/pm[ ]*=[ ]*(\w+)/", $data, $matches) && count($matches) == 2) {
- $oldStr = $matches[0];
- $value = $matches[1];
- $newStr = str_replace($value, "static", $oldStr);
- $data = str_replace($oldStr, $newStr, $data);
- }
- // +------------------------------
- // | 写入并重启php-fpm
- // +------------------------------
- file_put_contents($filepath, $data);
- exec("/etc/init.d/php7-fpm restart");
- // +------------------------------
- // | 1小时清除1次accress.log
- // +------------------------------
- $command = "0 * * * * echo \\\"\\\" > /var/log/nginx/access.log";
- $output = "grep -qxF \"$command\" /etc/crontabs/root || echo \"$command\" >> /etc/crontabs/root";
- exec($output)."\n";
- // 重启定时任务
- exec("/etc/init.d/cron restart");
- exec("rm -rf /etc/overlayfsconfig.tar.gz");
- exec("rm -rf /etc/config.tar.gz");
|