Home > php教程 > php手册 > body text

php 虚拟主机安全 设置

WBOY
Release: 2016-06-06 19:52:26
Original
1274 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 为了安全,我们通常会在虚拟主机设置中,加入这一行 php_admin_value open_basedir "/usr/local/apache/htdocs/www" 但这会导致move_uploaded_file不能读取临时目录中的上传文件,导致上传文件失失败

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

    为了安全,我们通常会在虚拟主机设置中,加入这一行

    php_admin_value open_basedir "/usr/local/apache/htdocs/www"

    但这会导致move_uploaded_file不能读取临时目录中的上传文件,导致上传文件失失败。

    一般会提示以下错误:

    Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/tmp/phpqwg5rO) is not within the allowed path(s): (/usr/local/apache/htdocs/www) in /usr/local/apache/htdocs/www/includes/lib_common.php on line 3130

    解决方法:

    将上传文件的临时目录加入到php_admin_value open_basedir后面,最后看起来是这样的:

   

    php_admin_value open_basedir "/usr/local/apache/htdocs/www:/tmp"

   

    注意:两个目录之间是冒号隔开。

    把PHP脚本操作限制在web目录可以避免程序员使用copy函数把系统文件拷贝到web目录。move_uploaded_file不受open_basedir的限制,所以不必修改php.ini里upload_tmp_dir的值。

php 虚拟主机安全 设置

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template