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.

Choosing the Best Web Server<br />

Installing the Nginx 1.1.19 web server<br />

In this section, we will see how much Nginx 1.1.19 can improve our performance<br />

in serving <strong>Magento</strong>. Unlike Apache2 and lighttpd, Nginx cannot serve <strong>Magento</strong><br />

without a lot of configuration. Therefore, we will spend the first part of this section<br />

to install and configure Nginx in order to serve <strong>Magento</strong> and, in the second step, we<br />

will optimize Nginx.<br />

Before optimization<br />

The first step is to install all the required components using the following command:<br />

$ sudo apt-get install nginx spawn-fcgi php5-cgi php5-cli php5-mcrypt<br />

php5-gd php5-curl<br />

Then, we need a script to force PHP to start in the fastcgi mode. This script has<br />

been built by atoc.com and can be downloaded at http://mathieu-nayrolles.<br />

com/magento-optimization/chapter2/php5-fcgi. This script is placed in /etc/<br />

init.d/:<br />

#! /bin/sh<br />

### BEGIN INIT INFO<br />

# Provides: php5-fcgi<br />

# Required-Start: $all<br />

# Required-Stop: $all<br />

# Default-Start: 2 3 4 5<br />

# Default-Stop: 0 1 6<br />

# Short-Description: PHP FastCGI<br />

# Description: PHP FastCGI<br />

### END INIT INFO<br />

# Author: AITOC <br />

PATH=/sbin:/usr/sbin:/bin:/usr/bin<br />

DESC="PHP FastCGI"<br />

NAME=php5-fcgi<br />

DAEMON=/usr/bin/spawn-fcgi<br />

FCGI_SOCKET=/var/run/php5-fcgi.sock<br />

FCGI_USER=www-data<br />

FCGI_MODE=0600<br />

PIDFILE=/var/run/$NAME.pid<br />

SCRIPTNAME=/etc/init.d/$NAME<br />

DAEMON_ARGS="-s $FCGI_SOCKET -M $FCGI_MODE -u $FCGI_USER -U $FCGI_USER<br />

-P $PIDFILE -- /usr/bin/php5-cgi"<br />

[ 30 ]<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!