Web Server Configuration

Recite CMS provides built-in functionality to help you manage the configuration of your web server. This can be extremely useful, since Recite CMS requires the a number of web sites are configured to operate. Aside from the administration site, you also need at least one Control Panel site and at least one client site.

Recite CMS helps this process by generating configuration files whenever Control Panel or client domains are modified and writing them to a special directory in your installation (the ./data/conf directory). A separate configuration file is generated for each branding and client. You can then set up your web server to monitor for changes in the directory and load them into your server as required.

Manual Web Server Configuration

If you don't want Recite CMS to automatically generate web server configurations you can still use the web server configuration section to help you manually configure your web server.

Open the Web Server Configuration section from the System menu tab.

This page lists the paths on the server filesystem that you need to use for manually configuring the web server.

Managing Configuration Templates

You can control the base template that is used for generating web server configurations. This can be controlled at both the brand and client level.

In the brand settings you can specify a default template to use for clients belonging to that brand. If you have a single client that requires a different configuration you can then override the configuration just for that client.

To manage the web server templates for the brand, go to the settings page for the respective brand and load the Global Settings bundle. You will then see a field for the brand template. This field is used for Control Panel domains. The Client VirtualHost Template setting is used for any clients created on the brand.

Note

The default templates provided with Recite CMS generate <VirtualHost> directives that are compatible with Apache HTTP Server.

If you want a different template for a particular client, open the settings page for that client and load the Global Settings bundle. If this field is blank then Recite CMS will check for the setting stored with the brand. Enter your required template here so Recite CMS uses that instead.

Brand Template Variables

There are a number of different variables available for creating web server configurations for brands. These are as follows.

  • $title - This is the title of the branding as it appears in the administration site.

  • $id - This is Recite CMS' internal ID number for the branding.

  • $domain - This is the primary domain for the Control Panel. If the brand has no domains set then this value will be empty.

  • $domains - This is an array of any other Control Panel domains.

  • $docroot - This is full file system path to the Control Panel web root.

  • $logroot - This is full file system path to the Recite CMS logs directory.

  • $ip - This is the IP address of the server. If your server uses multiple IP addresses then you may need to hard code the IP address instead of using this variable.

Client Template Variables

There are a number of different variables available for creating web server configurations for clients. These are as follows.

  • $title - This is the title of the client as it appears in the administration site.

  • $id - This is Recite CMS' internal ID number for the client.

  • $client - This is normalized string version of the client name. It is the client name but with only lower-case characters and hyphens instead of other characters (e.g. Recite CMS would become recite-cms).

  • $domain - This is the primary domain for the client web site. If the client has no domains set then this value will be empty.

  • $domains - This is an array of any other client domains.

  • $davdomain - This is the primary WebDAV domain for the client web site. If the client has no domains set then this value will be empty.

  • $davdomains - This is an array of any other WebDAV domains.

  • $docroot - This is full file system path to the client web site web root.

  • $davdocroot - This is full file system path to the client WebDAV site web root.

  • $logroot - This is full file system path to the Recite CMS logs directory.

  • $ip - This is the IP address of the server. If your server uses multiple IP addresses then you may need to hard code the IP address instead of using this variable.

Controlling Brands and Clients

Once you have configured the web server templates you must then decide which brands and clients you want to automatically build web server configurations for.

When a brand or client is created they are set by default not to auto-build a configuration file. Each time you create a new brand or client you must add them to the list to auto-build.

To manage this list, visit the Web Server Configuration section in the system maintenance area of the Recite CMS administration site.

Figure 9.2. The web server configuration page.

The web server configuration page.

On this page you must manually select which brands and clients to auto-configure. Check the box beside each brand or client that you want to auto-configure, then click Save and Rebuild All.

Tip

You can also enable this setting for each brand or client when you add a domain. Checking the Automatic web server config option when adding the domain will add them to list.

Automatically Restarting Your Web Server

You can set up Recite CMS to automatically restart your web server whenever client or brand domains change.

Whenever a configuration file is modified (typically as a result of adding or removing a domain), an empty file called recite.lock is created in the ./data/conf directory in your Recite CMS installation.

You can use the ./application/tools/maintenance/confwatch.php script to watch for this file and automatically trigger a web server restart.

Note

This only supports Apache HTTP Server currently. It relies on a standard management script (such as apachectl) that has the configtest and graceful commands.

When the recite.lock file is detected, the script will first check that the new configuration is valid, and if so it will gracefully restart your web server.

The script accepts as its first argument the full path to the web server controller script. The second argument must be the base path of your Recite CMS installation.

You can add this script your crontab. To schedule it to run every minute, use the following command. This assumes you have Recite CMS installed in /var/www/recite and that the apachectl command is found in /usr/local/apache/bin.

Tip

Another common location is /etc/rc.d/init.d/httpd

Example 9.1. Crontab line for auto-restarting web server

* * * * * /var/www/recite/application/tools/maintenance/confwatch.php /usr/local/apache/bin/apachectl /var/www/recite 1> /dev/null 2>/dev/null

Tip

If you have multiple Recite CMS installations, you don't need to set up a new crontab for every installation you want to watch web server configurations for. Simply append subsequent Recite CMS paths to the above command.