CentOS / RHEL 6 / 7 Nginx, PHP 7, PHP - FPM 설치

2284 단어 linux
  • Remi 원본 가 져 오기
  • ## Remi Dependency on CentOS 7 and Red Hat (RHEL) 7 ##
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    ## CentOS 7 and Red Hat (RHEL) 7 ##
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    
    ## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    ## CentOS 6 and Red Hat (RHEL) 6 ##
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
  • Nginx 원본 가 져 오기
  • vim /etc/yum.repos.d/nginx.repo
    
    #### centos
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    ###########
    
    #### RHEL
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    ###########
    
  • nginx, phop 7, phop - fpm
  • 설치
    yum --enablerepo=remi,remi-php72 install nginx php-fpm php-common
  • php 확장 설치
  • yum --enablerepo=remi,remi-php72 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
  • nginx 와 php - fpm 자동 시작 설정
  • ## CentOS/RHEL 7 ##
    systemctl start nginx.service
    systemctl enable nginx.service
    systemctl start php-fpm.service
    systemctl enable php-fpm.service
    
    ## CentOS/RHEL 6 ##
    service nginx start ## use restart after update
    chkconfig nginx on
    service php-fpm start
    chkconfig php-fpm on
  • 마지막 으로 자신의 서버 의 실제 상황 에 따라 nginx 의 가상 호스트 를 설정 합 니 다. 인터넷 에 이런 자료 가 많 습 니 다. 주로 다음 과 같은 설정 항목
  • 입 니 다.
    server {
        server_name testsite.local;
        access_log /srv/www/testsite.local/logs/access.log;
        error_log /srv/www/testsite.local/logs/error.log;
        root /srv/www/testsite.local/public_html;
    
        location / {
            index index.html index.htm index.php;
        }
    
        location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }

    참고: Fedora 29 / 28, CentOS / RHEL 7.5 / 6.10 에 Nginx / PHP - FPM 설치

    좋은 웹페이지 즐겨찾기