Jump to content
The Uniform Server Community

Tutorial: including virtual host configs (simple,real MultiServer)


BananaAcid
 Share

Recommended Posts

VHost includes

 

In general, any option can be overwritten at any place. That includes .htaccess files.

But:

The httpd.conf options usually apply generally unless they are marked for use with a special folder or location.

The .htaccess files are loaded on demand (on folder access) and apply only to the containing one and the subfolders (if defined), while overwriting the apache configuration options.

Be careful: htaccess options work on a "first found, first serves" basis. With several ReadmeName-s in a htaccess, only the first will be applied. Same for AddDescription. (Applies to same keys, in htaccess)

 

There is difference concerning the apache config. For example:

Listen 80
Listen 81

This will make apache listen to both ports, be be mapped to virtual hosts, directories and root folders (= Multiserver).

Having 2 ReadmeName-s in a row, only the first one serves.

ReadmeName footer1.txt  #this one will be selected to serve
ReadmeName footer2.txt   

 

That leads us to the following conclusion:

We must include our personal tweaks before the default options we want to overwrite.

But after the initialization: the options our tweaks base on. (definition of the http root dir, etc)

Usually (and VirtualHost related) includes can go to the bottom of the apache httpd.conf file (being appended) since the VHost part is at the end anyways and location stuff is personal so does not need to be overwriting anything.

 

 

Including

 

Not a lot of ppl know, that apache supports including, and with wildchars.

The includes can include others again. Like a /etc/default.conf could include example1, and apache could include that default.conf.

 

example 1:

include /etc/apache2/*.conf
include /etc/apache2/vhosts/*.*

For windows users:

the /etc folder is used for configuration files, for more then one, use a subfolder to contain them.

 

That reads pretty much as follows:

include all files ending in .conf from /etc/apache2/

and then include any files with any ending from include /etc/apache2/vhosts/

 

The first include would allow us to include personal settings like directory directives, special settings for specific folders.

The second include would allow us to get config files with any name like "forum.bananaacid.ath.cx". Easily distinguishing of virtual hosts by file name.

( i recomend clearedit. in its settings it can be associated with unknown filetypes )

 

A virtual host .conf could look like this: (example2)

/etc/apache2/vhosts/forum.bananaacid.ath.cx

Listen 80
<VirtualHost *:80>
ServerName forum.bananaacid.ath.cx
ServerAlias forum.bananaacid.kicks-ass.net

DocumentRoot /www-user/forum/www/

#PHPIniDir "/www-user/forum.cfg/"
#'----> use a specific php.ini file from that PHPIniDir, with modified options
#  '--> or use Location and php_admin_value to overwrite specific value

 <Location />
php_admin_value safe_mode_exec_dir  "/www-user/forum/"
php_admin_value open_basedir		"/www-user/forum/"
php_admin_value error_log		   "/www-user/forum/errors.log"
php_admin_value doc_root			"/www-user/forum"
php_admin_value user_dir			"/www-user/forum/www"
 </Location>

</VirtualHost>

if it would be a setup to a clients website, the ftp access for a client would be to /www-user/forum/ but the server would display only the stuff within forum/www/. The cgi bin would go to forum/cgi-bin

 

"Listen 80" adds the port to use for the forum (if not available allready). the forum will only be reachable by port 80. To take any port to listen to, use "<VirtualHost *>".

 

Specific settings are within the "Location" directive. In this case for PHP, so we do not need a special php.ini, since most php.ini settings are generally ok. We use "php_admin_value" to set any php.ini value. The ones defined here, restrict ANY access to the "users" folder specifically (in windows, this is wonderfull, since using access rights is a pain).

To get more details on the php_admin_value-s, open php.ini and look up the description about the open_basedir and the others.

 

 

Conclusion:

For any Virtual Host, add a file with a filename that represents that address best and add the above code (ecample2).

Change it suit your needs.

 

Remember:

MySQL allows different databases for different users! No need to load a whole new MySQL server into memory.

 

Any comments, and additional info on perl directives are welcome.

 

BananaAcid

Link to comment
Share on other sites

  • 2 months later...

Carefull:

 

DynDNS service disabled Wildcard for free accounts. (Virtual Hosts depend on this)

 

Use another service:

Dynamic DNS Provider List

 

Preferably DtDNS - they provide for free, unlike DynDNs, an Offline Page/redirect and Wildcard. All other options are pretty much the same (all ports forwarding, framed opening of target page, updater support)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...