e7a395
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
e7a395
index fb3f4f3..7dde965 100644
e7a395
--- a/Mailman/Defaults.py.in
e7a395
+++ b/Mailman/Defaults.py.in
e7a395
@@ -1431,20 +1431,22 @@ AuthListPoster = 6    # List poster (Approved: <pw> header in posts only)
e7a395
 
e7a395
 # Useful directories
e7a395
 LIST_DATA_DIR   = os.path.join(VAR_PREFIX, 'lists')
e7a395
-LOG_DIR         = os.path.join(VAR_PREFIX, 'logs')
e7a395
-LOCK_DIR        = os.path.join(VAR_PREFIX, 'locks')
e7a395
+LOG_DIR         = '@LOG_DIR@'
e7a395
+LOCK_DIR        = '@LOCK_DIR@'
e7a395
+CONFIG_DIR      = '@CONFIG_DIR@'
e7a395
 DATA_DIR        = os.path.join(VAR_PREFIX, 'data')
e7a395
+PID_DIR         = '@PID_DIR@'
e7a395
 SPAM_DIR        = os.path.join(VAR_PREFIX, 'spam')
e7a395
 WRAPPER_DIR     = os.path.join(EXEC_PREFIX, 'mail')
e7a395
 BIN_DIR         = os.path.join(PREFIX, 'bin')
e7a395
 SCRIPTS_DIR     = os.path.join(PREFIX, 'scripts')
e7a395
-TEMPLATE_DIR    = os.path.join(PREFIX, 'templates')
e7a395
+TEMPLATE_DIR    = '@TEMPLATE_DIR@'
e7a395
 MESSAGES_DIR    = os.path.join(PREFIX, 'messages')
e7a395
 PUBLIC_ARCHIVE_FILE_DIR  = os.path.join(VAR_PREFIX, 'archives', 'public')
e7a395
 PRIVATE_ARCHIVE_FILE_DIR = os.path.join(VAR_PREFIX, 'archives', 'private')
e7a395
 
e7a395
 # Directories used by the qrunner subsystem
e7a395
-QUEUE_DIR       = os.path.join(VAR_PREFIX, 'qfiles')
e7a395
+QUEUE_DIR       = '@QUEUE_DIR@'
e7a395
 INQUEUE_DIR     = os.path.join(QUEUE_DIR, 'in')
e7a395
 OUTQUEUE_DIR    = os.path.join(QUEUE_DIR, 'out')
e7a395
 CMDQUEUE_DIR    = os.path.join(QUEUE_DIR, 'commands')
e7a395
@@ -1458,9 +1460,9 @@ RETRYQUEUE_DIR  = os.path.join(QUEUE_DIR, 'retry')
e7a395
 MAILDIR_DIR     = os.path.join(QUEUE_DIR, 'maildir')
e7a395
 
e7a395
 # Other useful files
e7a395
-PIDFILE = os.path.join(DATA_DIR, 'master-qrunner.pid')
e7a395
-SITE_PW_FILE = os.path.join(DATA_DIR, 'adm.pw')
e7a395
-LISTCREATOR_PW_FILE = os.path.join(DATA_DIR, 'creator.pw')
e7a395
+PIDFILE = os.path.join(PID_DIR, 'master-qrunner.pid')
e7a395
+SITE_PW_FILE = os.path.join(CONFIG_DIR, 'adm.pw')
e7a395
+LISTCREATOR_PW_FILE = os.path.join(CONFIG_DIR, 'creator.pw')
e7a395
 
e7a395
 # Import a bunch of version numbers
e7a395
 from Version import *
e7a395
diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py
e7a395
index 801ddc0..8506b9b 100644
e7a395
--- a/Mailman/MTA/Postfix.py
e7a395
+++ b/Mailman/MTA/Postfix.py
e7a395
@@ -32,8 +32,8 @@ from Mailman.MTA.Utils import makealiases
e7a395
 from Mailman.Logging.Syslog import syslog
e7a395
 
e7a395
 LOCKFILE = os.path.join(mm_cfg.LOCK_DIR, 'creator')
e7a395
-ALIASFILE = os.path.join(mm_cfg.DATA_DIR, 'aliases')
e7a395
-VIRTFILE = os.path.join(mm_cfg.DATA_DIR, 'virtual-mailman')
e7a395
+ALIASFILE = os.path.join(mm_cfg.CONFIG_DIR, 'aliases')
e7a395
+VIRTFILE = os.path.join(mm_cfg.CONFIG_DIR, 'virtual-mailman')
e7a395
 
e7a395
 try:
e7a395
     True, False
e7a395
diff --git a/Makefile.in b/Makefile.in
e7a395
index eb40844..289aeee 100644
e7a395
--- a/Makefile.in
e7a395
+++ b/Makefile.in
e7a395
@@ -28,6 +28,12 @@ bindir=		@bindir@
e7a395
 prefix=		@prefix@
e7a395
 exec_prefix=	@exec_prefix@
