LoginSignup
28
27

More than 5 years have passed since last update.

CentOSでFuelPHPをnginxで動かしてみたときのメモ

Posted at

FuelPHPを触ることになったのでnginxで動作させてみた時のメモ

環境

  • centos6.3(ゲストOS)
  • macosx10.8(ホストOS)

事前準備に必要なもの

  • php5.3以上
  • php-fpm

参考にしたサイト

公式サイトからFuelPHPを取得する

公式サイトにいってDownloadボタンをポチッと押して自分のドキュメントルートに持っていく

構成はこんな感じ

unzip fuelphp-1.5.2.zip

oilでインストールする

展開したディレクトリにoilというファイルがあるのでそこで下記のコマンドを実行する。
日本語版公式どおりです

sudo php oil refine install

nginxの設定

/usr/local/nginx/conf/nginx.conf
http {
    .
    .
    .
    server {
        listen       80; #ポート番号
        server_name  lo.fuel.master.org; #バーチャルホスト名
        root   /home/web/lo.fuel.master.org/public; #FuelPHPのデフォルトのpublicディレクトリ
        index  index.php index.html index.htm;
        access_log  /usr/local/nginx/logs/access.log;

        # Rewrite FuelPHP
        location / {
            if (-f $request_filename) {
                expires 30d;
                break;
            }
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php?q=$1 last;
            }
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

nginxの再起動

いつもどおり

/etc/init.d/nginx stop
/etc/init.d/nginx start

ブラウザで確認する

今回ならhttp://lo.fuel.master.orgにアクセスしてFuelのwelcomeページが表示されればOK

28
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
27