nginx + php-fpm 설치 정리 on centos 6.5
1. yum repository 에 nginx 위치 수동 추가 (http://nginx.org/en/linux_packages.html 참고)
1) cent os version 확인
cat /etc/issue
2) /etc/yum.repos.d/nginx.repo 에 아래 설정 추가
- 이때 cent OS 버전이 6.5 이므로 major 버전인 6을 디렉토리 위치에 추가한다.
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/6/$basearch/ gpgcheck=0 enabled=1 |
2. yum 을 이용한 nginx 설치 및 실행
yum install nginx service nginx start |
3. php 설치 (http://itraveler.tistory.com/26 참고)
1) 최신버전 설치를 위해 remi repository 설정
2) php-fpm 을 포함한 필요 모듈 설치
wget http://rpms.famillecollet.com/enterprise/remi-release-6.5-1.el6.remi.noarch rpm -Uvh remi-release-6*.rpm yum --enablerepo=remi-php55 install php php-fpm php-mysql php-mbstring php-xml |
3) 설치중 오류 처리
failed dependencies
epel-release >= 6 is needed by remi-release-6.5-1.el6.remi.noarch
yum install epel-release |
필요에 따라...
yum clean all yum makecache yum update |
4. php-fpm 설정
1) vi /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/www.sock listen.owner = nginx listen.group = nginx listen.mode = 0660 user = nginx group = nginx pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 chdir = /usr/share/nginx/html php_admin_value[error_log] = /var/log/php-fpm/www-error.log php_admin_flag[log_errors] = on php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache |
2) php-fpm 실행
/etc/rc.d/init.d/php-fpm restart
5. nginx 설정
1) vi /etc/nginx/conf.d/default.conf
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$ { try_files $uri =404; root /usr/share/nginx/html; fastcgi_pass unix:/var/run/php-fpm/www.sock; # fastcgi_split_path_info ^(.+\.php)(/.+)$; 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; #} } |
2) nginx 실행
service nginx restart