人生の恥は書き捨て

プログラムとかいろいろ

fuelPHPをnginx+php-fpmで動かすときの設定

apachefuelPHPを動かす時と違って、
nginxをwebサーバーとして使う場合はphp-fpmを利用するのが一般的です。
その際nginxにはmod_rewiteのモジュールが無いので、
自分でパスの書き換えを行わないといけません。

といっても大したことではないです。

nginxの設定ファイルは/etc/nginx/conf.d/以下で基本的な設定はdefault.confに記述します。

<?php
    location / { 
        try_files $uri $uri/ @handler;
    }   
    
    location @handler {
        rewrite ^ /index.php?/$request_uri;
    }

    location ~^/index.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
        client_max_body_size 100M;
    }

上の2つはパスの書き換えで、下の設定はphp-fpmの設定です。