How to specify priority (site name prefix of symlink in /etc/apache2/sites-enabled/) with a2ensite?
2 Answers
You cannot achieve what you are attempting to do with a2ensite
, as that tool contains special logic to identify when the default
site is being enabled, so that it names the symlink 000-default
. This is documented in the man page.
Nevertheless, a2ensite
is really just a glorified wrapper which creates symlinks in the appropriate location. Therefore, there is nothing to prevent you either:
- renaming the symlink after
a2ensite
has added it, to add the priority prefix number to specify the site load order - create the symlink yourself in the first instance, without using
a2ensite
, using a command to the effect ofln -s /etc/apache2/sites-available/<site> /etc/apache2/sites-enabled/nnn-<site>
, wherennn
is the priority you wish to set. Just remember to reload Apache after having done so - modifying the source code, although bear in mind this will give you a version of
a2ensite
which is out-of-line with other iterations in the main source tree, which could cause future upgrade difficulties (unless you get your changes merged upstream)
Unfortunately there is no such a possibility.
You need either to rename a symlink after a2ensite or to name your files in sites-enabled with priority prefixes.
a2ensite source code:
sub doit {
my $acton = shift;
my $prio = "";
if ( $obj eq 'site' && $acton eq 'default' ) {
$prio = '000-';
}
$prio is not modified anywhere else. You may modify the source code though. Not a good idea, but you can start with such a patch:
@@ -116,6 +116,13 @@
$prio = '000-';
}
+ if ( $obj eq 'site' )
+ {
+ print "Enter priority: ";
+ $prio = <STDIN>;
+ chomp $prio;
+ $prio .= '-';
+ }
my ( $conftgt, $conflink );
if ( $obj eq 'module' ) {
if ( $acton eq 'cgi' && threaded() ) {
You'll need to enter priority manually both when enable and disable a site.