centos 7 의 nginx 설정 자동 시작
2229 단어 프레임 도구 클래스
Systemd 서비스 파일 은. service 로 끝 납 니 다. 예 를 들 어 지금 nginx 를 시작 하려 고 합 니 다. yum install 명령 으로 설치 하면 yum 명령 은 자동 으로 nginx. service 파일 을 만 들 고 명령 을 직접 사용 합 니 다: systemcel enable nginx. service
시동 을 걸 면 됩 니 다.여기 서 저 는 원본 코드 로 컴 파일 되 어 설치 되 어 있 기 때문에 nginx. service 서비스 파일 을 수 동 으로 만 들 려 고 합 니 다.로그 인하 지 않 고 실행 할 수 있 는 프로그램 입 니 다. 시스템 서비스 (system) 에 존재 합 니 다. 즉, / lib / systemd / system /
[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
。
이로부터 다시 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 (시 작 된 모든 서 비 스 를 보기)