1

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?

Vance
  • 75
  • 7
  • Oh, while still programming-related such questions might be better placed on [Unix.SE](http://unix.stackexchange.com/) or [AskUbuntu](http://askubuntu.com/) – mario Dec 09 '11 at 16:13

2 Answers2

0

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.

xarlymg89
  • 2,552
  • 2
  • 27
  • 41
0

Depends on the actual ntfs driver used. For ntfs-3g you can use the uid= and gid= params in the fstab. There is also a usermapping= feature that might be of interest. See also the manpage

mario
  • 144,265
  • 20
  • 237
  • 291
  • Looking into those as we speak. I didn't really want to switch to ntfs-3g but it doesn't matter. Obviously I don't really want to have just anyone write to my drives but my local network does need at least read access. Thanks for the quick post, I'll get back with the results. – Vance Dec 09 '11 at 16:25
  • I'm accepting your answer and moving this over to askubuntu.com [link](http://askubuntu.com/questions/86497/ubuntu-xampp-php-file-permissions-with-ntfs-hdds-as-additional-media-storage) – Vance Dec 09 '11 at 18:49