HowTo/VHosts

Version 4 (modified by arneke, 5 years ago)

--

VHosts on Arachnia

Our setup currently relies on HTTP level routing, in the sense that we forward *.opengeo.org and *.geoserver.org to Arachnia and then proxy to the correct machine from there. This allows us to easily move services, and we are not dependent on DNS propagation to make changes.

A vhost (virtual host) is just a name for a service. When a browser retrieves a page, it first looks up the ip address of the server using DNS. But it then also includes the hostname in the request to the server, thus allowing one server to distinguish requests intended for different domains.

Adding a new vhost

  1. Make sure the domain points to arachnia.openplans.org's ip address. For *.opengeo.org and *.geoserver.org, this is already the case.
  1. In the directory /etc/httpd/vhosts.d/ copy template.txt to <incremented>_hostname_yourdomain_com.conf, where <incremented> is the next number if you look at existing configurations. e.g. cp /etc/httpd/vhosts.d/template.txt /etc/httpd/vhosts.d/97_hostname_yourdomain_com.conf
  1. Edit the ServerName and the paths in <incremented>_hostname_yourdomain_com.conf
  1. Ensure that /sites/hostname.yourdomain.com/htdocs exists, place a simple index.html there to check
  1. Reload Apache: /etc/init.d/httpd reload
  1. If you encounter errors, be sure to move your configuration file out of the directory. Otherwise Apache may fail to restart after log rotation.

PHP

PHP is now running under suexec and mod_fcgid. General information about the setup can be  found here. Please get help to set up new accounts, or have someone check it for you.

  1. Add a new user ( 650 < uid < 700) , corresponding group and shadow entry. The easiest is to look at existing entries in /etc/passwd , group , shadow
  2. Copy one of the directories in /sites/php-fcgi-scripts and correct name and owner/group for the new user.
  3. In the vhost configuration files, add the following after the DocumentRoot directive, replacing {username} and {groupname}
    	SuexecUserGroup {username} {groupname}
    	PHP_Fix_Pathinfo_Enable 1
    	DirectoryIndex index.php
    
  1. Add the following to the bottom of the <Directory> entry for the document root, replacing {username}
    		Options +ExecCGI
    		AddHandler fcgid-script .php
    		FCGIWrapper /sites/php-fcgi-scripts/{username}/php-fcgi-starter .php
    

Upgrading Apache

If apache is upgraded we need to replace suexec with one that has document root in /sites. This can be done by rebuilding the httpd SRPM, in /usr/local/src/ (modify the spec file and bump the version number). If you upgrade by accident, try overwriting /usr/sbin/suexec with /usr/sbin/bak.suexec