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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值