New a2enpkg / a2dispkg script should be written - Improve virtual host configuration

Bug #122885 reported by Loye Young
2
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Fix Released
Wishlist
Unassigned

Bug Description

Binary package hint: apache2

I have a wishlist item for the community to consider.

The issue is what to do with packages that put their config files
 in /etc/apache2/conf.d. I'm talking about dwww, dpkg-www, roundcube, etc.
 Because ./conf.d gets read before ./sites-enabled, the configurations
 in ./conf.d can end up overriding ./sites-enabled/000-default. Also the conf
 files in /etc/apache2/conf.d affect all sites, which isn't necessarily what
 is intended.

I usually end up moving them to /etc/apache2/sites-available to avoid the
 problem and soI can toggle them on and off with a2ensite. But more thought
 should be given to this for the regular automated installation.

What I would like is a new script a2enpkg and a2dispkg that operate similarly
to a2ensite / a2dissite and a2enmod / a2dismod.

Each site should get a subdirectory in ./sites-available so that conf
 files can be separately maintained for each site. a2ensite would do
 essentially as it does now, but the include statement in apache2.conf would
 be recursive.

I'm thinking we'd treat the various packages something like the sites, with
 a ./pkg-available directory. A new script "a2enpkg" that would copy the
 pkg.conf file to the site's subdirectory.

E.g.,
./conf.d/ # for things affect everything on the server
 ./conf.d/charset
 ./conf.d/portmap

[snip modules stuff]

./pkg-available/ # packages available to virtual server
 ./pkg-available/dwww.conf
 ./pkg-available/dpkg-www.conf
 ./pkg-available/drupal.conf
 ./pkg-available/mediawiki.conf
 ./pkg-available/mydms.conf
 ./pkg-available/roundcube.conf

./sites-available/default/
 ./sites-available/default/default.conf
 ./sites-available/default/dwww.conf --> ./pkg-available/dwww.conf
 ./sites-available/default/dpkg-www.conf --> ./pkg-available/dpkg-www.conf
 ./sites-available/site1.com/
 ./sites-available/site1.com/roundcube.conf --> ./pkg-available/roundcube.conf
 ./sites-available/site1.com/drupal.conf --> ./pkg-available/drupal.conf
 ./sites-available/site2.com/
 ./sites-available/site2.com/mydms.conf --> ./pkg-available/mydms.conf
 ./sites-available/site2.com/mediawiki.conf --> ./pkg-available/mediawiki.conf
 ./sites-available/site3.com/
 ./sites-available/site3.com/drupal.conf --> ./pkg-available/drupal.conf

./sites-enabled/000-default --> ./sites-available/default
 ./sites-enabled/site1.com --> ./sites-available/site1.com/
 ./sites-enabled/site2.com --> ./sites-available/site2.com/
 ./sites-enabled/site3.com --> ./sites-available/site3.com/

a2enpkg would act something like this:
What package do you want to enable? Choices are:
 dwww dpkg-www drupal mediawiki mydms roundcube
 -> mydms roundcube
 For which sites do you want to enable the packages? Choices are:
 default site1 site2 site3 new
 --> new
 What is the name of the new site?
 --> site4.com
 Creating new directory site4 in ./sites-available . . . .
 Directory ./sites-available/site4.com/ created.
 Do you want to keep the default configurations or specially configure mydms?
 --> default
 Creating symlink in site4 to mydms.conf . . . .
 Do you want to keep the default configurations or specially configure
 roundcube?
 --> special
 Copying roundcube.conf to site4 . . . .
 When you are ready to enable site4.com, run a2ensite.
 Done.

The added file structure would look like this:
 ./sites-available/site4.com/
 ./sites-available/site4.com/mydms.conf --> ./pkg-available/mydms.conf
 ./sites-available/site4.com/roundcube.conf

In this way, the functionality of the server would become modular in the same
 way as the sites and the modules. It would allow an admin to install a new
 package and get it configured before turning it on with a2enpkg. Similarly,
 a2dispkg would turn off the functionality for a particular site quickly and
 easily.

From what I've seen of the a2ensite and a2enmod scripts, it should be fairly easy to
adapt that code to this idea.

Of course, everything will work the way it is, so it's not anything to kill
 ourselves over. But I'd be interested in what others think about the idea.

Revision history for this message
Mathias Gug (mathiaz) wrote :

Thank you for your suggestion.

a2enpkg and a2dispkg are scripts developed by the apache2 debian maintainers. The feature change you're proposing should also be discussed with them. Opening a bug in the Debian But Track system could be the first step in that direction.

Changed in apache2:
importance: Undecided → Wishlist
Revision history for this message
Soren Hansen (soren) wrote :

Mathias: Huh? Do these tools already exist?

Revision history for this message
Thom May (thombot) wrote :

No, they don't. And, IMHO, they shouldn't. This adds a lot of complexity for a fairly edge case.

Mathias Gug (mathiaz)
Changed in apache2:
status: New → Triaged
Revision history for this message
Loye Young (loyeyoung) wrote :

>a fairly edge case.
I don't know what survey was taken that leads you to that conclusion, I have a hard time believing that I'm the only one who hosts sites for third parties.

I host websites for customers, each of whom have different preferences for what they want in their domain. Several packages install their config files in /etc/apache2/conf.d. When that happens, the installed packages suddenly become a part of every site that is hosted on that box. In some cases, that makes for very bad results.

Good example is drupal, which is an extremely popular CMS. It sets itself up in as /etc/apache2/conf.d/drupal.conf. The following is the contents:
[code]
Alias /drupal /usr/share/drupal5
Alias /drupal5 /usr/share/drupal5

<Directory /usr/share/drupal5/>
 Options +FollowSymLinks
 AllowOverride All
 order allow,deny
 allow from all
</Directory>
[/code]

If the configuration stays like that, every virtual host on the box will end up with a drupal site, whether the customer knows it or not. Worse, the first person to browse to http://myvirtualhostcustomer.com/drupal will be able to set up the drupal site with themself as the administrator.

Here's a partial list of other packages that install themselves in /etc/apache2/conf.d. (I'm sure there are more; these are the ones I know about. )
apt-cacher
dpkg-www
dwww
gallery2
phpmyadmin
darcsweb
debian-edu-config
apache2-doc
fai-doc
knowledgeroot
lwat
sitesummary
slbackup-php
sympa

I think that writing the script to implement what I have suggested would not be difficult. It would, however, require a consensus and adoption as an extension to the Debian standard for Apache directory organization.

Revision history for this message
Robie Basak (racb) wrote :

The conf.d mechanism was revamped in the packaging for Apache 2.4. It's now moved to conf-available, and the mechanisms for using these pieces have substantially changed.

Thus, I think this bug is either fixed or superceded. If you think that something still needs to be changed, then please explain in light of the new mechanism and re-open accordingly.

But, as Mathias said in 2007, we would only make changes through Debian, so do not expect to make any progress in Ubuntu with just this bug here. Somebody needs to push for any changes through the Debian BTS.

Revision history for this message
Robie Basak (racb) wrote :

Some details of the new mechanism in 2.4 packaging is here: https://wiki.debian.org/Apache/PackagingFor24

Changed in apache2 (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.