centos 7 의 nginx 설정 자동 시작

centos 7 이상 은 Systemd 로 시스템 을 초기 화 했 습 니 다. Systemd 는 Linux 시스템 의 최신 초기 화 시스템 (init) 입 니 다. 주요 디자인 목 표 는 sysvint 의 고유 한 단점 을 극복 하고 시스템 의 작 동 속 도 를 향상 시 키 는 것 입 니 다.Systemd 에 대한 자세 한 정 보 는 여기 있 습 니 다.
Systemd 서비스 파일 은. service 로 끝 납 니 다. 예 를 들 어 지금 nginx 를 시작 하려 고 합 니 다. yum install 명령 으로 설치 하면 yum 명령 은 자동 으로 nginx. service 파일 을 만 들 고 명령 을 직접 사용 합 니 다: systemcel enable nginx. service
시동 을 걸 면 됩 니 다.여기 서 저 는 원본 코드 로 컴 파일 되 어 설치 되 어 있 기 때문에 nginx. service 서비스 파일 을 수 동 으로 만 들 려 고 합 니 다.로그 인하 지 않 고 실행 할 수 있 는 프로그램 입 니 다. 시스템 서비스 (system) 에 존재 합 니 다. 즉, / lib / systemd / system /
  • 시스템 서비스 디 렉 터 리 에 nginx. service 파일 vi / lib / systemd / system / nginx. service nginx. service 내용 은 다음 과 같다.
  • [Unit]
    Description=nginx
    After=network.target
     
    [Service]
    Type=forking
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s quit
    PrivateTmp=true
     
    [Install]
    WantedBy=multi-user.target
    
    Description:    
    After:      
    [Service]         
    Type=forking        
    ExecStart          
    ExecReload     
    ExecStop     
    PrivateTmp=True              
      :[Service]   、  、              
    [Install]              ,       ,        3
    
        。
    
  • 부팅 시스템 ctl enable nginx. service
  • 설정
    이로부터 다시 centos 를 시작 하면 nginx 가 자동 으로 시 작 됩 니 다.
    nginx 기타 명령:
    systemctl start nginx. service (nginx 서비스 시작) systemctl stop nginx. service (nginx 서비스 정지) systemctl enable nginx. service (시동 자동 시작 설정) systemctl disable nginx. service (시동 자동 시작 정지) systemctl status nginx. service (서비스 현재 상태 보기) systemctl restart nginx. service (서비스 재 시작)systemctl list - units -- type = service (시 작 된 모든 서 비 스 를 보기)

    좋은 웹페이지 즐겨찾기