centos 7 컴 파일 설치 nginx

13936 단어
1. 의존 팩 설치
yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel

다운로드
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.14.2.tar.gz

번역
tar -zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
./configure --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module
make && make install

 4. nginx 를 서비스 로 설정 합 니 다.
centos 7 에 서 는 systemd 를 사용 하여 시스템 을 관리 합 니 다. 저 희 는 nginx 를 위해 서비스 파일 을 만 듭 니 다.
vim /lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

이 곳 의 PIDFile 설정 은 앞의 설정 과 일치 해 야 합 니 다.
자동 시작 설정
 
[root@node2 logs]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

 
시작 nginx
[root@node2 logs]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

알림 오류, 상태 보기
[root@node2 logs]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since   2019-04-23 14:06:19 CST; 15s ago
  Process: 5873 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=1/FAILURE)
  Process: 5869 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)

4  23 14:06:16 node2.jinglong nginx[5873]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
4  23 14:06:17 node2.jinglong nginx[5873]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
4  23 14:06:17 node2.jinglong nginx[5873]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
4  23 14:06:18 node2.jinglong nginx[5873]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
4  23 14:06:18 node2.jinglong nginx[5873]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
4  23 14:06:19 node2.jinglong nginx[5873]: nginx: [emerg] still could not bind()
4  23 14:06:19 node2.jinglong systemd[1]: nginx.service: control process exited, code=e...s=1
4  23 14:06:19 node2.jinglong systemd[1]: Failed to start The NGINX HTTP and reverse pr...er.
4  23 14:06:19 node2.jinglong systemd[1]: Unit nginx.service entered failed state.
4  23 14:06:19 node2.jinglong systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

80 포트 가 점용 되 었 음 을 알려 줍 니 다. 이 때 실행:
[root@node2 sbin]# killall -9 nginx
-bash: killall:      

killall 설치
yum install psmisc

더욱 집행 한다
killall -9 nginx

시작 서비스
[root@node2 sbin]# systemctl start nginx
[root@node2 sbin]# 

오류 신고 없 이 상태 확인
[root@node2 sbin]# systemctl status nginx
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since   2019-04-23 14:24:54 CST; 17s ago
  Process: 6864 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
  Process: 6896 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 6893 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
 Main PID: 6897 (nginx)
   CGroup: /system.slice/nginx.service
           ├─6897 nginx: master process /usr/local/nginx/sbin/nginx
           └─6898 nginx: worker process

4  23 14:24:54 node2.jinglong systemd[1]: Starting The NGINX HTTP and reverse proxy server...
4  23 14:24:54 node2.jinglong nginx[6893]: nginx: the configuration file /usr/local/ngin...ok
4  23 14:24:54 node2.jinglong nginx[6893]: nginx: configuration file /usr/local/nginx/co...ul
4  23 14:24:54 node2.jinglong systemd[1]: Started The NGINX HTTP and reverse proxy server.
Hint: Some lines were ellipsized, use -l to show in full.

이 때 running, 시작 성공, 실행
[root@node2 sbin]# curl 127.0.0.1


<head>
Welcome to nginx!

head>


Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to "http://nginx.org/">nginx.org.
Commercial support is available at "http://nginx.com/">nginx.com.

Thank you for using nginx.


페이지 가 져 오기 성공
 소프트 연결 만 들 기
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/

이 때 nginx 는 임의의 디 렉 터 리 에서 명령 을 실행 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기