コンパイルとインストールnginx1.16 Centos7

依存関係をインストールします。1.

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

インストールパッケージをダウンロード2.

wget https://nginx.org/download/nginx-1.16.0.tar.gz

3.解凍してインストール

tar zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
./configure --prefix=/usr/local/nginx	#安装目录
make && make install

インストールが成功したかどうか4.チェック

[root@localhost ~]# nginx -V
nginx version: nginx/1.16.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
configure arguments: --prefix=/usr/local/nginx

5.サービスの開始

cd /usr/local/nginx/sbin
./nginx

サービスが正常に起動するかどうかをチェックします6.

[root@localhost sbin]# netstat -anptu | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      349/nginx: master

7. [追加] nginxのサービス

vi /lib/systemd/system/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

8.スタートはサービスとしてnginxの

pkill nginx
systemctl start nginx

9.は、サービスが開始され

[root@localhost sbin]# systemctl status nginx
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-04-29 23:19:39 EDT; 18min ago
  Process: 348 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 349 (nginx)
    Tasks: 2
   Memory: 976.0K
   CGroup: /system.slice/nginx.service
           ├─349 nginx: master process /usr/local/nginx/sbin/nginx
           └─350 nginx: worker process

Apr 29 23:19:39 localhost.localdomain systemd[1]: Starting nginx...
Apr 29 23:19:39 localhost.localdomain systemd[1]: Started nginx.
[root@localhost sbin]# netstat -ntlp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      349/nginx: master p

サービスのnginxの発売以来10セット

[root@localhost sbin]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
公開された10元の記事 ウォンの賞賛6 ビュー569

おすすめ

転載: blog.csdn.net/J_031591/article/details/104019687