disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,phpinfo #禁用的函数
expose_php = off #避免暴露PHP信息
display_errors = off
enable_dl = off
allow_url_include = off
session.cookie_httponly =1
upload_tmp_dir =/tmp
open_basedir =./:/tmp:/home/wwwroot/ open_basedir参数详解
; open_basedir,ifset, limits all file operations to the defined directory
; and below.This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file.This directive is
;*NOT* affected by whether SafeMode is turned On or Off.; http://php.net/open-basedir
open_basedir可将用户访问文件的活动范围限制在指定的区域,通常是其家目录的路径,也可用符号”.”来代表当前目录。注意用open_basedir指定的限制实际上是前缀,而不是目录名。
举例来说: 若”open_basedir = /home/wwwroot”, 那么目录 “/home/wwwroot” 和 “/home/wwwroot1″都是可以访问的。所以如果要将访问限制在仅为指定的目录,请用斜线结束路径名。 注意:
从网上获取的资料来看,open_basedir会对php操作io的性能产生很大的影响。研究资料表明,配置了php_basedir的脚本io执行速度会比没有配置的慢10倍甚至更多,请大家自己衡量
open_basedir也可以同时设置多个目录, 在Windows中用分号分隔目录,在任何其它系统中用冒号分隔目录。当其作用于Apache模块时,父目录中的open_basedir路径自动被继承。 MySQL安全设置 1. MySQL版本的选择
在正式生产环境中,禁止使用4.1系列的MySQL数据库。至少需要使用5.1.39或以上版本。 2. 网络和端口的配置
在数据库只需供本机使用的情况下,使用–skip-networking参数禁止监听网络 。 3. 确保运行MySQL的用户为一般用户,如mysql,注意存放数据目录权限为mysql
vi /etc/my.cnf
user = mysql 4. 开启mysql二进制日志,在误删除数据的情况下,可以通过二进制日志恢复到某个时间点
vi /etc/my.cnf
log_bin = mysql-bin
expire_logs_days =7 5. 认证和授权
(1)禁止root账号从网络访问数据库,root账号只允许来自本地主机的登陆。
mysql>grant all privileges on *.* to root @localhost identified by 'password' with grant option;
mysql>flush priveleges;
(2)删除匿名账号和空口令账号
mysql>USE mysql;
mysql>delete from user where User=;
mysql>delete from user where Password=;
mysql>delete from db where User=; web服务器安全
确保运行Nginx或者Apache的用户为一般用户,如www,注意存放数据目录权限为www
防止sql注入