LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-06-2010, 03:33 AM   #1
dpsh
LQ Newbie
 
Registered: Jul 2009
Posts: 12

Rep: Reputation: 0
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
 
Old 06-06-2010, 07:43 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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.
 
Old 06-06-2010, 09:29 AM   #3
dpsh
LQ Newbie
 
Registered: Jul 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 06-06-2010, 10:19 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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.
 
Old 06-06-2010, 12:41 PM   #5
dpsh
LQ Newbie
 
Registered: Jul 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Is it possible to disable the database module of php and then enable it only for some vhosts?
 
Old 06-06-2010, 01:43 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
  


Reply

Tags
apache, php, virtualhost



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
configuring php for apache PennyroyalFrog Linux - Newbie 3 02-07-2008 11:58 PM
Configuring Apache and PHP home_art Linux - General 1 04-11-2007 10:54 PM
configuring apache, php mjl3434 Linux - Software 4 09-22-2005 06:49 PM
Apache Virtualhosts + PHP error critical Linux - Software 3 08-03-2005 12:21 AM
Configuring php on apache Dakkar Linux - Software 5 06-01-2004 09:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration