Docker container to run NGINX
- Install Docker
- Pull from Docker Hub
docker pull xaamin/nginx
- Build an image from Dockerfile
docker build -t xaamin/nginx https://github.com/xaamin/nginx.git
You must provide a volume mounted on /shared containing the same structure as shared directory
First, run a PHP5 FPM container
docker run -d --name example.dev --restart always -v ./shared/accounts/example.dev:/shared/accounts/example.dev xaamin/php-fpm
See shared directory inside this repository for sample structure. You must link to xaamin/php-fpm docker container.
docker run -d --name nginx.web --restart always --link example.dev -v ./shared:/shared xaamin/nginx
To replace the default SSL certificate use the following command.
docker exec -it nginx.dev bash /secure.sh
Or inside the container execute /secure.sh
script and fill properly information.
docker exec -it nginx.dev bash bash
# Inside de container terminal issue
SCRIPT_FILENAME=/shared/accounts/example.dev/www/index.php QUERY_STRING=VAR1 DOCUMENT_ROOT=/shared/accounts/example.dev/www REQUEST_METHOD=GET cgi-fcgi -bind -connect example.dev:9000
You must need openssl installed locally. This scripts only runs in Linux and MacOS, if you are a windows user you should enter to your nginx container to create a site
# Lunux and MacOS
bash scripts/create-site.sh
# Windows
docker exec -it nginx bash /shared/scripts/create-site.sh
export HOST_USER_ID=$(id -u $(whoami)) && export HOST_GROUP_ID=$(id -g $(whoami)) && docker-compose up -d