0

I am using Centos 5.5

Let's say I have 2 directories:

/var/www/read

/var/www/write

If a file is created in /var/www/read is it possible to have it "redirected" so that it's actually created in /var/www/write and NOT in /var/www/read?

e.g. Trying to create /var/www/read/directory/directory/newfile.txt actually ends up creating /var/www/write/directory/directory/newfile.txt

Why?

I want any Apache writes to be in a different directory then where it reads from. I can't do this directly in the php code as it's encrypted.

1
  • 2
    It's not possible as you describe it. If you provide more details as to your goal, we may be able to provide an alternate solution.
    – Warner
    Jul 2, 2010 at 18:42

3 Answers 3

2

Generally, no. Apache just runs your php (or whatever) code. The application can write to any directory the running user has write permission for (if you're using mod_php, then this user is the same user the webserver runs as).

1
  • How about at the filesystem level?
    – Travis
    Jul 2, 2010 at 17:55
1

Well, you could have a cron job periodically move the new files from the read directory to the write directory.

Or you could build a chroot environment for apache where everything was the same except that you mounted the write directory over the read directory. You could just bind mount the write directory over the read directory right now but if you have to shuffle many things about just go all the way to full chroot instead of later.

UPDATE: Using chroot on apache is visible only by apache while doing a bind mount only of write-over-read is visible by the the entire system.

0

It sounds like you want /var/www/read to be read-only. The technique is similar to that used for Linux LiveCDs. Use unionfs or aufs to divert writes at the filesystem level. Scientific Linux, a sibling of CentOS, comes with a kernel-module-aufs package.

You must log in to answer this question.