Created
May 17, 2017 03:33
-
-
Save Tairy/bd4226e5b2408efde3dcc0e186338fd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php_install_dir=/usr/local/php7 | |
cp php.ini-production $php_install_dir/etc/php.ini | |
Mem=`free -m | awk '/Mem:/{print $2}'` | |
if [ $Mem -gt 1024 -a $Mem -le 1500 ];then | |
Memory_limit=192 | |
elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then | |
Memory_limit=256 | |
elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then | |
Memory_limit=320 | |
elif [ $Mem -gt 4500 ];then | |
Memory_limit=448 | |
else | |
Memory_limit=128 | |
fi | |
sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini | |
sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini | |
sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini | |
sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini | |
sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini | |
sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini | |
sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini | |
sed -i 's@^post_max_size.*@post_max_size = 50M@' $php_install_dir/etc/php.ini | |
sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini | |
sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini | |
sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini | |
sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini | |
sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini | |
sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini | |
sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini | |
[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini | |
#如果编译时去掉了 --enable-opcache,则以下包含opcache的都请忽略 | |
sed -i 's@^\[opcache\]@[opcache]\nzend_extension=opcache.so@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.enable=.*@opcache.enable=1@' $php_install_dir/etc/php.ini | |
sed -i "s@^;opcache.memory_consumption.*@opcache.memory_consumption=$Memory_limit@" $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.save_comments.*@opcache.save_comments=0@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.validate_timestamps.*@opcache.validate_timestamps=1@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.use_cwd.*@opcache.use_cwd=1@' $php_install_dir/etc/php.ini | |
sed -i 's@^opcache.max_accelerated_files.*@opcache.max_accelerated_files=100000@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.max_wasted_percentage.*@opcache.max_wasted_percentage=5@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.consistency_checks.*@opcache.consistency_checks=0@' $php_install_dir/etc/php.ini | |
sed -i 's@^;opcache.optimization_level.*@;opcache.optimization_level=0@' $php_install_dir/etc/php.ini | |
# php-fpm直接沿用之前的配置即可 | |
cp -f /usr/local/php/etc/php-fpm.conf /usr/local/php7/etc/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment