简体   繁体   English

yii2没有使用composer以正确的权限进行安装

[英]yii2 not installing with correct permissions with composer

I am running windows 10 with the ubuntu subsystem installed as my localhost. 我正在运行Windows 10,并将ubuntu子系统安装为我的本地主机。 I have composer installed on that and when I try to install the yii2 basic application it goes through the process correctly but when i open the yii2 basic application in my browser I get: 我在上面安装了composer,当我尝试安装yii2基本应用程序时,它可以正确执行此过程,但是当我在浏览器中打开yii2基本应用程序时,我得到:

Failed to change permissions for directory "/mnt/c/Users/andre/zype/staff-tools/web/assets/89851207": chmod(): Operation not permitted 未能更改目录“ / mnt / c / Users / andre / zype / staff-tools / web / assets / 89851207”的权限:chmod():不允许操作

If I then change permissions on the yii2 installation file structure with 如果然后我使用以下命令更改了yii2安装文件结构的权限

sudo chown -R www-data:www-data . sudo chown -R www-data:www-data。

the application loads but the web/assets folders are missing so my application has no styling. 该应用程序已加载,但缺少web / assets文件夹,因此我的应用程序没有样式。 I am unsure if this is a composer issue or a yii2 issue but it looks like permissions to me. 我不确定这是作曲家问题还是yii2问题,但对我来说似乎是许可。

Try changing the permission of 'assets' folder most likely to 777 (all users can access this file) 尝试将“ assets”文件夹的权限更改为最可能的777(所有用户都可以访问此文件)

your-project/web/assets 您的项目/网络/资产

Well this solution works for Linux users. 好了,该解决方案适用于Linux用户。 Will require to check for windows 将需要检查窗户

Follow Steps 遵循步骤

Step 1- Install Composer (I installed it through bash) 第1步-安装Composer(我通过bash安装了它)

Step 2- Now in cmd use following command 步骤2-现在在cmd中使用以下命令

composer create-project --prefer-dist yiisoft/yii2-app-basic yii2-basic-check composer create-project --prefer-dist yiisoft / yii2-app-basic yii2-basic-check

Output (Last Lines)- 输出(最后一行)-

chmod('runtime', 0777)...done. chmod('runtime',0777)...完成。

chmod('web/assets', 0777)...done. chmod('web / assets',0777)...完成。

chmod('yii', 0755)...done. chmod('yii',0755)...完成。

Step 3 - Open " http://localhost/yii2-basic-check/web/ " URL in browser. 第3步-在浏览器中打开“ http:// localhost / yii2-basic-check / web / ” URL。 It worked fine for me 对我来说很好

Important: Windows Subsystem for Linux has many serious problems with file permission. 重要说明: Linux的Windows子系统在文件权限方面存在许多严重问题。 So, I advise not to install Linux programs and it's files in Windows drives ie DRVFS ( /mnt/c ). 因此,我建议不要在Windows驱动器(即DRVFS( /mnt/c ))中安装Linux程序及其文件。 Also as PHP frameworks need many files, it will be better if you install distributions in another internal NTFS drives other that C:\\ drive. 另外,由于PHP框架需要许多文件,因此,如果将发行版安装在C:\\驱动器以外的另一个内部NTFS驱动器中,则会更好。

Steps: Place/clone the required project files/repositories in current user's home folder eg /root , /home , /home/user . 步骤:将所需的项目文件/存储库放置/克隆到当前用户的主文件夹中,例如/root/home/home/user Do not place the files in C:\\ drive aka. 不要将文件放在C:\\驱动器中。 /mnt/c otherwise WSL will not follow their permissions correctly. /mnt/c否则WSL将不会正确遵循其权限。 Here is an example of the installation procedure from YiiFramework: The Definitive Guide to Yii 2.0 . 这是YiiFramework的安装过程示例:Yii 2.0权威指南

  • Install required packages: sudo apt-get install php php-cli php-common php-mbstring php-xml php-zip zip unzip 安装所需的软件包: sudo apt-get install php php-cli php-common php-mbstring php-xml php-zip zip unzip
  • Go to user folder: cd ~ 转到用户文件夹: cd ~
  • Download composer: curl -sS https://getcomposer.org/installer | php 下载作曲家: curl -sS https://getcomposer.org/installer | php curl -sS https://getcomposer.org/installer | php
  • Install yii2-basic: ~/composer.phar create-project --prefer-dist yiisoft/yii2-app-basic basic 安装yii2-basic: ~/composer.phar create-project --prefer-dist yiisoft/yii2-app-basic basic
  • Go to project folder: cd ~/basic 转到项目文件夹: cd ~/basic
  • Run PHP server: php yii serve 运行PHP服务器: php yii serve
  • Open server in browser at localhost:8080 (default port 8080). 在浏览器中的localhost:8080 (默认端口8080)中打开服务器。

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

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