Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a Ubuntu server, I have a database file under a user's home directory, specifically /home/pistacchio/lessico/mydatabase.db. Apache works under the group www-data. What is the best way to grant access to that file to Apache? Thanks

share|improve this question
up vote 1 down vote accepted

not sure why someone gave you a -1.... but here's some food-for-thought on the subject.

If you're trying to have a database-driven website, Apache does not need access to the database files directly. Typically, apache relies on a module for a specific programming language (php, perl, python, bash, cgi, etc...) to access a database server, which in-turn access the files making changes on the fly as needed. File-based databases that do not rely on a dedicated "server" do exist, but in a multi-threaded environment can run into problems. (look up "race-conditions" if you want more info on this)

If you're trying to do some sort of backup of the files directly... you're going about it all wrong. If the database files are mounted to an active database server, at any moment and for a variety of reasons, those files will be changed. If you're trying to download/copy/whatever a file that is constantly changing... you're probably going to end up with broken downloads or corrupted downloads. There's several steps that need to be performed to "lock" the database to prevent writes for the period while you're copying it... or you need to look at database backup-tools like "mysqldump" to create a dump of the database... and then back that up. You can also look at volume snapshots... where you can create a "snapshot" of the current state of the file, and then download the snapshot rather than the ever-changing version.

If you're still set on trying to download the database files directly, you can create a symbolic link to the file within the web-root someplace, and then ensure the permissions are set (probably on the group or everyone bits) to allow the user Apache is running as to have access to those files. You can also use frameworks like suphp (not recommended) to execute php sessions as another user.

share|improve this answer
thank you for you answer. the reason i got a -1, i think, is because i myself gave a -1 to a user that just posted "check chmod" and that's it. he later on removed the answer. thanks for yours, by the way – pistacchio Feb 3 '12 at 19:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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