e7a395
 var_prefix=	@VAR_PREFIX@
e7a395
+configdir=	@CONFIG_DIR@
e7a395
+lockdir=	@LOCK_DIR@
e7a395
+logdir=		@LOG_DIR@
e7a395
+piddir=		@PID_DIR@
e7a395
+queuedir=	@QUEUE_DIR@
e7a395
+templatedir=	@TEMPLATE_DIR@
e7a395
 DESTDIR=
e7a395
 
e7a395
 CC=		@CC@
e7a395
@@ -41,8 +47,11 @@ DEFS=		@DEFS@
e7a395
 OPT=		@OPT@
e7a395
 CFLAGS=		@CFLAGS@ $(OPT) $(DEFS)
e7a395
 
e7a395
+FHS_DIRS= \
e7a395
+	${configdir} ${lockdir} ${logdir} ${piddir} ${queuedir} ${templatedir}
e7a395
+
e7a395
 VAR_DIRS= \
e7a395
-	logs archives lists locks data spam qfiles \
e7a395
+	archives lists data spam \
e7a395
 	archives/private archives/public
e7a395
 
e7a395
 ARCH_INDEP_DIRS= \
e7a395
@@ -105,6 +114,15 @@ doinstall: $(SUBDIRS)
e7a395
 	    else true; \
e7a395
 	    fi; \
e7a395
 	done
e7a395
+	@for d in $(FHS_DIRS); \
e7a395
+	do \
e7a395
+	    dir=$(DESTDIR)/$$d; \
e7a395
+	    if test ! -d $$dir; then \
e7a395
+		echo "Creating directory $$dir"; \
e7a395
+		$(INSTALL) -d -m $(DIRMODE) $$dir; \
e7a395
+	    else true; \
e7a395
+	    fi; \
e7a395
+	done
e7a395
 	chmod o-r $(DESTDIR)$(var_prefix)/archives/private
e7a395
 	@for d in $(ARCH_INDEP_DIRS); \
e7a395
 	do \
e7a395
diff --git a/bin/check_perms b/bin/check_perms
e7a395
index 137ebfb..1f45f84 100755
e7a395
--- a/bin/check_perms
e7a395
+++ b/bin/check_perms
e7a395
@@ -183,7 +183,8 @@ def checkall():
e7a395
         print _('checking mode for %(prefix)s')
e7a395
     dirs = {}
e7a395
     for d in (mm_cfg.PREFIX, mm_cfg.EXEC_PREFIX, mm_cfg.VAR_PREFIX,
e7a395
-              mm_cfg.LOG_DIR):
e7a395
+              mm_cfg.CONFIG_DIR, mm_cfg.DATA_DIR, mm_cfg.LOCK_DIR,
e7a395
+              mm_cfg.LOG_DIR, mm_cfg.QUEUE_DIR, mm_cfg.PID_DIR):
e7a395
         dirs[d] = True
e7a395
     for d in dirs.keys():
e7a395
         try:
e7a395
diff --git a/configure.in b/configure.in
e7a395
index f2eb1c0..c01129c 100644
e7a395
--- a/configure.in
e7a395
+++ b/configure.in
e7a395
@@ -305,6 +305,72 @@ else
e7a395
     prefixcheck=$VAR_PREFIX
e7a395
 fi
e7a395
 
