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
php -v PHP 7.0.0 설치 완료
systemctl start php-fpm // php 시작 systemctl enable php-fpm // php 부팅시 자동 실행 systemctl status php-fpm // php 상태 확인 systemctl stop php-fpm // php 정지 systemctl restart php-fpm // php 재시작 |
2. php.ini 설정
vi /etc/php.ini
allow_url_fopen = Off expose_php = Off display_errors = Off upload_max_filesize = 100M post_max_size = 110M max_execution_time = 60 max_input_time = 120 memory_limit = 256M |
3. www.conf 설정
vi /etc/php-fpm.d/www.conf
user = nginx group = nginx listen.owner = nobody // listen.group = nobody // 앞에 주석 ; 을 지움 |
위와 같이 설정 후 저장하고 php 시작
4. nginx – php 연동 설정
vi /etc/nginx/conf.d/default.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #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$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$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 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 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # deny access to .htaccess files, if Apache’s document root |
▲ nginx-php conf.d/도메인(영문).conf 설정 수정
위와 같이 바꾼 후 저장하고 nginx 를 시작해준다.
nginx 가 이미 실행중이라면 재시작해야 설정이 적용된다.
# systemctl reload nginx
4. nginx – php 가 제대로 연동됐는지 확인
vi /home/유저/public_html/phpinfo.php
<?php phpinfo() |