Skip to content

Instantly share code, notes, and snippets.

@niels-nijens
Last active November 24, 2017 13:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niels-nijens/548e0c4fe80c3c79ca30 to your computer and use it in GitHub Desktop.
Save niels-nijens/548e0c4fe80c3c79ca30 to your computer and use it in GitHub Desktop.
Running Apache2 and PHP-FPM in Travis CI container-based infrastructure
addons:
apt:
packages:
- apache2
- libapache2-mod-fastcgi
install:
- echo "Initializing Apache2 and PHP-FPM"
- cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
- tests/Resources/apache2/apache2.sh
#!/bin/bash
set -e
export APACHE_RUN_USER=travis
export APACHE_RUN_GROUP=travis
export APACHE_PID_FILE=$TRAVIS_BUILD_DIR/tests/Resources/apache2/apache2.pid
export APACHE_LOCK_DIR=$TRAVIS_BUILD_DIR/tests/Resources/apache2
export APACHE_LOG_DIR=$TRAVIS_BUILD_DIR/tests/Resources/apache2
exec /usr/sbin/apache2 -f $TRAVIS_BUILD_DIR/tests/Resources/apache2/configuration -k start
Listen 8080
ServerName localhost
PidFile ${APACHE_PID_FILE}
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ErrorLog ${APACHE_LOG_DIR}/error.log
Include /etc/apache2/mods-available/actions.load
Include /etc/apache2/mods-available/alias.load
Include /etc/apache2/mods-available/authz_host.load
Include /etc/apache2/mods-available/env.load
Include /etc/apache2/mods-available/fastcgi.load
Include /etc/apache2/mods-available/mime.load
Include /etc/apache2/mods-available/rewrite.load
Include /etc/apache2/mods-available/setenvif.load
Include /etc/apache2/mods-available/actions.conf
Include /etc/apache2/mods-available/alias.conf
Include /etc/apache2/mods-available/mime.conf
Include /etc/apache2/mods-available/setenvif.conf
<IfModule mod_fastcgi.c>
FastCgiIpcDir ${TRAVIS_BUILD_DIR}/tests/Resources/apache2
</IfModule>
<VirtualHost *:8080>
DocumentRoot ${TRAVIS_BUILD_DIR}/web
<Directory "${TRAVIS_BUILD_DIR}/web">
Options FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
# Configure Apache to use Travis CI's php-fpm.
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
</VirtualHost>
@gmorel
Copy link

gmorel commented Mar 4, 2016

Thanks ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment