apache 怎么禁止操作根目录以外的位置

WBOY
Release: 2016-06-23 14:14:20
Original
941 people have browsed it

怎么设置apache 让程序只能操作本程序根目录以内的文件。现在用file_put_contents之类的文件操作方法可以操作根目录以外的文件。


回复讨论(解决方案)

设置 open_basedir

比方有三个站是这样的 要怎么写呢

DocumentRoot "E:\php\web\php\w39"
ServerAlias *.w39.com



DocumentRoot "E:\php\web\php\w38"
ServerAlias *.w38.com



DocumentRoot "E:\php\web\php\w36"
ServerAlias *.w36.com

每个虚拟主机里面写一个 php_admin_value open_basedir "E:\php\web\php\w3X : php上传的临时目录" 记得是这样的,你试试

谢谢大家!解决了!贴出一个配置让今后再遇到这种情况的人学习一下
httpd.conf配置

DocumentRoot "E:\php\web\php\qddd"
ServerAlias *.w30.com
php_admin_value open_basedir e:/temp/;E:/php/web/php/qddd/

php.ini配置
upload_tmp_dir ="e:\temp"
session.save_path = "e:\temp"

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template