Webapp-config

From Gentoo Wiki
Jump to:navigation Jump to:search
Resources


webapp-config is Gentoo's installer for web-based applications. It is used for automatic setup of web applications in virtual hosting environments. Originally written as a bash script, webapp-config is now Python-based and available in the Gentoo ebuild repository.

Concepts

webapp-config is aimed at providing the package management functionality that web server administrators need when running multiple web sites off of the same IP address (virtual hosting).

Two-stage install

Package managers such as RPM and Portage are designed to install one copy of a package, and to install it onto a fixed location. This conflicts with the needs of a virtual hosting environment, where administrators need to be able to install one package in multiple places so that it can be part of more than one website. With that being said, package managers are essential for maintaining an operating system over time - how is it possible to have the best of both worlds?

The answer is a two-stage install. The traditional package manager installs a master copy into /usr/share/webapps/ This master copy is not fit to run - but it is ready to be used by the webapp-config utility to install a single package multiple times in multiple places.

Multiple installations of the same package

webapp-config allows the administrator to install multiple copies of the same package on the same system at the same time. The administrator decides which directories to install each copy into.

In the web application world, these multiple installations are called "virtual copies".

Different versions of the same package can be installed on the same system at the same time. This allows web administrators to gradually roll out a new version of a package across sites; they are not forced to upgrade every site at once.

webapp-config minimizes the number of duplicated files to the absolute minimum. This keeps disk space usage low. The majority of files are hard linked to the master copy; only configuration files, and any files that the package needs to write to are copied into the virtual copy.

File ownership and permissions

Administrators who are used to installing web-based applications by hand will know that it can be a pain to get every file owned by the correct user, and with the correct permissions. Some files need to be owned by the user that the web server runs as. Others need to be owned by specific shell accounts, so that those users can login and edit the configuration files. If the Linux distribution offers a choice of web servers - each running under a different user - even the installers can struggle to get it right.

With webapp-config, the administrator tells the installer which web server to use and which shell account needs to be able to edit the configuration files. webapp-config then installs the files with the correct ownership and permissions.

Protected configuration files

webapp-config automatically ensures that configuration files are never overwritten during an upgrade - even if the files have not been edited since the original installation. Additionally, webapp-config will never overwrite any file that it did not install, or that has been changed since it was installed by webapp-config. webapp-config uses MD5 check sums to determine whether a file has been changed or not. In the case of symbolic links, webapp-config will not replace a symlink that points to a different file.

When an upgrade does attempt to overwrite a protected file, webapp-config creates a ._cfg file with the new file inside. etc-update can be used to complete the install, just as a regular emerge.

File copying options

A virtual copy is built mostly by creating hard links to files under /usr/share/webapps. If a hard link cannot be created, the file is copied from /usr/share/webapps instead.

Hard links can only be created to files on the same file system. If /usr/share/webapps and /var/www on kept on different file systems, webapp-config cannot use hard links, and will be forced to copy the files instead.

There are three ways to get around the hard link problem.

The easiest way is to make /usr/share/webapps a symlink to a directory under /var/www. For most administrators, this will ensure that everything is on the same file system.

However, if the hosted websites are kept on separate file systems, then webapp-config is never going to be able to hard-link files.

As an alternative the --soft command-line option can be used. This tells webapp-config to create symbolic links instead of hard links. Symbolic links work across file systems.

The problem with using symbolic links is that some packages do not work when the virtual copy is made from symbolic links. Many users, and system administrators alas, have also complained that they find directories full of symbolic links confusing. For these reasons, symbolic links are not used by default in webapp-config any more.

The --copy command-line option can also be chosen. This particular switch tells webapp-config to directly copy the files from /usr/share/webapps/ instead of hard links. Copying directly works across file systems with the drawback of using more space. This may be desired instead of relying on symbolic links in order to separate the virtualhost files, which admins can then modify, and files in /usr/share/webapps/.

Virtual file voodoo

By default, the master copy contains the metadata that decides which files get linked into a virtual copy and which files do not. Files are either owned by the web server (server-owned), are configuration files (config-owned), or are linked in (virtual). Directories can be server-owned or config-owned, but most of the time they need to be just plain directories (default-owned) created inside the installation directory (set with the -d option). webapp-config provides a number of switches which allows for overriding the master copy's metadata - in the case the overriding is ever needed.

The --default-dirs and --virtual-files switches allow the administrator to decide what webapp-config will do if (respectively) a directory or a file is marked as being default or virtual. webapp-config can be instructed to make the directory or file any of the other choices - server-owned or config-owned - instead.

${ROOT}

webapp-config is intended to fully support ${ROOT}. For administrators unsure what that means see the emerge man page (man emerge).

Features

Using the vhost USE flag webapp-config is capable of managing the following applications:

