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
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
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.