I have a dedicated server, on this server i have two vhosts. and i will give the access of the server to two people. In my php file there's the database password and i don't want to share that with them. So how can i protect the php file from reading? If i do a chmod 700 apache2 can not read and the page is "Forbidden". Thanks and good night
In order to use the data, it must be readable by the webserver uid - which means that anyone whom can deploy PHP code on the server can read the files. This is true of all web programming languages.
PHP is unusual in that it does provide mechanisms for partitioning shared access on a webserver
If you've got root access, then you can setup permissions on the file so that apache (and thus php) can read it using a supplementary group; and prevent the two "users" from reading it.
Without knowing about your OS variant; something like the following process should work. Testing is of course mandatory.
You will need to restart Apache to acquire the new supplementary groups.