简体   繁体   English

php composer open_basedir限制,如何设置主路径?

[英]php composer open_basedir restriction, how do I set the home paths?

I have installed php and composer on a Windows Vista 64 machine. 我已经在Windows Vista 64计算机上安装了php和composer。 I am having a devil of a time getting Composer to accept a directive to use a specified directory other than the default C:\\Users\\\\AppData\\Roaming\\Composer. 我有一段时间让Composer接受指令以使用默认C:\\ Users \\\\ AppData \\ Roaming \\ Composer以外的指定目录,这真是恶魔般的时刻。

I tried to set up a config.json file viz: 我试图设置config.json文件,即:

{
    "config": {
        "COMPOSER_HOME": "c:\inetpub\wwwroot\PHPcomposer\",
        "COMPOSER_CACHE_DIR": "c:\inetpub\wwwroot\PHPcomposer\"
    }    
}

and this was completely ignored. 而这完全被忽略了。 even added cache-dir for fun. 甚至增加了cache-dir的乐趣。

I tried altering the composer.json viz: 我尝试更改composer.json的viz:

{
    "require": {
        "symfony/validator":         "2.1.*",
        "doctrine/dbal":             "2.2.*",
        "monolog/monolog":           "dev-master",
        "jtreminio/test-extensions": "dev-master"
    },
    "minimum-stability": "dev",
    "config": {
        "COMPOSER_HOME": "c:/inetpub/wwwroot/PHPcomposer/",
        "cache-dir": "c:/inetpub/wwwroot/PHPcomposer/",
        "COMPOSER_CACHE_DIR": "c:/inetpub/wwwroot/PHPcomposer/"
    }    
}

and still I am getting an open_basedir restriction in effect message referring to 而且我仍然得到一个open_basedir限制,实际上消息是指

C:\Users\<user>\AppData\Roaming\Composer

I also did a iisreset, just in case iis was caching stuff. 我还做了一个iisreset,以防万一iis缓存了东西。

So, any clues as to where I am going wrong. 因此,关于我要去哪里的任何线索。 I know I can alter php.ini, but that to me is violating the security that php is offering. 我知道我可以更改php.ini,但对我而言这违反了php提供的安全性。 I would prefer to tell Composer to behave and do what I tell it to do. 我宁愿告诉Composer表现并按照我的指示去做。


Here is the command line I used and the result of it, the same error occurs regardless of any settings in config.phar or the "config" section in composer.phar. 这是我使用的命令行及其结果,无论config.phar或composer.phar中的“ config”部分如何设置,都会发生相同的错误。 The php.ini has open_basedir = "C:\\inetpub\\wwwroot": php.ini具有open_basedir =“ C:\\ inetpub \\ wwwroot”:

C:\inetpub\wwwroot\PHPcomposer>composer install

[ErrorException]
file_exists(): open_basedir restriction in effect. 
File(C:/Users/Stuart/AppData/Roaming/Composer/.htaccess) is not 
within the allowed path(s): (C:\inetpub\wwwroot)


 install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev]
 [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress]
 [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]

You need to Create a directory c:\\pathTo\\composer and download composer.phar into it from here 您需要创建目录c:\\ pathTo \\ composer并从此处composer.phar下载到该目录中

Then setup COMPOSER_HOME and COMPOSER_CACHE_DIR before running php, in a batch file: 然后在批处理文件中运行php之前设置COMPOSER_HOME和COMPOSER_CACHE_DIR。

composer.bat 作曲家蝙蝠

@ECHO off
SET cwd=%cd%
PUSHD "c:\pathTo\php-5.4.28"
SET COMPOSER_HOME=c:\pathTo\composer
SET COMPOSER_CACHE_DIR=c:\pathTo\composer
"c:\pathTo\php-5.4.28\php.exe" -c "c:\pathTo\phpIniDir" -ddisable_functions="" -ddisable_classes="" -n "c:\pathTo\composer\composer.phar" --working-dir="%cwd%" %* 
POPD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM