I have a LAMP server setup. I have the source folder in my desktop which I can edit without 'sudo'ing. Then, I sync the files to var/www using sudo rsync. I gave the folders in var/www necessary permissions (770 for the mentioned folder, since www-data is added to root group, and apache has to write to this directory, that is upload directory). It works well. But, when I restart the computer, files in the upload folder in var/www disappears. I cannot understand what is happening.

  drwxrwxr-x 2 root www-data 4096 Dec 15 08:26 uploaded_files

my folder permissions look like this.

EDIT: The files disappear some time after the upload.

I'm just confused like hell.

Any help will be appreciated. I'm a newbie in linux file, folder permission btw.



I had my source files in my Desktop, and I was syncing with var/www manually so that I don't have to sudo files individually. I was achieving this by syncing the entire desktop folder whenever I felt syncing is necessary. I used the '--delete' bit in my rsync command, so that any extra files in the destination which might have been deleted in my Desktop source, will be removed.

Here is the catch: I have a /upload/dir in my desktop, but nothing really gets uploaded, since it is done in document root, which is /var/www/. So, whenever I sync files, my Desktop /upload/dir (which is empty and will always be) replaces the /upload/dir in the document root. Hence the content disappeared.

Moral (for me & new linux users): Never blindly copy commands in terminal, without getting a basic understanding.

| improve this answer | |

They're either not saved, or removed. Check if /var/www isn't on a tmpfs (that's like a RAM disk, files are not saved to disk but kept in memory and so will disappear on reboot):

df -hT /var/www

and see what's under "Type". For example, I keep my logs on a tmpfs:

$ df -hT /var/log 
Filesystem     Type   Size  Used Avail Use% Mounted on
tmpfs          tmpfs  3.9G  672K  3.9G   1% /var/log
| improve this answer | |
  • actually, it disappears a few minutes after uploading. It happens even after giving 777 permissions – palerdot Dec 15 '12 at 6:41
  • /dev/sda6 ext4 46G 8.8G 35G 21% / /var/www it lists as ext4 – palerdot Dec 15 '12 at 6:42
  • my other files in var/www are intact – palerdot Dec 15 '12 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.