맛집 여행 캠핑 일상 생활

[NGINX] VirtualHost 도메인별 유저설정 본문

IT이야기

[NGINX] VirtualHost 도메인별 유저설정

영은파더♥ 2020. 7. 22. 17:13

아파치에서는 mod_ruid2 모듈이 있어서 각 도메인 마다 사용자 권한 설정이 가능합니다.

NGINX 에서는 디폴트가 nginx 인데 이를 user, group 을 설정할 수가 있습니다.

cp /etc/opt/remi/php72/php-fpm.d/www.conf /etc/opt/remi/php72/php-fpm.d/example.conf

기존 파일을 하나 복사해서 편집합니다.
참고로 PHP Multiple 버전으로 사용도 가능합니다.

[www]
==>
[www.example.com]

user = apache
group = apache
==>
user = example
group = example

listen = 127.0.0.1:9000
==>
listen = 127.0.0.1:9001

포트는 각 유저당 1개씩 사용이 됩니다.

vi /etc/nginx/conf.d/example.conf

server {
    listen 80;
    server_name www.example.com;
    root   /home/example/www;
    index index.php index.html index.htm;

    access_log /var/log/nginx/access-example.log;
    error_log  /var/log/nginx/error-example.log;

    location / {
        index    index.html index.htm index.php;
    }

    location ~ [^/]\.(php|htm|html)(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

fastcgi_pass 이 부분을 찾아서 포트번호를 적어줍니다.

아파치 설정 방법은 itrooms.tistory.com/976 여기를 참고하세요~

 

Trackback : | Comments :