Ubuntu Xampp PHP 文件权限与 NTFS 硬盘作为附加媒体存储
我的 Ubuntu 10.10 系统中有 4 个驱动器(是的,物理上在盒子里,SATA 连接),xampp 安装在操作系统驱动器上的 /opt/lampp/ 目录中。操作系统驱动器(ssd,为了理智起见,我们称其为drive1)具有正确的文件权限,允许PHP(用户www-data)读取/写入我的任何htdocs和vhosts文件夹。
我的问题是我尝试移动其他 3 个驱动器之一上存在的文件。我的其他每个驱动器都是 ntfs(1tb、1.5tb 和 2.0tb)并使用 fstab 进行安装。当我使用 gui (nautilus) 查看文件权限时,它说一切都是 root。所以我尝试了 chown、chmod 等。我发现你不能用这些命令更改 ntfs 的权限。所以我转到我的 fstab 配置,但是我无法设置这些权限以允许 PHP 在其中一个驱动器中复制/重命名/移动文件。
我今天更新为使用 UUID,驱动器也在我的本地网络上共享,并且仍然工作得很好。
我在安装后更改为 ntfs-3g 驱动程序,重新启动机器,但我仍然无法让 php 移动文件。
这是我的 fstab 文件: UUID=552A7C6B05CEAAD2 /media/v1tb ntfs-3g 默认值,uid=1000 0 0 UUID=DE58539158536775 /media/v1.5tb ntfs-3g 默认值,uid=1000 0 0 UUID=3D80C54D5D100280 /media/v2.0tb ntfs-3g defaults,uid=1000 0 0
另外,我尝试使用以下内容并且它工作得很好:
sudo -u www-data cp '/media/v2.0tb/path/to/file' '/media/v2.0tb/path/to/newfile'
How does imitating a user work, but php's rename/copyfunctions won't work ?
如何设置 php 用户 (www-data) 以允许复制/重命名/删除这些 ntfs 驱动器上的文件和目录?我必须重新格式化它们吗?
I have 4 drives in my (yes, physically in the box, sata connected) Ubuntu 10.10 system with xampp installed at the /opt/lampp/ dir on the OS drive. The OS drive (ssd, lets call it drive1 for sanity) has the correct file permissions to allow for PHP (user www-data) to read/write to any of my htdocs and vhosts folder(s).
My problem comes with I try to move a file that exists on one of the other 3 drives. Each of my other drives are ntfs (1tb, 1.5tb and 2.0tb) and mounted with fstab. When I view the file permissions with the gui (nautilus) it says that everything is root. So I tried chown, chmod, etc. I found out that you can't change the permissions of ntfs with those commands. So I went to my fstab config, however I can't get those permissions set to allow for PHP to copy/rename/move a file within even one of the drives.
I updated to using the UUID's today, the drives are also shared on my local network and that still works just fine.
I changed to the ntfs-3g driver after installing, restarted the machine but I'm still not able to have php move a file.
Here is my fstab file:
UUID=552A7C6B05CEAAD2 /media/v1tb ntfs-3g defaults,uid=1000 0 0
UUID=DE58539158536775 /media/v1.5tb ntfs-3g defaults,uid=1000 0 0
UUID=3D80C54D5D100280 /media/v2.0tb ntfs-3g defaults,uid=1000 0 0
Also, I tried to use the following and its working just fine:
sudo -u www-data cp '/media/v2.0tb/path/to/file' '/media/v2.0tb/path/to/newfile'
How does imitating a user work, but php's rename/copy functions won't work?
How can I set the php user (www-data) to allow for copying/renaming/deleting files and directories on these ntfs drives? Do I have to reformat them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于实际使用的 ntfs 驱动程序。对于
ntfs-3g
,您可以在 fstab 中使用uid=
和gid=
参数。还有一个可能令人感兴趣的usermapping=
功能。另请参阅联机帮助页Depends on the actual ntfs driver used. For
ntfs-3g
you can use theuid=
andgid=
params in the fstab. There is also ausermapping=
feature that might be of interest. See also the manpage如果有人遇到这样的问题,有时可能是先前目录的权限可能会影响对目录的访问。
例如,在 Ubuntu 12.10 上,与许多其他 Ubuntu 版本一样,分区位于 /media 上。但在此版本中,您可以有另一个目录,您的分区(尤其是 NTFS 和外部驱动器)将位于其中,该目录是 /media/YOUR_USER_NAME。为了解决对我的外部硬盘驱动器的访问,具体来说是使用 PHP,我必须首先更改 /media/MY_USER_NAME 的权限,然后更改 /media/MY_USER_NAME/MY_EXTERNAL_DRIVE 的权限。
这些是使用的命令:
sudo chown MY_USER_NAME MY_USER_NAME/
sudo chown MY_USER_NAME MY_USER_NAME/MY_EXTERNAL_DRIVE/
和
sudo mount -t ntfs -o rw,uid=1000,gid=1000,fmask=000,dmask=000 /dev/sdb1 /media/MY_USER_NAME/MY_EXTERNAL_DRIVE
第一个和第二个是更改目录的所有者,第三个一、以正确的权限挂载NTFS驱动器。
我认为这对某人可能有用,因为我花了几个小时才意识到我可能无法访问以前的目录。
If anybody gets a problem like this, sometimes it could be that the permissions on previous directories could affect the access to a directory.
For example, on Ubuntu 12.10, you have the partitions on /media, as many other Ubuntu versions. But on this version, you could have another directory where your partitions, especially the NTFS and external drives, will be located, and is /media/YOUR_USER_NAME. To solve the access to my external hard drive, concretely using PHP, I had to change permissions at /media/MY_USER_NAME, first, and then at /media/MY_USER_NAME/MY_EXTERNAL_DRIVE.
These are the commands used:
sudo chown MY_USER_NAME MY_USER_NAME/
sudo chown MY_USER_NAME MY_USER_NAME/MY_EXTERNAL_DRIVE/
and
sudo mount -t ntfs -o rw,uid=1000,gid=1000,fmask=000,dmask=000 /dev/sdb1 /media/MY_USER_NAME/MY_EXTERNAL_DRIVE
The first and the second one, is to change the Owner of the directory, and the third one, to mount the NTFS drive with the correct permissions.
I've thought this could be usefull to somebody, cause I've spent several hours after I realized that it could be that I couldn't access to previous directories.