nginx 다 중 포트 접근 다 중 항목 설정

3549 단어 nginx포트conf
최근 에 막 출근 하기 시 작 했 는데 회 사 는 nginx 서버 를 사용 합 니 다.로 컬 개발 테스트 에서 하나의 localhost 는 서로 다른 포트 를 가리 키 며 서로 다른 프로젝트 경 로 를 가리킨다.예 를 들 어 localhost: 80 은 D: / WWW 디 렉 터 리 를 가리 키 고 localhost: 801 은 D: / bbs 디 렉 터 리 를 가리킨다.기본적으로 localhost 의 80 포트 는 설치 환경 에서 지정 한 경 로 를 가리 키 고 있 습 니 다.
설정 도 간단 합 니 다. 아파 치 설정 과 차이 가 많 지 않 습 니 다. nginx / conf / nginx. conf 를 열 고 기본 server 설정 을 찾 습 니 다.
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root   "D:/WWW";
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

801 포트 를 추가 하고 경 로 는 D: / procject 를 가리 키 는 server 설정 을 복사 합 니 다.
설정 은 다음 과 같 습 니 다:
        server {
        listen       801;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root   "D:/project";
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

완료 후 nginx 를 다시 시작 하면 주소 표시 줄 을 통 해 localhost: 801 을 방문 할 수 있 습 니 다. 예 를 들 어 localhost: 801 / test. php, 그리고 localhost 는 기본적으로 80 포트 를 가리 키 고 있 습 니 다.

좋은 웹페이지 즐겨찾기