Centos7 Install Nginx

Centos7 Install Nginx

下载地址

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel 提前安装依赖

解压到目录/usr/local/nginx下面


[root@k8s-master nginx]#  ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --with-http_ssl_module

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

# 开始编译
[root@k8s-master nginx] make && make install 

编译后目录记录

编译后的目录结构

  • 添加为服务,开机启动
[Unit]
Description=Nginx HTTP ServerAfter=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 stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@k8s-master nginx]# vim /etc/systemd/system/nginx.service
[root@k8s-master nginx]# 
[root@k8s-master nginx]# systemctl daemon-reload
[root@k8s-master nginx]# systemctl enable nginx
[root@k8s-master nginx]# 
[root@k8s-master nginx]# systemctl start nginx
[root@k8s-master nginx]# systemctl status nginx
● nginx.service - Nginx HTTP ServerAfter=network.target
   Loaded: loaded (/etc/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-07-28 10:11:54 CST; 8s ago
  Process: 3288 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 3292 (nginx)
    Tasks: 2
   Memory: 1.4M
   CGroup: /system.slice/nginx.service
           ├─3292 nginx: master process /usr/local/nginx/sbin/nginx
           └─3293 nginx: worker process

Jul 28 10:11:53 k8s-master systemd[1]: Starting Nginx HTTP ServerAfter=network.target...
Jul 28 10:11:54 k8s-master systemd[1]: Started Nginx HTTP ServerAfter=network.target.
[root@k8s-master nginx]# lsof -i :80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   3292   root    6u  IPv4 738460      0t0  TCP *:http (LISTEN)
nginx   3293 nobody    6u  IPv4 738460      0t0  TCP *:http (LISTEN)
[root@k8s-master nginx]# 
  • 6
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jc0803kevin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值