├── .gitignore ├── README.md ├── docker-compose.yml ├── fpm.Dockerfile ├── nginx.Dockerfile ├── php.ini └── statamic.nginx.conf /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | statamic 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Basic Statamic & Nginx Docker Setup 2 | 3 | **For Statamic 3, see [statamic3-nginx-docker](https://github.com/danielgormly/statamic3-nginx-docker/)** 4 | 5 | Statamic 2.x Docker setup with Nginx.git 6 | 7 | ## Installation 8 | 9 | - Clone repository 10 | - Download [Statamic](https://statamic.com/) and extract into `./statamic` 11 | - Run `docker-compose up -d` to start 12 | - Listening on port 8000 13 | - Run statamic installer `/installer.php` 14 | - `docker-compose build` to rebuild services if you make any changes 15 | 16 | ## Files 17 | 18 | **docker-compose.yml** Docker composition file, builds fpm & Nginx dockerfiles. 19 | 20 | **fpm.Dockerfile** Builds from official [fpm:php-7fpm](https://hub.docker.com/_/php/) image Installs GD and required dependencies for Statamic's image manipulation capabilities. Adds `php.ini` into project (you may want to update the timezone here - defaults to `Australia/Sydney`). Makes 256mb memory available as recommended by Statamic (default for fpm:php-7fpm Docker image is 128mb). 21 | 22 | **nginx.Dockerfile** Adds `statamic.nginx.conf` (site specific Nginx conf file) to Nginx container 23 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | nginx: 4 | build: 5 | context: ./ 6 | dockerfile: nginx.Dockerfile 7 | ports: 8 | - "8000:8000" 9 | volumes: 10 | - ./statamic:/var/www/statamic-site/ 11 | fpm: 12 | build: 13 | context: ./ 14 | dockerfile: fpm.Dockerfile 15 | volumes: 16 | - ./statamic:/var/www/statamic-site/ 17 | -------------------------------------------------------------------------------- /fpm.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7-fpm 2 | RUN apt-get update && apt-get install -y \ 3 | libjpeg62-turbo-dev \ 4 | libpng-dev \ 5 | zlib1g-dev \ 6 | libzip-dev \ 7 | && rm -rf /var/lib/apt/lists/* \ 8 | && docker-php-ext-configure gd --with-jpeg \ 9 | && docker-php-ext-install -j$(nproc) gd \ 10 | && docker-php-ext-install exif \ 11 | && docker-php-ext-install zip 12 | COPY php.ini /usr/local/etc/php/ 13 | -------------------------------------------------------------------------------- /nginx.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:latest 2 | ADD statamic.nginx.conf /etc/nginx/conf.d -------------------------------------------------------------------------------- /php.ini: -------------------------------------------------------------------------------- 1 | memory_limit = 256M 2 | date.timezone = "Australia/Sydney" 3 | upload_max_filesize = 12M 4 | post_max_size = 12M 5 | max_execution_time = 300 -------------------------------------------------------------------------------- /statamic.nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8000; 3 | root /var/www/statamic-site; 4 | 5 | # ssl_protocols TLSv1.2; 6 | 7 | # Increase Nginx upload size limit to 12MB 8 | client_max_body_size 12M; 9 | 10 | index index.html index.htm index.php; 11 | 12 | charset utf-8; 13 | 14 | # Static cache reverse proxy 15 | # location = / { 16 | # try_files /static/index.html /index.php?$query_string; 17 | # } 18 | 19 | location / { 20 | try_files $uri $uri/ /static/$uri /static/$uri/index.html /static/ $uri /index.php?$query_string; 21 | } 22 | 23 | location = /favicon.ico { access_log off; log_not_found off; } 24 | location = /robots.txt { access_log off; log_not_found off; } 25 | 26 | access_log off; 27 | error_log /var/log/nginx/example.com-error.log error; 28 | 29 | error_page 404 /index.php; 30 | 31 | location ~ [^/]\.php(/|$) { 32 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 33 | fastcgi_pass fpm:9000; 34 | fastcgi_index index.php; 35 | include fastcgi_params; 36 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 37 | fastcgi_param PATH_INFO $fastcgi_path_info; 38 | fastcgi_read_timeout 300; 39 | } 40 | 41 | # Block access to hidden files (except the /.well-known/ dir) 42 | location ~ /(?!.well-known)(\.)\w+ { 43 | deny all; 44 | } 45 | 46 | # Block access to content/data files 47 | location ~* /(.*)\.(?:md|yaml|textile)$ { 48 | deny all; 49 | return 404; 50 | } 51 | 52 | # Block access to the Statamic app 53 | location ^~ /statamic { 54 | deny all; 55 | return 404; 56 | } 57 | 58 | # Enable gzip compression 59 | gzip on; 60 | gzip_min_length 1100; 61 | gzip_buffers 4 32k; 62 | gzip_types text/plain application/x-javascript text/xml text/css; 63 | gzip_vary on; 64 | } 65 | --------------------------------------------------------------------------------