Skip to content
Jeremy McNamara edited this page Jan 11, 2014 · 11 revisions

PHP is most efficient when used in Fast CGI Mode.

Install php5 process manager

#apt-get install php5-fpm

Next Steps:

  • create a CSR and either self-sign or get a legit ssl certificate
  • create a file in /etc/nginx/sites-avaiable/[your servername]
  • create a symbolic link in /etc/nginx/sites/enabled
  • restart nginx

Create file [your servername]:

upstream php {
   server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    server_name [your server name];
    return 301 https://$host$request_uri;
}

server { 
  listen 443;
  server_name [your server name];

  error_page 404 "/index.php?page=error&action=404";

  ssl on;
  ssl_certificate /etc/ssl/certs/[your server certificiate];
  ssl_certificate_key /etc/ssl/private/[your server key];
  ssl_prefer_server_ciphers on;
  keepalive_timeout 15;

  # Adjust to your installation location  
  root /usr/share/nginx/www/MPOS/public; 

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location ~ /\. {
    deny all;
  }

  location ~ /templates(/|$) {
    deny all;
  }
  location ~ /include(/|$) {
   deny all;
  }

 # Directives to send expires headers and turn off 404 error logging.
  location ~* ^.+\.     (ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
  }

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

  location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;	
        fastcgi_pass php;
  }
}
Clone this wiki locally