CentOS6 환경에서 진행하며, nginx와 php는 php-fpm을 이용하여 연결된다.
설치는 yum을 이용한다.
- Nginx 설치
sudo yum install nginx vim /etc/nginx/nginx.conf +location ~ \.php$ { + root html; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; + include fastcgi_params; +} sudo service nginx start
- Php7 설치
sudo yum -y update
sudo yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://centos6.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm
sudo yum -y update
sudo yum -y install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-mcrypt php70u-gd php70u-devel php70u-mysql php70u-intl php70u-mbstring php70u-bcmath php70u-json php70u-iconv
vim /etc/php.ini
+ date.timezone = Asia/Seoul
+ cgi.fix_pathinfo=0
+ expose_php = Off
Error: Package: php70u-gd-7.0.18-1.ius.centos6.x86_64 (ius)
Requires: libwebp.so.5()(64bit)
위와 같은 에러 발생 시 https://www.rpmfind.net/linux/rpm2html/search.php?query=libwebp.so.5()(64bit)
에서 lib64webp5-0.4.3-1.mga5.x86_64.rpm
다운로드 후 sudo yum install lib64webp5-0.4.3-1.mga5.x86_64.rpm
설치한다.
- php-fpm 설치
sudo yum install php70u-fpm sudo service php-fpm start
- index.php 생성
sudo vim /usr/share/nginx/html/index.php
<?php
phpinfo()
http://localhost/index.php
접속하여 확인한다.