apacheからnginxに乗り換える2

昨日の続き

php-fpmをインストールする

php5.6を使っているのでremiリポジトリを追加後インストールする

sudo yum install yum --enablerepo=remi-php56,remi,epel install php-fpm

その他は下記記事を参考に設定 qiita.com

/etc/nginx/conf.d/default.conf は最終的にこうなった

server {
    listen       80;
    server_name  localhost;
    root   /var/www/html;

    location / {
        index  index.php index.html index.htm;
    }

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }
}

文字化け

デフォルトだとutf-8が文字化けして配信されてしまったので /etc/nginx/nginx.conf のhttpブロックの先頭に↓を追加した

charset UTF-8;