views:

31

answers:

1

I have a package that is using the autotools to build and install. Part of the package is a website that can be run on the local machine. So in the package there is a .conf file that is meant to be either copied or linked to the /etc/apache2/conf.d directory. What's the standard way that packages would do this? If possible, I'd like for the user not to have an extra step to make the website work. I'd like to have them install the package and then be able to browse to http://localhost/newpackage to get up and running.

Also, is there a way that autoconf knows about the apache install or a standard way through then environment some how? If someone could point me in the right direction that would be great.

Steve

+1  A: 

The first thing you should do is to locate the apache extension tool apxs or apxs2 (depends on apache version and/or platform you are building for). After you know where your tool is located you can run queries to get certain apache config params. For example to get system config dir you can run:

apxs2 -q SYSCONFDIR

Here is a snippet of how you can locate apache extension tool: (be careful it may contain syntax errors)

dnl Note: AC_DEFUN goes here plus other stuff

AC_MSG_CHECKING(for apache APXS)
AC_ARG_WITH(apxs,
            [AS_HELP_STRING([[--with-apxs[=FILE]]],
                            [path to the apxs, defaults to "apxs".])],
[
    if test "$withval" = "yes"; then
      APXS=apxs
    else
      APXS="$withval"
    fi
])

if test -z "$APXS"; then
  for i in /usr/sbin /usr/local/apache/bin /usr/bin ; do
    if test -f "$i/apxs2"; then
      APXS="$i/apxs2"
      break
    fi
    if test -f "$i/apxs"; then
      APXS="$i/apxs"
      break
    fi
  done
fi
AC_SUBST(APXS)

The way to use APXS in your automake Makefile.am would look something like this:

## Find apache sys config dir
APACHE2_SYSCONFDIR = `@APXS@ -q SYSCONFDIR`

## Misc automake stuff goes here

install: install-am
    cp my.conf $(DESTDIR)${APACHE2_SYSCONFDIR}/conf.d/my.conf

I assume you are familiar with automake and autoconf tools.

Boris
Thanks a bunch! That's exactly what I'm looking for.
Stephen Burke