Function of the open_basedir option in the PHP configuration file

Source: Internet
Author: User

The following is the original description and default configuration in PHP. ini:
; Open_basedir, if set, 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 safe mode is turned on or off.
Open_basedir =.
Open_basedir can restrict the activity scope of files accessed by users to a specified region. It is usually the path of the home directory
The "." symbol can be used to represent the current directory. Note that the restriction specified by open_basedir is actually a prefix rather than a directory name.
For example, if "open_basedir =/DIR/user", the directories "/DIR/user" and "/DIR/user1" are both
Accessible. Therefore, if you want to restrict access to a specified directory only, end the path with a slash. For example, set:
"Open_basedir =/DIR/user /"

Open_basedir can also set multiple directories at the same time. In Windows, use semicolons to separate directories and use them in any other system.
Separate directories with colons. When it acts on the Apache module, the open_basedir path in the parent directory is automatically inherited.

There are three ways to make independent settings for specified users in Apache:

(A) How to Set directory in httpd. conf of Apache:

Php_admin_value open_basedir/usr/local/Apache/htdocs/
# To set multiple directories, refer to the following:
Php_admin_value open_basedir/usr/local/Apache/htdocs/:/tmp/

(B) How to Set virtualhost in httpd. conf of Apache:
Php_admin_value open_basedir/usr/local/Apache/htdocs/
# To set multiple directories, refer to the following:
Php_admin_value open_basedir/var/www/html/:/var/tmp/

(C) Because open_basedir is set in virtualhost, this virtual user will not inherit PHP. ini automatically.
Open_basedir setting value in, which makes it difficult to achieve flexible configuration measures. Therefore, we recommend that you do not
For example, you can set open_basedir =.:/tmp/in PHP. ini.
Access the current directory (the directory where the PHP script file is located) And/tmp/directory.

Note: If the temporary directory for uploading files set in PHP. INI is/tmp/, open_basedir must be set.
Contains/tmp/, otherwise the upload will fail. The new PHP version will prompt "open_basedir restriction in effect"
Warning, but the move_uploaded_file () function can still successfully retrieve the uploaded files in the/tmp/directory.
This is a vulnerability or a new feature.

Shopex472 Configuration:

Open_basedir = "D:/server ;.. /CATALOG ;.. /include ;.. /.. /home ;.. /syssite ;.. /templates ;.. /language ;.. /.. /language ;.. /.. /.. /language ;.. /.. /.. /.. /language"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.