LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Configuring php for virtualhosts in apache (https://www.linuxquestions.org/questions/linux-server-73/configuring-php-for-virtualhosts-in-apache-812423/)

dpsh 06-06-2010 03:33 AM

Configuring php for virtualhosts in apache
 
Hello,

I am using the virtualhosts feature of Apache web server to host multiple domains on a single web-server. Is it possible to have different settings for php for different domains?

For eg:- I have mydomain1.com and mydomain2.com hosted on the same server. I want php scripts of mydomain1.com to connect to database but prevent database access for scripts of mydomain2.com.
There are many php functions that I want to restrict for mydomain2.com.


Thanks

bathory 06-06-2010 07:43 AM

Hi,

You can change php settings per vhost, but what you want to do (connecting to a db) depends on the php code used in the 2 vhosts.
If you want to stop connecting to the db from server2, you should change (or remove) from server2 the php scripts where the db settings are defined.

dpsh 06-06-2010 09:29 AM

The problem is that the php scripts of the websites hosted on the server is not under my control. Each website (vhost) has a different admin who maintains the scripts. It is not possible for me to monitor the code. The only option for me is to prevent execution of the functions even if it is used in the code.

bathory 06-06-2010 10:19 AM

I'm afraid you cannot disable a database connect function from apache configuration. It can be done from php.ini and in this case it's global.
The only thing that comes in mind, is to disable php for server2 using
Code:

php_flag engine off
in a .htaccess in the docroot of server2, or inside the vhost2 definition in httpd.conf.
Of course this will stop parsing all php pages and will break vhost2 if it's written in php.

dpsh 06-06-2010 12:41 PM

Is it possible to disable the database module of php and then enable it only for some vhosts?

bathory 06-06-2010 01:43 PM

Quote:

Is it possible to disable the database module of php and then enable it only for some vhosts?
No, unless you install a second php instance, that does not support any database


All times are GMT -5. The time now is 04:15 AM.