1

I have two domains DomainA.com , DomainB.com on my Linux Server , each with separate space.

I am using PHP and MySQL for both my websites.

I have a page on DomainA.com from where users upload files. But I need to store the files uploaded from DomainA.com , on DomainB.com/mystorage.

For this what permissions I need to set of the 'mystorage' folder ....0777 or 0755 or else?

Or shall I need to give permissions to a User Account of DomainA.com to 'storage' folder on DomainB.com and simply use PHP for uploading? How do I give permissions on my Linux server of one folder on DomainB to user account of DomainA?

I got suggestions of chmod but don't know how to use it . please help.

sqlchild
  • 113
  • 1
  • 7
  • If you don't know how to use chmod (really?) then what are you using to set permissions? As for using chmod, do you know how to use Google? – John Gardeniers Sep 20 '12 at 12:28

2 Answers2

2

chmod is used to change the permissions on a file or folder. The permissions in 0777 are four separate types of permissions:

  • First digit = special permissions such as suexec
  • Second digit = permission for the user owning the file or folder
  • Third digit = permission for the group owning the file or folder
  • Fourth digit = permission for everybody else

The numbers used are 1 for execute, 2 for write, and 4 for read. You get the full number by adding them together, so the numer 7 means read, write and execute rights.

0777 means that the owner, and the group, and everybody else has read, write and execute rights. (In the context of a folder, execute rights means that you can look at the contents of the folder.)

If you give your folder permissions 0777 you're allowing everybody to do anything, including deleting, files in the folder. It would be better to make sure that the two accounts are in the same group and give that group permission to do what needs to be done - that would probably mean 0775.

Jenny D
  • 27,358
  • 21
  • 74
  • 110
2

so i assume you are using apache?

if so, make sure that the 'mystorage' folder is owned by the apache user/group.

You don't have to do "cross-domain uploading" because both websites are on the same box. If one site writes to mystorage on that box, the other site can access it.

If we are talking about both site's servving that content statically, you have 2 Possible solutions:

  1. you could move_uploaded_file to SiteA's storage, then copy the file to siteB's storage, but then you have 2 copies of the same file.
  2. I would suggest having mystorage separate from both sites. on upload, move_uploaded_file to mystorage. then serve the mystorage files using another server (not apache) like NGINX
  • yes sir, am using apache. when i upload on domainB.com/mystorage , then PHP says Permissions error. so i have to put permissions as 0777 , but 0777 is not safe , and then with 0777 , the files are uploaded without any problem , but i don't want permissions of 'mystorage' foloder as 0777 , i want them as 0755 – sqlchild Sep 20 '12 at 12:54
  • make sure that the apache group (apache is a linux user with a group) owns the directory that you are trying to upload into. – Francis Yaconiello Sep 20 '12 at 13:07
  • how do i check this ? – sqlchild Sep 20 '12 at 13:50
  • Read this: http://www.tuxfiles.org/linuxhelp/filepermissions.html its a much better and in depth description of users/groups and permission levels for linux than I could ever write on my own – Francis Yaconiello Sep 20 '12 at 15:26