Catégories
Installation

Installation de Nginx, PHP 5.3 et PHP-FPM

image_pdfimage_print

Nginx

aptitude install nginx
service nginx start

Configuration de Nginx

server {
    listen   80;
    server_name  localhost;
    access_log  /var/log/nginx/localhost.access.log;

## Default location
    location / {
        root   /var/www;
        index  index.php;
    }

## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log        off;
      expires           30d;
      root /var/www;
    }

## Parse all .php file in the /var/www directory
    location ~ .php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass   backend;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param  QUERY_STRING     $query_string;
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;
        fastcgi_param  CONTENT_LENGTH   $content_length;
        fastcgi_intercept_errors        on;
        fastcgi_ignore_client_abort     off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
        deny  all;
    }
}
upstream backend {
    server 127.0.0.1:9000;
}

Il est possible que « fastcgi_split_path_info » ne soit pas supporté, car cette variable de configuration n’est disponible que dans les versions récentes de Nginx.

PHP, PHP-FPM et ses modules

On utilise le dépôt DotDeb

echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list
aptitude update
aptitude safe-upgrade

Et on installe PHP

aptitude install php5-cli php5-common php5-suhosin
aptitude install php5-fpm php5-cgi
aptitude install php5-mysql php5-curl php5-gd php5-imagick php5-mcrypt php5-memcache php5-apc

Initialisation

service nginx restart
service php5-fpm restart

Laisser un commentaire