Application Package Homepage Description
ampache www-apps/ampache http://www.ampache.org/ Ampache is a PHP-based tool for managing, updating and playing audio files via a web interface.
b2evolution www-apps/b2evolution http://www.b2evolution.net Multilingual multiuser multi-blog engine.
Bugzilla www-apps/bugzilla http://www.bugzilla.org Bugzilla is the Bug-Tracking System from the Mozilla project.
cgit www-apps/cgit http://git.zx2c4.com/cgit/about A fast web-interface for git repositories.
coppermine www-apps/coppermine http://coppermine.sourceforge.net/ Web picture gallery written in PHP with a MySQL backend.
cvsweb www-apps/cvsweb http://www.freebsd.org/projects/cvsweb.html WWW interface to a CVS tree
dokuwiki www-apps/dokuwiki http://wiki.splitbrain.org/wiki:dokuwiki DokuWiki is a simple to use Wiki aimed at a small company's documentation needs.
dragonflycms www-apps/dragonflycms http://dragonflycms.org A feature-rich open source content management system based off of PHP-Nuke 6.5
Drupal www-apps/drupal http://drupal.org/ PHP-based open-source platform and content management system.
egroupware www-apps/egroupware http://www.egroupware.org/ Web-based GroupWare suite.
eyeos www-apps/eyeos http://www.eyeos.org AJAX web-based desktop environment.
groupoffice www-apps/groupoffice http://group-office.sourceforge.net/ Group-Office is a powerful modular Intranet application framework.
Joomla www-apps/joomla http://www.joomla.org/ Joomla is a powerful Open Source Content Management System.
mantisbt www-apps/mantisbt http://www.mantisbt.org/ PHP/MySQL/Web based bugtracking system.
MediaWiki www-apps/mediawiki http://www.mediawiki.org The MediaWiki wiki web application (as used on wikipedia.org).
mirmon www-apps/mirmon http://people.cs.uu.nl/henkp/mirmon/ Simple webapp to monitor the status of mirrors.
Moodle www-apps/moodle http://moodle.org The Moodle Course Management System.
mythweb www-apps/mythweb http://www.mythtv.org PHP scripts intended to manage MythTV from a web browser.
Nextcloud www-apps/nextcloud https://nextcloud.com/ Web-based personal cloud that runs on your own server.
otrs www-apps/otrs http://otrs.org/ OTRS is an Open source Ticket Request System.
Owncloud www-apps/owncloud http://owncloud.org Web-based storage application where all your data is under your own control.
phpBB www-apps/phpBB http://www.phpbb.com/ phpBB is an open-source bulletin board package.
phpmp www-apps/phpmp http://www.musicpd.org/ phpMp is a client program for Music Player Daemon (mpd).
phpsysinfo www-apps/phpsysinfo http://rk4an.github.com/phpsysinfo/ phpSysInfo is a nice package that will display your system stats via PHP.
postfixadmin www-apps/postfixadmin http://postfixadmin.sourceforge.net Web Based Management tool for Postfix style virtual domains and users.
rutorrent www-apps/rutorrent https://github.com/Novik/ruTorrent ruTorrent is a front-end for the popular Bittorrent client rTorrent.
trac www-apps/trac http://trac.edgewall.com/ Trac is a minimalistic web-based project management, wiki and bug/issue tracking system.
tt-rss www-apps/tt-rss http://tt-rss.org/ Tiny Tiny RSS - A web-based news feed (RSS/Atom) aggregator using AJAX.
venus www-apps/venus http://intertwingly.net/code/venus/ A feed aggregator application.
viewvc www-apps/viewvc http://viewvc.org/ ViewVC, a web interface to CVS and Subversion.
wiliki www-apps/wiliki http://practical-scheme.net/wiliki/ WiLiKi is a lightweight Wiki engine written in and running on Gauche Scheme.
WordPress www-apps/wordpress http://wordpress.org/ Wordpress php and mysql based content management system (CMS).

Installation

USE flags

USE flags for app-admin/webapp-config Gentoo's installer for web-based applications

portage Propagate python_targets dependencies to sys-apps/portage

Emerge

Install webapp-config:

root #emerge --ask app-admin/webapp-config

Configuration

Web server setup

webapp-config needs to know which web server to host the installed applications with. Popular choices include:

Note
If a web server has not been set up previous to this step in the webapp-config process, do so before continuing to proceed through this article. Visit the links referenced above to install and configure the web server. Once the web server has been set up return to this article

Edit the following line in the /etc/vhosts/webapp-config file to set a web server. This example would be the correct modification to make if lighttpd (www-servers/lighttpd) was the web server of choice:

FILE /etc/vhosts/webapp-configSetting webapp-config's web server preference
vhost_server="lighttpd"

Usage

Actions

-I, --install
Activate install mode.
-U, --upgrade
Activate upgrade mode.
-C, --clean
Activate remove mode.

Examples

Note
For the following examples Owncloud will be used as the web application. Owncloud can be substituted with any of the applications listed in the table above.
Note
Replace the <version> placeholder with the web application version to action upon.

To install a webapp:

root #webapp-config -I owncloud <version>

To list installed webapps:

root #webapp-config --list-installs

To show installed webapps:

root #webapp-config --show-installed

To update a previously installed webapp:

root #webapp-config -U owncloud <version>

To remove an installed webapp:

root #webapp-config -C owncloud <version>

Troubleshooting

Ghost installs

Entries still exist when running webapp-config --list-installs when the files in /var/www/ directory have been deleted.

The trouble probably was generated from an improper deletion of a webapp. If the files in /var/www/ are manually deleted then the webapp-config program can become confused. Uninstalls should be managed by running webapp-config -C <application_name> <application_version>.

Uninstall webapp-config:

root #emerge --depclean --verbose app-admin/webapp-config

Once removed, delete any left over installation files that may be found in the /var/db/webapps/ directory.

root #rm -rf /var/db/webapps/

Reinstall webapp-config and run the command with the --list-installs. All ghost installs should be gone.