简体   繁体   English

Docker nginx php 权限问题

[英]Docker nginx php permissions issue

I'm just learning Docker and took on a little pet project and wondering if something is possible permission wise with docker/nginx/php.我刚刚学习 Docker 并承担了一个小宠物项目,并想知道 docker/nginx/php 是否有可能获得许可。 I'm attempting to convert an old IIS-Windows/php/MySql project of mine to Docker/nginx/php/mysql我正在尝试将我的旧 IIS-Windows/php/MySql 项目转换为 Docker/nginx/php/mysql

I'm most of the way there and have the 3 containers linked and all is working well EXCEPT, this system has a file upload/view/delete component to it.我大部分时间都在那里,并且链接了 3 个容器,并且一切都运行良好,除了这个系统有一个文件上传/查看/删除组件。 I want the "files" stored outside of the root html folder which is "/usr/share/nginx/html" in this case.我希望将“文件”存储在根 html 文件夹之外,在本例中为“/usr/share/nginx/html”。

My Linux box has a 120 gb ssd where my os and docker solution live.我的 Linux 盒子有一个 120 gb ssd,我的操作系统和 docker 解决方案在那里运行。 I have a ~9 TB raid (4 3TB drive mdadm raid 5) mounted to the system as well, and that is where I'd like to store a folder "files" and allow my docker solution to read/write to it from the PHP web interface.我也有一个 ~9 TB RAID(4 个 3TB 驱动器 mdadm raid 5)安装到系统上,这就是我想存储文件夹“文件”并允许我的 docker 解决方案从PHP web 接口。 I can't seem to get this to work.我似乎无法让它工作。

I've added these volume maps to my docker-compose:我已将这些卷映射添加到我的 docker-compose:

volume:
  - ./code:/usr/share/nginx/html
  - /mnt/md0/files:/usr/share/nginx/html/files

where "code" is my php code of course and it seems to work as far as the "files" folder being visible in the folder structure, but I can't write to it, php permission denied error.其中“代码”当然是我的 php 代码,它似乎可以在文件夹结构中可见的“文件”文件夹中工作,但我无法写入它,php 权限被拒绝错误。 I've run:我跑过:

docker exec -it [myNginxContainer] chown -Rf www-data.www-data /usr/share/nginx/html/files

and that does change the actual ownership of my folder on the raid to that, but can't write to it still from php.这确实将我在 raid 上的文件夹的实际所有权更改为那个,但仍然无法从 php 写入它。 (doing this does work as I want it to if I put the actual "files" folder inside the code directory: /usr/share/nginx/html/ and remove the volume map in docker-compose, but I want it on the raid) (如果我将实际的“文件”文件夹放入代码目录:/usr/share/nginx/html/ 并删除 docker-compose 中的卷 map,则这样做确实可以按我的意愿工作,但我希望它在 raid 上)

I even tried setting the folder permissions wide open:我什至尝试将文件夹权限设置为开放:

chmod 777 /mnt/md0/files/

just so see if that would help and it doesn't.就这样看看这是否有帮助,但没有。 The permissions on that folder on the raid look like this after all this:毕竟,raid 上该文件夹的权限如下所示:

drwxrwxrwx 2 www-data www-data  4096 Jan 17 23:41 files

seems like that should be writable?似乎应该是可写的?

before I tear my hair out any more, is something like this even possible?在我再把头发扯掉之前,这样的事情可能吗? And at some point I may even want that "files" location to be a mounted network location, but at least an "external-to-my-html" folder location for now.在某些时候,我什至可能希望那个“文件”位置是一个挂载的网络位置,但至少现在是一个“external-to-my-html”文件夹位置。

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

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