authserver/homestead/scripts/serve-hhvm.sh
changeset 8 5a0cbbe0922a
equal deleted inserted replaced
7:1a3fa80225b2 8:5a0cbbe0922a
       
     1 #!/usr/bin/env bash
       
     2 
       
     3 mkdir /etc/nginx/ssl 2>/dev/null
       
     4 openssl genrsa -out "/etc/nginx/ssl/$1.key" 1024 2>/dev/null
       
     5 openssl req -new -key /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.csr -subj "/CN=$1/O=Vagrant/C=UK" 2>/dev/null
       
     6 openssl x509 -req -days 365 -in /etc/nginx/ssl/$1.csr -signkey /etc/nginx/ssl/$1.key -out /etc/nginx/ssl/$1.crt 2>/dev/null
       
     7 
       
     8 block="server {
       
     9     listen ${3:-80};
       
    10     server_name $1;
       
    11     root \"$2\";
       
    12 
       
    13     index index.html index.htm index.php;
       
    14 
       
    15     charset utf-8;
       
    16 
       
    17     location / {
       
    18         try_files \$uri \$uri/ /index.php?\$query_string;
       
    19     }
       
    20 
       
    21     location = /favicon.ico { access_log off; log_not_found off; }
       
    22     location = /robots.txt  { access_log off; log_not_found off; }
       
    23 
       
    24     access_log off;
       
    25     error_log  /var/log/nginx/$1-error.log error;
       
    26 
       
    27     sendfile off;
       
    28 
       
    29     location ~ \.php$ {
       
    30         fastcgi_split_path_info ^(.+\.php)(/.+)$;
       
    31         fastcgi_pass 127.0.0.1:9000;
       
    32         fastcgi_index index.php;
       
    33         fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
       
    34         include fastcgi_params;
       
    35     }
       
    36 
       
    37     location ~ /\.ht {
       
    38         deny all;
       
    39     }
       
    40 }
       
    41 server {
       
    42     listen ${4:-443};
       
    43     server_name $1;
       
    44     root \"$2\";
       
    45 
       
    46     index index.html index.htm index.php;
       
    47 
       
    48     charset utf-8;
       
    49 
       
    50     location / {
       
    51         try_files \$uri \$uri/ /index.php?\$query_string;
       
    52     }
       
    53 
       
    54     location = /favicon.ico { access_log off; log_not_found off; }
       
    55     location = /robots.txt  { access_log off; log_not_found off; }
       
    56 
       
    57     access_log off;
       
    58     error_log  /var/log/nginx/$1-error.log error;
       
    59 
       
    60     sendfile off;
       
    61 
       
    62     location ~ \.php$ {
       
    63         fastcgi_split_path_info ^(.+\.php)(/.+)$;
       
    64         fastcgi_pass 127.0.0.1:9000;
       
    65         fastcgi_index index.php;
       
    66         fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
       
    67         include fastcgi_params;
       
    68     }
       
    69 
       
    70     location ~ /\.ht {
       
    71         deny all;
       
    72     }
       
    73 
       
    74     ssl on;
       
    75     ssl_certificate     /etc/nginx/ssl/$1.crt;
       
    76     ssl_certificate_key /etc/nginx/ssl/$1.key;
       
    77 }
       
    78 "
       
    79 
       
    80 echo "$block" > "/etc/nginx/sites-available/$1"
       
    81 ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
       
    82 service nginx restart
       
    83 service php5-fpm restart
       
    84 service hhvm restart