在CentOS系统中,为了确保PHP的安全性,你可以采取以下措施来配置PHP安全设置:
sudo yum update php
sudo chmod 644 /etc/php.ini
sudo chown root:root /etc/php.ini
eval(), exec(), system(), passthru(), shell_exec()等。找到以下行并取消注释(删除行首的分号):disable_functions = eval, exec, system, passthru, shell_exec, ...
upload_max_filesize = 10M
post_max_size = 10M
display_errors = Off
log_errors = On
error_log = /var/log/php_errors.log
session.cookie_secure = 1
session.cookie_httponly = 1
session.cookie_samesite = Lax
zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
sudo systemctl restart httpd
对于Nginx和PHP-FPM,可以使用以下命令:
sudo systemctl restart nginx
sudo systemctl restart php-fpm
遵循以上建议,可以显著提高CentOS系统中PHP的安全性。请注意,这些设置可能需要根据你的具体需求进行调整。在生产环境中部署应用程序之前,请务必对其进行充分的测试。