#############
# nginx 설치 #
#############
## 설치
# yum repo 설정.
$ cat << EOF > /etc/yum.repos.d/nginx.repo
[nginx]
name=Nginx Repository \$basearch - Archive
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
enabled=1
gpgcheck=1
gpgkey=https://nginx.org/keys/nginx_signing.key
EOF
# yum install
$ yum install nginx
# version
$ nginx -v
nginx version: nginx/1.16.1
## 설정
# nginx 환경설정 파일을 수정.
$ vi /etc/nginx/conf.d/default.conf
server {
# 캐릭터셋 변경
#charset koi8-r;
charset utf-8;
# root 디렉토리 설정.
# location / {} 안에 설정한 root 폴더를 밖으로.
root /var/www;
location / {
# root 디렉토리 변경
# root /usr/share/nginx/html;
# php 연동할 경우 location root 설정은 제거
index index.html index.htm;
}
location ~ \.php$ {
# /var/run/php-fpm/www.sock 경로에 파일이 있는지 확인
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
## 시작
# 서비스 시작.
$ systemctl start nginx
###############
# php-fpm 설치 #
###############
## 설치
# yum 패키지매니저에 저장소 REMIREPO 설치
$ yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ yum install epel-release yum-utils
# remirepo php7.3 활성화
$ yum-config-manager --disable remi-php54
$ yum-config-manager --enable remi-php73
# 설치(설치할때 7.3.X 버전으로 설치하고있는지 주의)
$ yum install php-fpm
# 기타 php 확장라이브러리 설치
yum install php-fpm php-cli php-brotli php-intl php-gd php-gmp php-imap php-bcmath php-interbase php-json php-mbstring php-mysqlnd php-odbc php-opcache php-tidy php-pdo php-pdo-dblib php-pear php-pgsql php-process php-pecl-apcu php-pecl-geoip php-pecl-gmagick php-pecl-hrtime php-pecl-json php-pecl-mongodb php-pecl-rar php-pecl-pq php-pecl-yaml php-pecl-zip
# version
$ php -version
PHP 7.3.15 (cli) (built: Feb 18 2020 09:25:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.15, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.15, Copyright (c) 1999-2018, by Zend Technologies
## 시작
# 서비스 시작.
$ systemctl restart php-fpm
## 설정
# php-fpm 설정파일 수정
$ vi /etc/php-fpm.d/www.conf
# php-fpm: fast CGI 모듈
; socket 통신으로 설정
;listen = 127.0.0.1:9000
listen = '/var/run/php-fpm/www.sock'
# 사용자 설정 (웹 데몬 설정)
listen.acl_users = nginx
# 아래를 해두지 않으면 php-fpm 으로 www.sock 이 실행되어도 권한때문에 연결이 되지 않는다.
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
# ?
chdir = /var/www
# catch_workers_output
# - no : worker 가 출력하는 error log 가 /dev/null 로 가 버리므로 에러가 발생해도 원인을 찾기가 어렵다.
# - yes : main error log 파일에 worker 의 에러 로그가 같이 남게 된다.
catch_workers_output = yes
## 재시작
# 설정 후 재시작.
systemctl restart php-fpm
systemctl restart nginx
## 추가 설정
# 서비스 자동시작 등록
$ systemctl enable php-fpm
$ systemctl enable nginx
'Server' 카테고리의 다른 글
http header 정보. (0) | 2017.04.12 |
---|