This config file works great on Ubuntu 10.04 LTS server with nginx 0.7.65. Other software includes php 5.3.2, Code Igniter 2.0. Performance-wise I was able to squeeze 12,000 requests per second on static files and ~250 req/s on dynamic PHP pages.
This is a copy-paste from Chris Gaunt’s github page with a change in server name.
server { listen 8080; server_name www.metak.com metak.com; access_log /home/metak/metak.com/logs/access.log; error_log /home/metak/metak.com/logs/error.log; root /home/metak/metak.com/public_html; # If file is an asset, set expires and break location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires max; break; } # Serve the directory/file if it exists, else pass to CodeIgniter front controller location / { try_files $uri @codeigniter; } # Do not allow direct access to the CodeIgniter front controller location ~* ^/index.php { rewrite ^/index.php/?(.*)$ /$1 permanent; } # CodeIgniter Front Controller location @codeigniter { internal; root /home/metak/metak.com/public_html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_config; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /home/metak/metak.com/public_html/index.php; } # If directly accessing a PHP file in the public dir other than index.php location ~* \.php$ { root /home/metak/metak.com/public_html; try_files $uri @codeigniter; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_config; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Advertisements