CentOS 上修复 PHP 安全漏洞的实操步骤
一 优先级与总体思路
二 更新系统与 PHP 版本
sudo yum update -y(或 sudo dnf update -y),及时获取内核与基础组件的安全补丁。sudo yum install -y epel-releasesudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpmsudo yum-config-manager --enable remi-php74sudo yum update php\*sudo systemctl restart httpdsudo systemctl restart nginx && sudo systemctl restart php-fpmphp -vyum 替换为 dnf,并使用对应的 Remi 仓库包(remi-release-8.rpm)。三 加固 PHP 运行时配置
php_admin_value 设置):
display_errors = Offlog_errors = Onerror_log = /var/log/php_errors.logdisable_functions = eval,exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_sourceopen_basedir = /var/www/html:/tmp(按实际站点路径调整)allow_url_fopen = Offallow_url_include = Offfile_uploads = Onupload_max_filesize = 2Mpost_max_size = 8Mopcache.enable=1opcache.memory_consumption=128opcache.interned_strings_buffer=8opcache.max_accelerated_files=4000opcache.revalidate_freq=60opcache.fast_shutdown=1user = apache、group = apache)。四 网络与访问控制
sudo yum install -y firewalldsudo systemctl start firewalld && sudo systemctl enable firewalldsudo firewall-cmd --permanent --zone=public --add-service=httpsudo firewall-cmd --permanent --zone=public --add-service=httpssudo firewall-cmd --reloadsudo yum install -y mod_ssl/etc/httpd/conf.d/ssl.conf 中的证书与密钥路径sudo systemctl restart httpd五 应用与运维层面的加固