
CentOS/RHEL에 PHP-FPM을 사용하여 Nginx MySQL PHP를 설치하는 방법
NGINX(Engine X)는 웹 서버이며 빠른 속도로 인해 매우 빠르게 인기를 얻고 있습니다. NGINX는 역방향 프록시 서버로도 사용됩니다. nginx와 함께 PHP 스크립트를 사용하려면 php-fpm을 설치해야 합니다. 이 문서는 CentOS 및 RHEL 6 Server에서 Nginx, MySQL, PHP(LEMP) 스택을 사용하여 PHP-FPM을 사용하여 웹 호스팅 환경을 설정하는 데 도움이 됩니다. 1단계: 필요한 RPM 저장소 설치Fristly 시스템에 EPEL 및 Remi 저장소를 설치해야 합니다. 다음 명령을 사용하여 리포지토리를 설치합니다.
Nginx를 설치하려면
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm다른 시스템 버전/아키텍처를 사용하는 경우 아래 문서Yum Repositories for CentOS, RHEL Systems를 참조하십시오. 2단계: YumNow를 사용하여 NGINX 설치 yum 명령줄 유틸리티를 사용하여 nginx를 설치합니다. 주어진 명령에 따라 nginx를 설치하고 nginx 서버를 시작합니다.
Nginx를 설치하려면
# yum install nginxNginx를 시작하려면
# /etc/init.d/nginx start3단계: 다음 명령을 사용하여 MySQL을 설치하고 MySQL 서버를 구성합니다.
# yum install mysql mysql-server처음으로 mysql을 시작하고 구성하십시오.
# /etc/init.d/mysqld start
# /usr/bin/mysql_secure_installationmysql 루트 암호를 설정하고 나머지 지침을 따릅니다. 다른 단계의 경우 모두 예라고 말하는 것이 좋습니다. 4단계: PHP 설치 및 PHP-FPMphp-fpm은 remi 저장소에서 사용할 수 있습니다. 다음 명령을 사용하여 설치하십시오.
# yum --enablerepo=remi install php php-fpm php-mysql php-cli5단계: NGINX 및 기본 가상 호스트를 구성하고 nginx 구성 파일을 편집하고 작업자 프로세스를 4로 업데이트합니다.
# vim /etc/nginx/nginx.conf worker_processes 4;이제 nginx 가상 호스트 파일에서 기본 가상 호스트를 구성합니다.
vi /etc/nginx/conf.d/default.confConfiguration 파일에는 아래와 같은 설정이 있어야 합니다. 요구 사항에 따라 server_name 및 루트 경로 설정을 업데이트합니다.
# # The default virtual server # server { listen 80; server_name nginx..net; location / { root /var/www/nginx..net; index index.php index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php { root /var/www/nginx..net; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }6단계: PHP-FPMEdit php-fpm 구성 파일을 구성하고 아래와 같이 사용자 및 그룹 설정을 업데이트합니다.
# vim /etc/php-fpm.d/www.conf사용자 및 그룹의 값을 아래와 같이 nginx로 교체합니다.
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache Choosed to be able to access some dir as httpd user = nginx ; RPM: Keep a group allowed to write in log dir. group = nginx7단계: 서비스 다시 시작 다음 서비스를 다시 시작하고 구성 시스템 부팅 시 자동 시작합니다.
# /etc/init.d/nginx restart # /etc/init.d/php-fpm restart # /etc/init.d/mysqld restart # chkconfig nginx on # chkconfig mysqld on # chkconfig php-fpm on8단계: 설정 테스트 모든 구성이 완료되었습니다. 이제 브라우저에서 가상 호스트에 액세스합니다. 이 기사에서는 php가 작동하는지 확인하기 위해 문서 루트에 phpinfo 파일을 생성했습니다.
