| #Fedora/Centos/Redhat vi /etc/httpd/conf/httpd.conf #Ubuntu/Debian vi /etc/apache2/httpd.conf |
我们可以使用默认的用户组,也可以创建新的用户/组。
第六、防止信息泄露
默认的Apache安装后会在默认页面体现出端口、版本信息等,我们需要隐藏这些信息。
| #Fedora/Centos/Redhat vi /etc/httpd/conf/httpd.conf #Ubuntu/Debian vi /etc/apache2/conf-enabled/security.conf |
搜索ServerTokens和ServerSignature字符,然后对应修改
ServerTokens Prod
ServerSignature Off
然后重启Apache
#Fedora/Centos/Redhat
service apache2 restart
#Ubuntu/Debian
service httpd restart
然后我们的404页面就看不到版本信息。
第七、隐藏PHP版本信息
| #Fedora/Centos/Redhat vi /etc/php.ini #Ubuntu/Debian vi /etc/php5/apache2/php.ini |
然后搜索expose_php,对应的参数on改成off
第八、禁用自动索引模块
#Fedora/Centos/Redhat
/etc/httpd/conf/httpd.conf
把"LoadModule autoindex_module modules/mod_autoindex.so"一行前面加上#禁止掉
#Ubuntu/Debian
rm -rf /etc/apache2/mods-enabled/autoindex.conf
删除自动索引模块
总结,以上老左就整理到8点Apache的安全设置,还有一些设置我们可以查看.htaccess文件的安全设置,我们不容小视这个小文件,有些安全设置还是需要通过.htaccess文件的,以后有时间专门整理一篇。无论如何,不管我们使用的是虚拟主机,还是VPS/服务器,我们需要随时监控和定时备份网站和项目数据。









