Running PHP file outside of documentroot (cgi-bin folder)

后端 未结 5 1371
慢半拍i
慢半拍i 2021-01-25 13:22

I am working with a colleague to set up their local environment on a MAC in XAMPP, on windows my vhost looks like the one below.

When I access a URL like http://domain.l

5条回答
  •  孤独总比滥情好
    2021-01-25 14:12

    Assuming that PHP is running in Safe Mode you may need to "open" your cgi-bin directory, as the execution of user (PHP) scripts is limited to the DocumentRoot and it's subfolders.

    For all I know you could do that in two ways

    1. Edit your php.ini

    Locate the line containing open_basedir. If there's a comment at the beginning of the line - a semicolon - remove it. Then add your cgi-bin directory.

    open_basedir = "E:\home\www\www.domain.co.uk\cgi-bin\"

    If you need to open more than one directories you can use semicolon ; as a separator. On Linux based server, use a colon :

    open_basedir = "E:\home\www\www.domain.co.uk\cgi-bin\;E:\home\www\www.domain.co.uk\another_dir\"

    In cases like mine, where your server is hosted by third party, you'd need the second option (well sort of)

    2. Edit your VirtualHost

    Add the following to your VirtualHost, i.e. after DocumentRoot:

    php_admin_value open_basedir "E:\home\www\www.domain.co.uk\cgi-bin\"

    Same rules apply here for multiple directories and difference between Linux and Windows systems as above.

    Hope that helps

提交回复
热议问题