30.06.2016 Views

Magento Site Performance Optimization

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2<br />

We have set all the surrounding technologies; we can now handle the web server<br />

configuration. Here is the configuration proposed by Nginx developers for <strong>Magento</strong><br />

1.7+, which has been modified to run fastcgi:<br />

server {<br />

root /home/magento/web/;<br />

index index.php;<br />

server_name magento.example.com;<br />

location / {<br />

index index.html index.php;<br />

try_files $uri $uri/ @handler;<br />

expires 30d;<br />

}<br />

location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/<br />

config.xml|var)/ { internal; }<br />

location /var/export/ { internal; }<br />

location /. { return 404; }<br />

location @handler { rewrite / /index.php; }<br />

location ~* .php/ { rewrite ^(.*.php)/ $1 last; }<br />

location ~* .php$ {<br />

if (!-e $request_filename) { rewrite / /index.php last; }<br />

expires off;<br />

fastcgi_pass unix:/var/run/php5-fcgi.sock;<br />

fastcgi_param SCRIPT_FILENAME<br />

/var/www/magento-site-name$fastcgi_script_name;<br />

fastcgi_param SCRIPT_FILENAME<br />

$document_root$fastcgi_script_name;<br />

fastcgi_param MAGE_RUN_CODE default;<br />

fastcgi_param MAGE_RUN_TYPE store;<br />

include /etc/nginx/fastcgi_params;<br />

}<br />

}<br />

This file must be created under /etc/nginx/sites-available/ and all the values<br />

in bold must be adapted to your configuration.<br />

After all this, we can restart Nginx and finally get the default performances on this<br />

web server:<br />

sudo /etc/init.d/nginx restart<br />

Here is the default performance of Nginx:<br />

Document Path:<br />

Document Length:<br />

/magento/index.php/furniture/living-room.html<br />

16538 bytes<br />

[ 33 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!