컴퓨터/리눅스 클라우드(AWS, GCP)
Nginx, php 설치 및 연동
Tyson
2018. 2. 22. 12:38
Linux Version 확인
1 cat /etc/*release*
1 | cat /etc/*release* |
NGINX 설치
>yum install nginx
NGINX 실행
>service nginx start
php설치
>yum install yum-priorities
yum-priorities 설치 php5.3으로 설치
>yum install php php-cli php-common php-fpm php-mysql
PHP 연동
1 | vi /usr/share/nginx/html/info.php |
이곳에 아래 내용을 붙여 넣는다. (PHP 코드)
1 2 3 | <?php phpinfo(); ?> |
NGINX 설정 변경
1 | vi /etc/nginx/conf.d/default.conf |
아래 내용을 넣는다. (이미 주석처리 되어 있으므로 주석을 풀어 준다.)
단!! fastcgi-param 부분과 root 부분의 코드가 주석과 다르니 주의 한다.!!
1 2 3 4 5 6 7 | location ~ \.php$ { root /usr/share/nginx/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 재기동 하면, (service nginx restart)
info.php 접속하면 정상으로 보여야 한다.
근데, 이렇게 하면, nginx에서 안뜸..
php-fpm를 실행시켜줘야함.
nginx.conf
/etc/php-fpm.d/www.conf
service 구동
시작할때, php-fpm 이랑, nginx를 실행되게 해줌.
참고블로그 :
http://jongkwang.com/?p=941
https://www.lesstif.com/pages/viewpage.action?pageId=24444977