Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janikvonrotz/9445746 to your computer and use it in GitHub Desktop.
Save janikvonrotz/9445746 to your computer and use it in GitHub Desktop.
Ubuntu: Install Nginx php5-fpm website #PHP #Nginx #Markdown

Introduction

This is a minimal Nginx configuration to run php based websites/ applications.

Requirements

  • Ubuntu server
  • Nginx
  • Nginx minimal website
  • php5-fpm

Installation

Add this Nginx configuration to your website config.

server{

    ...
    
    # php5-fpm configuration
    location ~ \.php$ {
        
        set $php_root /var/www/[host];
        
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}

Test config and reload Nginx service.

sudo nginx -t && sudo service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment