Nginx Tricks for PHP Developers Ilia Alshanetsky @iliaa http://ilia.ws Core PHP Developer • CTO @ Gubagoo Inc. • (We are hiring!!) Security & Scalability aficionado ;-) • Brief History Developed in 2002 at rambler.ru by Igor Sysoev to • solve c10k problem First public release in the end of 2006 • In 2015 powers 15.5% of all sites, 23% of busiest • sites Party Tricks High Performance Event based HTTP Server • 10k+ connections with very low memory footprint • Reverse Proxy with Caching • Load Balancer • Mail Proxy • Any many many more… • The Basics + Base Config location ~* \.php$ { } Initial File location ~* \.php$ { fastcgi_index index.php; } PHP-FPM Socket Location location ~* \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; } Initialize $_SERVER Values location ~* \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } Files to Try, then 404 location ~* \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $uri =404; }
Description: