MAC 하 nginx 80 포트 솔 루 션

2162 단어
nginx 설치 brew 를 통 해
$:brew install nginx
launchd
launchd 에 대한 설명 은 manpage 를 참조 합 니 다. 다음 과 같 습 니 다.
launchd manages processes, both for the system as a whole and for individual users. The primary and preferred interface to launchd is via the launchctl(1) tool which (among other options) allows the user or administrator to load and unload jobs. Where possible, it is preferable for jobs to launch on demand based on criteria specified in their respective configuration files. launchd also manages XPC services that are bundled within applications and frameworks on the system. During boot launchd is invoked by the kernel to run as the first process on the system and to further bootstrap the rest of the system. You cannot invoke launchd directly.
launchd 는 시스템 과 사용자 관리 프로 세 스 에 사 용 됩 니 다. 주로 launchctl 을 통 해 작 동 합 니 다. 사용 자 는 launchd 를 직접 호출 할 수 없습니다.시작 할 때 커 널 에서 launchd 를 호출 하여 첫 번 째 프로 세 스 를 실행 합 니 다.
plist
그리고 우리 가 알 아야 할 것 은 plist 파일 입 니 다.plist 는 property list format 이라는 뜻 으로 애플 이 응용 데 이 터 를 저장 하 는 형식 으로 xml 입 니 다.nginx 에 대응 하 는 plist 파일 을 / usr / local / opt / nginx 에서 찾 을 수 있 습 니 다. 예 를 들 어 제 컴퓨터 에 서 는 homebrew. mxcl. nginx. plist 입 니 다.
그것 의 내용 은 대략 이렇다.




Label
homebrew.mxcl.nginx
RunAtLoad

KeepAlive

ProgramArguments

/usr/local/opt/nginx/bin/nginx
-g
daemon off;

WorkingDirectory
/usr/local



이 파일 을 / Library / LaunchDaemons 에 복사 해 야 합 니 다. ~ / Library / LaunchAgent 라면 괜 찮 지만 차이 가 있 습 니 다.전 자 는 시스템 이 시 작 될 때 시작 하고 후 자 는 사용자 가 로그 인 할 때 시작 합 니 다.이 어 launchctl load - w 를 실행 합 니 다. 다음 과 같 습 니 다.
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
마지막 으로 기 계 를 다시 시작 하면 nginx 가 80 포트 에서 작 동 하 는 것 을 발견 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기