e7a395
+# Get the configuration file directory
e7a395
+AC_SUBST(CONFIG_DIR)
e7a395
+AC_MSG_CHECKING(for --with-config-dir)
e7a395
+AC_ARG_WITH(config-dir, dnl
e7a395
+[  --with-config-dir    specify directory for configuration data other than [VAR_]PREFIX/data])
e7a395
+case "$with_config_dir" in
e7a395
+    yes|no|"") CONFIG_DIR="$VAR_PREFIX/data";;
e7a395
+    *)         CONFIG_DIR=$with_config_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($CONFIG_DIR)
e7a395
+
e7a395
+# Get the lock directory
e7a395
+AC_SUBST(LOCK_DIR)
e7a395
+AC_MSG_CHECKING(for --with-lock-dir)
e7a395
+AC_ARG_WITH(lock-dir, dnl
e7a395
+[  --with-lock-dir    specify directory for lock files other than [VAR_]PREFIX/locks])
e7a395
+case "$with_lock_dir" in
e7a395
+    yes|no|"") LOCK_DIR="$VAR_PREFIX/locks";;
e7a395
+    *)         LOCK_DIR=$with_lock_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($LOCK_DIR)
e7a395
+
e7a395
+# Get the log directory
e7a395
+AC_SUBST(LOG_DIR)
e7a395
+AC_MSG_CHECKING(for --with-log-dir)
e7a395
+AC_ARG_WITH(log-dir, dnl
e7a395
+[  --with-log-dir    specify directory for log files other than [VAR_]PREFIX/logs])
e7a395
+case "$with_log_dir" in
e7a395
+    yes|no|"") LOG_DIR="$VAR_PREFIX/logs";;
e7a395
+    *)         LOG_DIR=$with_log_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($LOG_DIR)
e7a395
+
e7a395
+# Get the pid directory
e7a395
+AC_SUBST(PID_DIR)
e7a395
+AC_MSG_CHECKING(for --with-pid-dir)
e7a395
+AC_ARG_WITH(pid-dir, dnl
e7a395
+[  --with-pid-dir    specify directory for the pid file other than [VAR_]PREFIX/data])
e7a395
+case "$with_pid_dir" in
e7a395
+    yes|no|"") PID_DIR="$VAR_PREFIX/data";;
e7a395
+    *)         PID_DIR=$with_pid_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($PID_DIR)
e7a395
+
e7a395
+# Get the queue directory
e7a395
+AC_SUBST(QUEUE_DIR)
e7a395
+AC_MSG_CHECKING(for --with-queue-dir)
e7a395
+AC_ARG_WITH(queue-dir, dnl
e7a395
+[  --with-queue-dir    specify directory for queue files other than [VAR_]PREFIX/qfiles])
e7a395
+case "$with_queue_dir" in
e7a395
+    yes|no|"") QUEUE_DIR="$VAR_PREFIX/qfiles";;
e7a395
+    *)         QUEUE_DIR=$with_queue_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($QUEUE_DIR)
e7a395
+
e7a395
+# Get the template directory
e7a395
+AC_SUBST(TEMPLATE_DIR)
e7a395
+AC_MSG_CHECKING(for --with-template-dir)
e7a395
+AC_ARG_WITH(template-dir, dnl
e7a395
+[  --with-template-dir    specify directory for template files other than [VAR_]PREFIX/templates])
e7a395
+case "$with_template_dir" in
e7a395
+    yes|no|"") TEMPLATE_DIR="$VAR_PREFIX/templates";;
e7a395
+    *)         TEMPLATE_DIR=$with_template_dir;;
e7a395
+esac
e7a395
+AC_MSG_RESULT($TEMPLATE_DIR)
e7a395
+
e7a395
 # new macro for finding group names
e7a395
 # returns a comma separated list of quoted group names
e7a395
 # the list is returned in the same order as specified with any duplicates removed
e7a395
diff --git a/misc/Makefile.in b/misc/Makefile.in
e7a395
index af99c04..df50a06 100644
e7a395
--- a/misc/Makefile.in
e7a395
+++ b/misc/Makefile.in
e7a395
@@ -27,6 +27,12 @@ bindir= 	@bindir@
e7a395
 prefix=   	@prefix@
e7a395
 exec_prefix=	@exec_prefix@
e7a395
 var_prefix=	@VAR_PREFIX@
e7a395
+configdir=	@CONFIG_DIR@
e7a395
+lockdir=	@LOCK_DIR@
e7a395
+logdir=		@LOG_DIR@
e7a395
+piddir=		@PID_DIR@
e7a395
+queuedir=	@QUEUE_DIR@
e7a395
+MAILMAN_GROUP=  @MAILMAN_GROUP@
e7a395
 DESTDIR=
e7a395
 
e7a395
 CC=		@CC@
e7a395
@@ -87,7 +93,7 @@ install-other:
e7a395
 	    $(INSTALL) -m $(FILEMODE) paths.py $$dir; \
e7a395
 	done
e7a395
 	$(INSTALL) -m $(EXEMODE) mailman $(DESTDIR)$(SCRIPTSDIR)
e7a395
-	$(INSTALL) -m $(FILEMODE) sitelist.cfg $(DESTDIR)$(DATADIR)
e7a395
+	$(INSTALL) -m $(FILEMODE) sitelist.cfg $(DESTDIR)$(configdir)
e7a395
 
e7a395
 install-packages:
e7a395
 	if [ -z "$(EMAILPKG)" -a -d $(DESTDIR)$(PYTHONLIBDIR)/email ] ; \
e7a395
diff --git a/templates/Makefile.in b/templates/Makefile.in
e7a395
index b23d7c1..16930a2 100644
e7a395
--- a/templates/Makefile.in
e7a395
+++ b/templates/Makefile.in
e7a395
@@ -25,6 +25,7 @@ srcdir= 	@srcdir@
e7a395
 bindir= 	@bindir@
e7a395
 prefix=   	@prefix@
e7a395
 exec_prefix=	@exec_prefix@
e7a395
+template_dir=   @TEMPLATE_DIR@
e7a395
 DESTDIR=
e7a395
 
e7a395
 CC=		@CC@
e7a395
@@ -37,7 +38,7 @@ DEFS=   	@DEFS@
e7a395
 
e7a395
 OPT=		@OPT@
e7a395
 CFLAGS=		$(OPT) $(DEFS)
e7a395
-TEMPLATEDIR= 	$(prefix)/templates
e7a395
+TEMPLATEDIR= 	$(template_dir)
e7a395
 
e7a395
 SHELL=		/bin/sh
e7a395