├── nginx.conf ├── nginx_ssl_options.conf ├── nginx_vhost_default.conf ├── nginx_vhost_http.conf ├── nginx_vhost_https.conf └── post-receive /nginx.conf: -------------------------------------------------------------------------------- 1 | # User to run nginx under 2 | user root; 3 | 4 | # Number of nginx workers 5 | worker_processes 1; 6 | 7 | # Where to store errors 8 | error_log /var/log/nginx/error.log warn; 9 | 10 | # Nginx PID file 11 | pid /var/run/nginx.pid; 12 | 13 | # Connections a worker can handle 14 | events { 15 | worker_connections 1024; 16 | } 17 | 18 | 19 | # HTTP Configuration 20 | http { 21 | # Include MIME types 22 | include /etc/nginx/mime.types; 23 | 24 | # Default type when none detected 25 | default_type application/octet-stream; 26 | 27 | # Log format configuration 28 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 29 | '$status $body_bytes_sent "$http_referer" ' 30 | '"$http_user_agent" "$http_x_forwarded_for"'; 31 | 32 | # Access log file 33 | access_log /var/log/nginx/access.log main; 34 | 35 | # Handle file descriptors at kernel level 36 | sendfile on; 37 | 38 | # Timetou of keepalive 39 | keepalive_timeout 65; 40 | 41 | # Uncomment to turn on compression 42 | #gzip on; 43 | 44 | # Include virtual hosts 45 | include /etc/nginx/sites-enabled/*; 46 | } 47 | -------------------------------------------------------------------------------- /nginx_ssl_options.conf: -------------------------------------------------------------------------------- 1 | # General SSL Configurations 2 | ssl_session_cache shared:SSL:10m; 3 | ssl_session_timeout 10m; 4 | 5 | # Perfect Forward Security 6 | ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; -------------------------------------------------------------------------------- /nginx_vhost_default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | # Listen to HTTP on Both IPv4 & IPv6 4 | listen 80 default_server; 5 | listen [::]:80 default_server ipv6only=on; 6 | 7 | # Listen to HTTPS on Both IPv4 & IPV6 8 | listen 443 ssl default_server; 9 | listen [::]:443 ssl default_server; 10 | 11 | # Default host root folder 12 | root /var/www/html; 13 | 14 | # Index files 15 | index index.html index.htm index.nginx-debian.html; 16 | 17 | # Server name 18 | server_name _; 19 | 20 | # Rewrite 21 | location / { 22 | try_files $uri $uri/ =404; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /nginx_vhost_http.conf: -------------------------------------------------------------------------------- 1 | # HTTP Application 2 | 3 | server { 4 | 5 | # Application Path 6 | root /path/to/app/public/path; 7 | 8 | # Index Application File 9 | index index.php; 10 | 11 | # Listen to hosts 12 | server_name app.com www.app.com; 13 | 14 | # Enable IPv4 15 | listen 80; 16 | # Enable IPv6 17 | listen [::]:80; 18 | 19 | # URL Rewrite Rules 20 | location / { 21 | try_files $uri $uri/ /index.php$is_args$args; 22 | } 23 | 24 | # PHP Backend Config 25 | location ~ \.php$ { 26 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 27 | fastcgi_pass unix:/run/php/php7.0-fpm-myapp.sock; 28 | fastcgi_index index.php; 29 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 30 | include fastcgi_params; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /nginx_vhost_https.conf: -------------------------------------------------------------------------------- 1 | # HTTPS Application 2 | 3 | server { 4 | 5 | # Application Path 6 | root /path/to/app/public/path; 7 | 8 | # Index Application File 9 | index index.php; 10 | 11 | # Listen to hosts 12 | server_name app.com www.app.com; 13 | 14 | # Enable SSL 15 | ssl on; 16 | # Listen on HTTPS Port using HTTP2 (IPv4) 17 | listen 443 http2; 18 | # Listen on HTTPS Port using HTTP2 (IPv6) 19 | listen [::]:443 http2; 20 | 21 | # SSL Certificate File 22 | ssl_certificate /etc/letsencrypt/live/app.com/fullchain.pem; 23 | # SSL Private Key 24 | ssl_certificate_key /etc/letsencrypt/live/app.com/privkey.pem; 25 | 26 | # URL Rewrite Rules 27 | location / { 28 | try_files $uri $uri/ /index.php$is_args$args; 29 | } 30 | 31 | # PHP Backend Config 32 | location ~ \.php$ { 33 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 34 | fastcgi_pass unix:/run/php/php7.0-fpm-myapp.sock; 35 | fastcgi_index index.php; 36 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 37 | include fastcgi_params; 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /post-receive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read oldrev newrev ref 3 | 4 | # Variables 5 | USER_PATH='/home/user' 6 | REPO_PATH=$USER_PATH"/repo" 7 | STAGING_PATH=$USER_PATH"/staging" 8 | PRODUCTION_PATH=$USER_PATH"/production" 9 | 10 | do 11 | 12 | branch=`echo $ref | cut -d/ -f3` 13 | 14 | export GIT_DIR=$REPO_PATH 15 | 16 | if [ "develop" == "$branch" ]; then 17 | echo "Deploying STAGING" 18 | export GIT_WORK_TREE=$STAGING_PATH 19 | git checkout -f $branch 20 | cd $STAGING_PATH 21 | composer install 22 | php artisan migrate --force 23 | gulp 24 | php artisan cache:clear 25 | 26 | elif [ "master" == "$branch" ]; then 27 | echo "Deploying PRODUCTION" 28 | export GIT_WORK_TREE=$PRODUCTION_PATH 29 | git checkout -f $branch 30 | cd $PRODUCTION_PATH 31 | composer install 32 | php artisan migrate --force 33 | gulp 34 | php artisan cache:clear 35 | fi 36 | 37 | done 38 | --------------------------------------------------------------------------------