NginxでCakePHPを動かしてみる

NginxでPHPを動かしてみる
の続き

NginxでCakePHPを動かしてみる。

CakePHPの設置

とりあえずCakePHPを設置する。

$ cd /vagrant
$ wget https://github.com/cakephp/cakephp/archive/2.6.12.zip
$ unzip 2.6.12.zip

Securityの所を修正。

$ vi /vagrant/cakephp-2.6.12/app/Config/core.php
・・・
Configure::write('Security.salt', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
・・・
Configure::write('Security.cipherSeed', '01234567890123456789');
・・・

PHPの設定

mbstringをまだ入れてなかったのでインストール

$ sudo yum -y install php-mbstring

あと、PHPタイムゾーンの設定をまだしてなかったので設定。

$ sudo vi /etc/php.ini
・・・
date.timezone = Asia/Tokyo
・・・

再起動して反映。

$ sudo systemctl restart php-fpm

Nginxの設定

nginx.confのserverの所を下記のように修正。

$ sudo vi /etc/nginx/nginx.conf
・・・
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;

    root   /vagrant/cakephp-2.6.12/app/webroot/;
    index  index.php;

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

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
・・・

再起動して反映。

$ sudo systemctl restart nginx

結果

とりあえずCakePHPにアクセスできるようになった。