From 6e56e54d889b0bbd1f3e499d3669d3ec86ddc227 Mon Sep 17 00:00:00 2001 From: Francisco Redondo Marchena Date: Thu, 12 Feb 2015 13:02:00 +0000 Subject: Add apache httpd server and mod_wsgi module Add apache-httpd server and mod_wsgi which is a module to host any python application with python wsgi inteface. NOTE: apache-httpd server need to configure an user and group to run this can not be configured in this patch because some bug when changing owners of files and directories in system-integration commands. See more information on httpd-server.morph chunk --- strata/apache-httpd-server.morph | 40 +++++++++++++++ strata/apache-httpd-server/apr.morph | 25 ++++++++++ strata/apache-httpd-server/httpd-server.morph | 70 +++++++++++++++++++++++++++ strata/apache-httpd-server/mod_wsgi.morph | 21 ++++++++ 4 files changed, 156 insertions(+) create mode 100644 strata/apache-httpd-server.morph create mode 100644 strata/apache-httpd-server/apr.morph create mode 100644 strata/apache-httpd-server/httpd-server.morph create mode 100644 strata/apache-httpd-server/mod_wsgi.morph diff --git a/strata/apache-httpd-server.morph b/strata/apache-httpd-server.morph new file mode 100644 index 00000000..1692c61c --- /dev/null +++ b/strata/apache-httpd-server.morph @@ -0,0 +1,40 @@ +name: apache-httpd-server +kind: stratum +description: apache http web server and some utilities related to it +build-depends: +- morph: strata/tools.morph +- morph: strata/pcre-utils.morph +chunks: +- name: apr + morph: strata/apache-httpd-server/apr.morph + repo: upstream:apache/apr + ref: 3c818c6d7351f0130282d212a69035642f5fecad + unpetrify-ref: trunk + build-depends: [] +- name: httpd + morph: strata/apache-httpd-server/httpd-server.morph + repo: upstream:apache/httpd + ref: 6d8e0b2fd95268fcba96326ba9dce7bb8f712c19 + unpetrify-ref: 2.4.10 + build-depends: + - apr +- name: psutil + repo: upstream:python-packages/psutil + ref: 2bc8555f0428af81c2d067aa76168ed7bc5e0179 + unpetrify-ref: release-2.2.0 + build-depends: [] +- name: mod_wsgi-metrics + repo: upstream:python-packages/mod_wsgi-metrics + ref: ec715eb593255229f9f45f3f323edbb845c691d8 + unpetrify-ref: 1.1.1 + build-depends: + - psutil +- name: mod_wsgi + morph: strata/apache-httpd-server/mod_wsgi.morph + repo: upstream:python-packages/mod_wsgi + ref: 1be8b37aaf07d8cb3083da99d6fda12375221b07 + unpetrify-ref: 4.4.5 + build-depends: + - apr + - httpd + - mod_wsgi-metrics diff --git a/strata/apache-httpd-server/apr.morph b/strata/apache-httpd-server/apr.morph new file mode 100644 index 00000000..87e05910 --- /dev/null +++ b/strata/apache-httpd-server/apr.morph @@ -0,0 +1,25 @@ +name: apr +kind: chunk +configure-commands: +- ./buildconf +- | + ./configure --prefix="$PREFIX" \ + --disable-static \ + --enable-threads \ + --with-installbuilddir="$PREFIX"/share/apr-1/build +build-commands: +- make +install-commands: +- PREFIX="$PREFIX" DESTDIR="$DESTDIR" make install +# Install files required for apr-util and httpd +- | + for file in find_apr.m4 apr_common.m4 install.sh gen-build.py get-version.sh \ + config.guess config.sub; do \ + cp build/$file "$DESTDIR$PREFIX"/share/apr-1/build/$file ; \ + done +# Create a symlink in the build directory to the include directory (this is needed for httpd) +- ln -sf /usr/include/apr-2 "$DESTDIR$PREFIX"/share/apr-1/build/ +post-install-commands: +# Copy apr headers needed for mod_wsgi +- cp include/private/apr_support.h "$DESTDIR$PREFIX"/include/apr-2 +- cp include/arch/unix/apr_private.h "$DESTDIR$PREFIX"/include/apr-2 diff --git a/strata/apache-httpd-server/httpd-server.morph b/strata/apache-httpd-server/httpd-server.morph new file mode 100644 index 00000000..84b349f7 --- /dev/null +++ b/strata/apache-httpd-server/httpd-server.morph @@ -0,0 +1,70 @@ +name: httpd-server +kind: chunk +configure-commands: +- ./buildconf --with-apr=/usr/share/apr-1 +# libexecdir is rewrite with the same value as the layout has because +# when mod_wsgi calls apxs, it finds this variable empty +# failing on linking time, with the following error: +# +#/usr/share/apr-1/build/libtool --silent --mode=link gcc -std=gnu99 +# -o src/server/mod_wsgi.la -rpath # -module -avoid-version +# src/server/wsgi_validate.lo src/server/wsgi_stream.lo +# src/server/wsgi_server.lo src/server/wsgi_restrict.lo +# src/server/wsgi_metrics.lo src/server/wsgi_logger.lo +# src/server/wsgi_interp.lo src/server/wsgi_daemon.lo +# src/server/wsgi_convert.lo src/server/wsgi_buckets.lo +# src/server/wsgi_apache.lo src/server/mod_wsgi.lo +# -L/usr/lib -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm +# libtool: error: only absolute run-paths are allowed +# apxs:Error: Command failed with rc=65536 +# +- | + ./configure --prefix="$PREFIX" \ + --libexecdir="$PREFIX"/lib/httpd/modules \ + --enable-layout=RPM \ + --enable-mpms-shared=all \ + --with-apr="$PREFIX"/bin/apr-2-config \ + --enable-suexec --with-suexec \ + --with-suexec-caller=apache \ + --with-suexec-docroot=/var/www \ + --with-suexec-logfile=/var/log/httpd/suexec.log \ + --with-suexec-bin="$PREFIX"/lib/httpd/suexec \ + --with-suexec-uidmin=500 --with-suexec-gidmin=100\ + --with-suexec-userdir=public_html \ + --enable-pie \ + --with-pcre \ + --enable-mods-shared=all \ + --enable-ssl --with-ssl \ + --enable-case-filter --enable-case-filter-in \ + --enable-cgid --enable-cgi\ + --enable-so +build-commands: +- make +install-commands: +- PREFIX="$PREFIX" DESTDIR="$DESTDIR" make install +post-install-commands: +# Add perl interpreter path to apxs script, required for loading mod_wsgi. +- | + sed -i 's|#!/replace/with/path/to/perl/interpreter -w|#!/usr/bin/perl -w|g' \ + "$DESTDIR$PREFIX"/bin/apxs +# Add conf.d directory where apache will look for other configurations to load. +- mkdir -p "$DESTDIR"/etc/httpd/conf.d +- echo 'Include /etc/httpd/conf.d/*.conf' >> "$DESTDIR"/etc/httpd/conf/httpd.conf +#################################################################################### +# This chunk should add an apache user and an apache group, create the apache home +# directory and move suexec to /usr/lib/httpd/suexec as system-integration time. +# This is not possible due a bug in linux-chroot which does not allow to change +# the owners of directories or files. So for now you should create an script +# which includes the following commands: +# - mkdir -p /var/www +# - groupadd -r apache +# - | +# useradd -c "Apache Server" -d /var/www -g apache \ +# -s /bin/false apache +# +# - mkdir -p /usr/lib/httpd +# - mv -v /usr/bin/suexec /usr/lib/httpd/suexec +# - chgrp apache /usr/lib/httpd/suexec +# - chmod 4754 /usr/lib/httpd/suexec +# - chown -R apache:apache /var/www +#################################################################################### diff --git a/strata/apache-httpd-server/mod_wsgi.morph b/strata/apache-httpd-server/mod_wsgi.morph new file mode 100644 index 00000000..df8faf8c --- /dev/null +++ b/strata/apache-httpd-server/mod_wsgi.morph @@ -0,0 +1,21 @@ +name: mod_wsgi +kind: chunk +configure-commands: +- | + ./configure --prefix="$PREFIX" \ + --with-apxs=/usr/bin/apxs +build-commands: +- make +install-commands: +- PREFIX="$PREFIX" DESTDIR="$DESTDIR" make install +post-install-commands: +- | + install -D -m 644 /proc/self/fd/0 <<'EOF' "$DESTDIR"/etc/httpd/conf.d/wsgi.conf + # NOTE: mod_wsgi can not coexist in the same apache process as + # mod_wsgi_python3. Only load if mod_wsgi_python3 is not + # already loaded. + + + LoadModule wsgi_module /usr/lib/httpd/modules/mod_wsgi.so + + EOF -- cgit v1.2.1