Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache Virtual host and the Include file 1

Status
Not open for further replies.

Oraclecat

IS-IT--Management
Jan 21, 2004
4
US
I'm new to this post and have an easy question on Virtual hosts and the include parameter.

1) I believe in higher versions of Apache you can use the Include parameter with virtual hosts?

2) If I use the Include parameter in virtual hosts only the virtual host will know about the files included correct (the main instance of Apache will have no clue)?

3) If the main instance of Apache has an Include file, will the virtual host know about it, or will it be sourced in and be able to reference it.

I'm hoping that the Apache main server/instance and all virtual hosts will be treated as there own entity.

I'm currently running 1.3.19 of Apache.

I'm trying to alleviate some missed steps in my trouble shooting process via this forum.

Thanks for your help!!
 
Includes take affect across the entire configuration.

If the CONTEXT of your include is a virtualhost then yes, only the vhost will know about it.

It is essentially a text replacement mechanism. So if you have

<VirtualHost blabla>
Include vhost1.txt
</VirtualHost

and vhost1.txt contains
DocumentRoot /www/

Your config file inside of apache now looks like

<VirtualHost blabla>
DocumentRoot /www/
</VirtualHost>

Hope that makes sense.
 
Siberian,

Thanks for your help!

Based on your statment then I can assume that only &quot;VirtualHost blabla&quot; will know about vhost1.txt

But if outside of the Virtual Host setting (bottom of Apache httpd.conf) there is another Include file (mainApache.txt) will both the &quot;main&quot; Apache server and the Virtual Host know about this include and read it? See below.

<VirtualHost blabla>
Include vhost1.txt
</VirtualHost

and vhost1.txt contains
DocumentRoot /www/

Your config file inside of apache now looks like

<VirtualHost blabla>
DocumentRoot /www/
</VirtualHost>


#Include file from Oraclecat
Include mainApache.txt
 
Correct, if your include is outside the vhost it gets read in the global context.

If it is inside the vhost it gets read in the vhost context.

 
Thanks again! This clears up a lot.

Is there anyway to keep what the virtual host reads and what is in the &quot;main&quot;/&quot;global context&quot; seperate.

The reason I ask is because I'm working with a purchased Application that provides an Apache server, and in their supplied httpd.conf file they have some Include files at the bottom (that chain to other include files).

I need to create some virtual hosts that will have their own include files and variables. Some of the variables that I need to define will be the same ones as what is defined in the &quot;global context&quot; include files at the bottom of the httpd.conf file (just with different values).

Is there any way to keep them seperate?

I'm currently running a seperate Apache server for each one and it is very cumbersome and resource intensive.

Last, which one takes precedence? If I define a variable in global context and then in the virual host I use the Include file and define the variable again with a different value will this value take precedence and overwrite the global context.

Thanks for the help
 
First off, virtual host always takes precedence. You can think of the global config as a 'default' and the vhost overrides.

Its important to note that if you do declare a vhost most global declarations are now OUT of scope. So you can not define something globally and then expect it to trickle into a vhost.

In terms of your application, you could try creating your own httpd.conf, creating a vhost for the application and then including the applications httpd.conf within your vhost and letting it chain out in that context.

 
Ok I followed some of the suggestion in this post and I must say they were very helpful. Now I'm encountering a problem and it seems that using vhosts may not be able to handle my situation, but I'm looking to this vast pool of knowledge for some solutions.

The below text shows my virtual host setups! The problem I'm having is that Apache only &quot;picks up&quot; the first &quot;SetEnv FORMS60_WEB_CONFIG_FILE&quot; in the Virtual host setup. It ignores the one in the &quot;main&quot; apache setup and the one in the &quot;second&quot; virtual host setup. It doesn't matter if I'm accessing the main Apache or Virtual host two (japan), it always uses the SetEnv FORMS60_WEB_CONFIG_FILE setting from the virtual host one configuration.

My need is to use the SetEnv FORMS60_WEB_CONFIG_FILE for V1 only when accessing V1 and V2 only when accessing V2 and the Main configuration setting only when accessing the main apache server. (NOTE: the end file names are different for the FORMS60_WEB_CONFIG_FILE settings below in each VirtualHost)

Is this possible??

# Begin customizations

NameVirtualHost 999.888.7.654

<VirtualHost australia>
ServerName australia
DocumentRoot &quot;/opt/mary/common/john/portal/wilbur_orville/final&quot;
SetEnv TWO_TASK australia_anz
SetEnv FORMS60_WEB_CONFIG_FILE /opt/mary/common/john/html/bin/appsweb_final_orville_anz.cfg
ServerAdmin mgr@dontknow.com
ErrorLog /opt/mary/product/john/iAS/Apache/Apache/logs/anz_error_log
TransferLog /opt/mary/product/john/iAS/Apache/Apache/logs/anz_access_log
</VirtualHost>

<VirtualHost japan>
ServerName japan
DocumentRoot &quot;/opt/mary/common/john/portal/wilbur_orville/final&quot;
SetEnv TWO_TASK japan_jp
SetEnv FORMS60_WEB_CONFIG_FILE /opt/mary/common/john/html/bin/appsweb_final_orville_jp.cfg
ServerAdmin mgr@dontknow.com
ErrorLog /opt/mary/product/john/iAS/Apache/Apache/logs/jp_error_log
TransferLog /opt/mary/product/john/iAS/Apache/Apache/logs/jp_access_log
</VirtualHost>
# End customizations

# **** And this setting is in the main Apache Configuration***
SetEnv FORMS60_WEB_CONFIG_FILE /opt/mary/common/john/html/bin/appsweb_final_orville_main_apach_config.cfg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top