Written by Mitchell Krog - https://github.com/mitchellkrogza
This is a basic template for getting Travis CI's container based infrastructure to install a stable version of Nginx including Nginx-Extras and to test any scenario of Nginx.conf files and customization scripts you have written.
I actually use this a test playground for my Nginx Bad Bot Blocker - https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker so it's always changing but it will give you the basics of how to properly install Nginx on Travis.
Travis CI is a great system for checking and testing your build's Commits, Pull Requests and Merges. Travis runs everything inside a Docker container so it's a fully contained system that you can run build tests on your GIT repository and you can't break anything outside of it.
This repository contains a simple layout for installing nginx into Travis, then loading your config files and running and number of bash commands to test your scripts.
If you pulled all your hair out already trying to get this all to work with Travis CI then you have landed in the right repository.
Travis CI does not come with Nginx pre-installed so the install needs to be scripted to tell Travis CI what to do. This script takes care of installing a stable build of nginx including nginx-extras.
If you don't even know what the heck Travis CI is read here - https://travis-ci.org/
All of the installation files are located in the /travis-ci directory.
The main installation is done through the install-nginx.sh bash script.
It's a simple script so it should be relatively easy to follow for anyone with a little bit of understanding of bash. The other scripts in the /travis-ci directory are basic Nginx and php-fpm configuration templates.
- Install Nginx using simple apt-get via entries in the .travis.yml file.
- Collect any information for the install into environment variables.
- Copy the configuration templates to a new directory while replacing placeholders with environment variables.
- Start php-fpm and Nginx with our custom configuration file instead of the default.
- Runs an nginx -t test to confirm Nginx is correctly configured
- Runs a curl against a simple php file in the /www directory.