>  기사  >  백엔드 개발  >  nginx 설치 후 php 설치 방법

nginx 설치 후 php 설치 방법

藏色散人
藏色散人원래의
2021-07-17 09:40:152812검색

nginx와 php 설치 방법: 먼저 "yum install php php-fpm"을 통해 PHP와 PHP-FPM을 설치한 다음 php-fpm을 시작한 다음 마지막으로 PHP와 작동하도록 nginx를 구성합니다. .

nginx 설치 후 php 설치 방법

이 기사의 운영 환경: centOS6.8 시스템, PHP7.1 버전, DELL G3 컴퓨터

nginx가 설치된 PHP를 설치하는 방법은 무엇입니까?

PHP 및 PHP-FPM 설치

yum install php php-fpm

php-fpm 시작

systemctl start php-fpm

PHP를 mysql 모듈과 연결

여기 mariadb 데이터베이스가 있습니다.

설치

yum install mariadh mariadb-server

Association

yum install php-gd php-mysql php-mbstring php-xml php-mcrypt  php-imap php-odbc php-pear php -xmlrpc

nginx 구성 PHP 작업

nginx 기본 구성 파일을 엽니다.

vim /etc/nginx/nginx.conf

http 모듈에 구성 추가:

     location / {  
        root   /usr/share/nginx/html;  
           index  index.html index.htm index.php;  
        }  
location ~ \.php$ {  
           root           html;  
           fastcgi_pass   127.0.0.1:9000;  
           fastcgi_index  index.php;  
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;  
           include        fastcgi_params;  
       }

nginx 기본 fastcgiparams 구성 파일 변경: vim /etc/nginx/fastcgi_params 파일 끝에 두 줄 추가:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
fastcgi_param PATH_INFO                $fastcgi_script_name;

그런 다음 서비스를 다시 시작:

service nginx restart
service php-fpm restart

Run

웹사이트의 루트 디렉터리에 index.php 파일을 생성하세요

파일 내용은 다음과 같습니다:

<?php    
phpinfo();    
?>

nginx에서 yum 설치를 위한 기본 웹사이트 루트 디렉터리는 /usr/share/nginx/라는 메시지가 표시됩니다. html

이 폴더에 새 파일을 만드세요

일반적인 상황에서 PHP 파일을 실행하고 액세스할 수 있습니다.

추천 학습: "PHP 비디오 튜토리얼"

위 내용은 nginx 설치 후 php 설치 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.