CentOSでPHP7をNginxで動かす
CentOSでPHP7をNginxで動かす(連携)の方法を簡単に。
Nginxいれて、PHP(&php-fpm)いれて、
$ yum -y install epel-release $ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm #CentOS6専用 $ yum --enablerepo=epel -y install nginx $ yum -y install --enablerepo=remi, remi-php70 php php-devel php-mbstring php-pdo php-gd php-mysql php-mcrypt php-fpm $ chkconfig nginx on $ chkconfig php-fpm on $ service nginx start $ service php-fpm start
nginxとphp-fpmの設定ファイルを書き換えます。
$ sudo vi /etc/php-fpm.d/www.conf user = nginx group = nginx
ドキュメントルートが/var/wwwの場合、
$ sudo vi /etc/nginx/conf.d/default.conf server_name xxxxx-xxxxx.com; location / { root /var/www; index index.php; } location ~ \.php$ { root /var/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
で、ブラウザでxxxxx-xxxxx.comを見て、/var/www/index.phpに書いたPHPコードが動いていればOKです