Jiniya

WEB

CentOS 7 에서 PHP 7 설치하기

1. PHP 7.0.0 설치 방법

yum install -y epel-release

rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum –enablerepo=remi update remi-release

yum –enablerepo=remi-php70 install -y php php-fpm php-mysql php-gd

php7-version

php -v  PHP 7.0.0 설치 완료

2. php.ini 설정

vi /etc/php.ini

3. www.conf 설정

vi /etc/php-fpm.d/www.conf

위와 같이 설정 후 저장하고 php 시작

4. nginx – php 연동 설정

vi /etc/nginx/conf.d/default.conf

▲ nginx 1.8.0 default.conf 기본 설정

 

 server {
listen       80;
server_name  도메인 도메인;#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;root /home/유저/public_html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}    error_page  404 /404.html;# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

 

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files      $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
#    deny  all;
#}
}

▲ nginx-php conf.d/도메인(영문).conf 설정 수정

위와 같이 바꾼 후 저장하고 nginx 를 시작해준다.
nginx 가 이미 실행중이라면 재시작해야 설정이 적용된다.

# systemctl reload nginx

 

4. nginx – php 가 제대로 연동됐는지 확인

vi /home/유저/public_html/phpinfo.php