Sunday, 8 January 2017

nginx Dengan Beberapa Versi PHP

Status : Draft

Untuk instalasi php5.6-fpm dan php7.0-fpm dalam 1 sistem lihat [1].

Contoh konfigurasi Nginx untuk php7.0-fpm 


#file /etc/nginx/sites-enabled/sangpelaut
server {
        server_name sangpelaut.np;
        root /home/wildan/jobstuff/openthinklabs/webapps/sangpelaut;

        access_log /var/log/nginx/sangpelaut/access.log;
        error_log /var/log/nginx/sangpelaut/error.log;

        fastcgi_read_timeout 300s;

        location / {
                try_files $uri /index.php/$uri?$args;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                if (!-f $document_root$fastcgi_script_name) {
                        return 404;
                }
                include fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   PATH_INFO               $fastcgi_path_info;
                fastcgi_param   KOHANA_ENV development;
                fastcgi_pass fpm70;
        }
}

#file /etc/nginx/conf.d/fpm70.conf

upstream fpm70 {
        server unix:/run/php/php7.0-fpm.sock;
}

Contoh konfigurasi Nginx untuk php5.6-fpm 

#file /etc/nginx/sites-enabled/sangpelaut
server {
        server_name sangpelaut.np;
        root /home/wildan/jobstuff/openthinklabs/webapps/sangpelaut;

        access_log /var/log/nginx/sangpelaut/access.log;
        error_log /var/log/nginx/sangpelaut/error.log;

        fastcgi_read_timeout 300s;

        location / {
                try_files $uri /index.php/$uri?$args;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                if (!-f $document_root$fastcgi_script_name) {
                        return 404;
                }
                include fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   PATH_INFO               $fastcgi_path_info;
                fastcgi_param   KOHANA_ENV development;
                fastcgi_pass fpm56;
        }
}

#file /etc/nginx/conf.d/fpm56.conf

upstream fpm56 {
        server unix:/run/php/php5.6-fpm.sock;
}

Referensi

  1. Multiple versions of PHP through nginx, http://serverfault.com/questions/671400/multiple-versions-of-php-through-nginx/671849#671849
  2. How to install php 7 to run beside php 5 on ubuntu with nginx, http://askubuntu.com/questions/749212/how-to-install-php-7-to-run-beside-php-5-on-ubuntu-with-nginx

No comments:

Post a Comment