LoginSignup
10
9

More than 5 years have passed since last update.

【俺メモ】CentOS6系にnginx,php5.6,php-fpm をインストール&socketでのnginx連携

Posted at

nginx のインストール

  • nginx用Repositoryの追加
sudo yum localinstall http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  • インストール
sudo yum install nginx
  • バージョン確認
nginx -v

php,php-fpm のインストールとsocketでのnginx連携

  • phpの最新版をインストールするのに必要なRepositoryの追加
sudo yum localinstall http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum localinstall http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
  • phpと周辺モジュールのインストール
sudo yum -y --enablerepo=remi-php56,remi,epel install php php-mbstring
php-xml php-pdo php-mcrypt php-pecl-memcache php-pgsql
  • php-fpmのインストール
sudo yum install yum --enablerepo=remi-php56,remi,epel install php-fpm
  • php-fpmの初期設定
sudo vi /etc/php-fpm.d/www.conf
「user = nginx」へ変更
「group = nginx」へ変更
「listen = /var/run/php-fpm/php-fpm.sock」へ変更
「listen.owner = nginx」へ変更
「listen.group = nginx」へ変更
  • nginx のphp-fpm連携設定
nginx-default.conf
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        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;
    }

DocumentRoot部分は適宜読み替えをすること。

10
9
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
10
9