fedora 에 실행 nginx 설치

8173 단어 Linux
배경:
windows 10 시스템 개발 환경 에 서 는 여러 가지 문제 가 자주 발생 하 는데, 오늘 오전 에는 또 이해 할 수 없 는 문제 가 발생 했 지만, 임무 가 급 해 자신의 컴퓨터 개발 을 생각 하고 있다.자신의 컴퓨터 를 사용 할 때 fedora 시스템, 프로젝트 에 nginx 를 사 용 했 기 때문에 fedora 에 설치 해 야 하기 때문에 이 글 이 있 습 니 다.
설치 절차
원본 코드 를 다운로드 한 후 컴 파일 하여 설치 하려 고 했 는데 make 가 항상 실 패 했 기 때문에 어 쩔 수 없 이 창고 에서 dnf 를 설치 할 수 밖 에 없 었 습 니 다.
레 퍼 런 스
  • dnf install nginx
  • systemctl enable nginx. service 가 시 작 될 때 nginx 서 비 스 를 자동 으로 시작 합 니 다
  • systemctl start nginx. service 수 동 으로 nginx 를 시작 할 수도 있 고 service nginx start | stop | restart 를 사용 하여 nginx
  • 를 제어 할 수도 있 습 니 다.
  • nginx. conf 파일 을 설정 합 니 다. nginx. conf 파일 은 제 가 windows 시스템 에서 복사 한 것 이기 때문에 복사 한 파일 은 루트 사용자 / 사용자 그룹 이 아 닌 자신 에 게 속 합 니 다. nginx 는 루트 사용자 에 속 하기 때문에 고치 지 않 으 면 파일 권한 문제 로 실패 할 수 있 습 니 다.chown -R root:root nginx.conf

  • 이 때 프로젝트 를 시작 하면 브 라 우 저 에서 일부 자원, js, css, 이미지 403 에 접근 할 수 없습니다.나 도 방법 을 많이 찾 아 봤 는데 안 돼.마지막 으로 seLinux 문제 가 발 견 됐 습 니 다.seLinux 는 잘 모 르 겠 습 니 다. 다만 안전 과 밀접 한 관 계 를 알 고 있 을 뿐 입 니 다.다음 명령 을 사용 하여 자세 한 정 보 를 볼 수 있 습 니 다: journalctl - xe 는 seLinux 에 관 한 문 제 를 알 릴 수 있 습 니 다.
    journalctl  -xe
                                                           Do
                                                           allow this access for now by executing:
                                                           # ausearch -c 'nginx' --raw | audit2allow -M my-nginx
                                                           # semodule -X 300 -i my-nginx.pp
    
    12  26 11:37:22 localhost.localdomain setroubleshoot[4902]: SELinux is preventing nginx from name_connect access on the tcp_socket port 20050. For complete SELinux messages
    12  26 11:37:22 localhost.localdomain python3[4902]: SELinux is preventing nginx from name_connect access on the tcp_socket port 20050.
    
                                                           *****  Plugin connect_ports (85.9 confidence) suggests   *********************
    
                                                           If you want to allow nginx to connect to network port 20050
                                                           Then you need to modify the port type.
                                                           Do
                                                           # semanage port -a -t PORT_TYPE -p tcp 20050
                                                               where PORT_TYPE is one of the following: dns_port_t, dnssec_port_t, http_port_t, kerberos_port_t, ocsp_port_t.
    
                                                           *****  Plugin catchall_boolean (7.33 confidence) suggests   ******************
    
                                                           If you want to allow httpd to can network connect
                                                           Then you must tell SELinux about this by enabling the 'httpd_can_network_connect' boolean.
    
                                                           Do
                                                           setsebool -P httpd_can_network_connect 1
    
                                                           *****  Plugin catchall_boolean (7.33 confidence) suggests   ******************
    
                                                           If you want to allow nis to enabled
                                                           Then you must tell SELinux about this by enabling the 'nis_enabled' boolean.
    
                                                           Do
                                                           setsebool -P nis_enabled 1
    
                                                           *****  Plugin catchall (1.35 confidence) suggests   **************************
    
                                                           If you believe that nginx should be allowed name_connect access on the port 20050 tcp_socket by default.
                                                           Then you should report this as a bug.
                                                           You can generate a local policy module to allow this access.
                                                           Do
                                                           allow this access for now by executing:
                                                           # ausearch -c 'nginx' --raw | audit2allow -M my-nginx
                                                           # semodule -X 300 -i my-nginx.pp
    
    12  26 11:37:25 localhost.localdomain google-chrome.desktop[4501]: [4501:4540:1226/113725.433785:ERROR:connection_factory_impl.cc(386)] Failed to connect to MCS endpoint wi
    
    

    seLinux 보안 명단 에 nginx 를 추가 하면 됩 니 다.seLinux 는 세 가지 모델 이 있 는데 그것 이 바로:
  • enforcing: 강제 모드 는 SELinux 운영 을 대표 하고 domain / type 을 정확하게 제한 하기 시 작 했 습 니 다.
  • permissive: 관용 모드: SELinux 운영 을 대표 하지만 경고 메시지 만 있 을 뿐 domain / type 의 접근 을 실제 적 으로 제한 하지 않 습 니 다.이 모드 는 SELinux 의 debug 로 운 송 될 수 있 습 니 다.
  • disabled: 닫 기, SELinux 는 실제 작 동 하지 않 습 니 다.먼저 관용 모드 로 시도 해 보 세 요: setenforce 0 에 다시 접근 하면 됩 니 다.이 문제 인 것 같 습 니 다. 보안 모드 를 다시 시작 합 니 다 setenforce 1
  • seLinux 보안 명단 추가: semodule - i mynginx. pp

  • 이상 의 절 차 는 nginx 의 설 치 를 완성 하 였 습 니 다.

    좋은 웹페이지 즐겨찾기