LAMP安全设置

1.设置MySQL密码,删除多余root账号

[html] view plain copy
 
  1. [root@localhost ~]# mysql -uroot -p  
  2. mysql>set password=password("111");  
  3. mysql>use mysql;  
  4. mysql>delete from `user` where user!="root";  
  5. mysql>delete from `user` where user="root" and host!="localhost";  
  6. mysql>exit;  



2.设置网站访问目录权限

[html] view plain copy
 
  1. vim /etc/httpd/conf/httpd.conf  
  2.   
  3. ServerSignature off   //禁止显示操作系统的版本  
  4. ServerTokens prod   //显示版本号为apache  
  5.   
  6. 凡是有Options的全部加上-Index  
  7.   
  8. NameVirtualHost *:80  
  9.   
  10. <VirtualHost *:80>  
  11. ServerName 11.22.33.44    #禁止用户通过IP访问网站根目录  
  12. <Location />  
  13.     Order Allow,Deny  
  14.     Deny from all  
  15. </Location>  
  16. </VirtualHost>  
  17.   
  18. <VirtualHost *:80>  
  19.     ServerAdmin webmaster@abc.com  
  20.     DocumentRoot /var/www/html/test/  
  21.     ServerName www.abc.com  
  22. </VirtualHost>  

3.配置PHP.ini

[html] view plain copy
 
  1. vim /etc/php.ini  
  2.   
  3. (1).magic_quotes_gpc = On //对写入数据库的字符串进行过滤处理  
  4.   
  5. (2).display_errors = Off //关闭错误报告  
  6.   
  7. (3).safe_mode = On //避免本地包含、文件打开、命令执行  
  8.   
  9. (4).disable_functions = phpinfo,exec,system,passthru,shell_exec,escapeshellarg  
  10. ,escapeshellcmd,proc_close,proc_open     
  11. //禁用一些系统函数  
  12.   
  13. (5).register_globals = Off //防止变量滥用  
  14.   
  15. (6).expose_php = Off    //禁止显示php版本信息  




4.mysql权限配置

[html] view plain copy
 
    1. mysql>update user set File_priv='N' where User='root' 
原文地址:https://www.cnblogs.com/frankielf0921/p/5930537.html