Skip to content

Commit

Permalink
Setup nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGoljerSalesChamp committed May 23, 2017
1 parent e4e6042 commit 3f1f4e0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ Tests for the application are stored here. Additional configuration for dev too

## Dev server

To start the built-in dev server, run
To start the built-in dev server on port `8080`, run

composer start

If you have `docker-compose` available, it is adviced to use the provided docker stack.

## Docker stack

To run the server inside docker, run
To run the stack with docker, run

docker-compose up -d

This boots the application itself running under `php-fpm` on port 9000 (internally) and an `nginx` front-end listening on `8080`.

## Nette Tester

[Nette Tester](https://github.com/nette/tester/) is a lightweight alternative to [PHPUnit](https://phpunit.de/).
Expand Down
13 changes: 9 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ volumes:
services:
app:
image: saleschamp/php
working_dir: /var/www
command: php -S 0.0.0.0:8080 -t public public/index.php
working_dir: /var/www/public
command: php-fpm
environment:
docker: "true"
ports:
- 8080:8080
volumes:
- .:/var/www
- logs:/var/www/logs

www:
image: nginx:1.13
volumes:
- ./www/nginx.conf:/etc/nginx/nginx.conf
ports:
- 8080:80
42 changes: 42 additions & 0 deletions www/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
gzip on;

index index.php;

server {
listen 80;
listen [::]:80;

root /var/www/public/;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;

include fastcgi_params;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# HTTPoxy
fastcgi_param HTTP_PROXY "";

fastcgi_pass app:9000;
}
}
}

0 comments on commit 3f1f4e0

Please sign in to comment.