2016-09-29 88 views
1

當我嘗試更新作曲家或清除我的symfony項目的緩存時,我經常會收到文件權限錯誤。 http://symfony.com/doc/current/setup/file_permissions.htmlSymfony Project,無法修復文件權限

linux下的我',Manjaro鸚鵡版(最新穩定版) 服務器apache的最後一個版本

例如:

composer update 
Loading composer repositories with package information 
Updating dependencies (including require-dev) 
Nothing to install or update 
Generating autoload files 
> Incenteev\ParameterHandler\ScriptHandler::buildParameters 
Updating the "app/config/parameters.yml" file 
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap 
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache 

// Clearing the cache for the dev environment with debug true               

    [Symfony\Component\Filesystem\Exception\IOException]                                     
    Failed to remove file "/srv/http/PetitMur/var/cache/de~/annotations/1a/5b504d5c506c6174666f726d42756e646c655c456e746974795c41727469636c652474616773405b416e6e6f745d5d5b315d.doctrinecache.data": . 
然而,我的文件是根據symfony中的文檔設置正確

該文件有這樣的權利:

pierre $ la /srv/http/PetitMur/var/cache/de~/annotations...data 
-rw-rw-r--+ 1 http http 234 29.09.2016 18:13 /srv/http/PetitMur/var/cache/de~/annotations...data 

我知道,這個問題是經常性的。但是我已經根據symfony的doc設置了權限文件。目前我必須在超級用戶上運行命令才能使其工作,這是不正常的。

你有想法嗎?

編輯:

php bin/symfony_requirements 

Symfony Requirements Checker 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

> PHP is using the following php.ini file: 
    /etc/php/php.ini 

> Checking Symfony requirements: 
    .............................WW...... 


[OK]           
Your system is ready to run Symfony projects 


Optional recommendations to improve your setup 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

* intl extension should be available 
    > Install and enable the intl extension (used for validators). 

* a PHP accelerator should be installed 
    > Install and/or enable a PHP accelerator (highly recommended). 


Note The command console could use a different php.ini file 
~~~~ than the one used with your web server. To be on the 
     safe side, please check the requirements from your web 
     server using the web/config.php script. 
+0

您是否嘗試使用rm -rf var/cache/*清除? –

+0

是的,但過了一段時間後問題又回來了。 –

+0

哪個網站服務器?它是Apache嗎? –

回答

0

我試試這個「sudo chown -R http:pierre Myproject」,目前這個工作可以清除緩存,但不適用於作曲家。

0

我懷疑許可,可能用戶組的設置可能不正確。

進入Apache httpd.conf文件檢查用戶/組設置。你會看到線是這樣的:

User apache 
Group apache 

以上是從我的系統是CentOS 6的,並且httpd.conf文件是/etc/httpd/conf/文件夾下。您的位置可能不同,可能是用戶httpd(請檢查它)。

然後設置正確的用戶/組爲您Symfony3項目:

sudo chown -R apache:apache /srv/http/PetitMur 

上述命令將用戶:組既apache,您可能需要使用httpd

現在刪除舊的緩存文件&日誌,因爲它們可能已經被之前與錯誤的用戶創建:

sudo rm -rf var/cache/* 
sudo rm -rf var/logs/* 

然後再次運行setfacl的,請確保你砍&膏(有一個大寫X),並使用正確的用戶(Apache或httpd的):

$ sudo setfacl -R -m u:apache:rwX -m u:`whoami`:rwX var 
$ sudo setfacl -dR -m u:apache:rwX -m u:`whoami`:rwX var 

然後測試你的系統,看看它的問題得到了解決。

+0

在我的情況下,用戶和組在我的hhtpd.conf中是「http」。我告訴你,我已經嘗試過...但是對於你我再試一次,並且=> pierre $作曲者更新 裝載作曲家​​軟件包的軟件包信息 更新依賴關係(包括require-dev) 沒有安裝或更新 [ErrorException] file_put_contents(/srv/http/PetitMur/vendor/composer/installed.json):faile d打開流:權限被拒絕 –

+0

And => pierre $ la/srv/http/PetitMur/vendor/composer/installed .json -rw-r - r-- 1 http http 81281 29.09.2016 19:50/srv/http/PetitMur/vendor/composer –

+0

您是否嘗試過:'sudo composer update'?你可能不得不指向作曲家的位置。使用'whereis composer'來找到它。 –