• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
2022
博客园    首页    新随笔    联系   管理    订阅  订阅

nginx 源码安装

nginx 源码安装

1.下载源码包
# nginx.org
wget  http://nginx.org/download/nginx-1.20.0.tar.gz
2.解压
tar xf   nginx-1.20.0.tar.gz -C /opt/
3.编译检查
[root@pingweb03 opt]# cd nginx-1.20.0/
[root@pingweb03 nginx-1.20.0]# ./configure

 # 安装所需要的包
 [root@pingweb03 nginx-1.20.0]# yum install libxml2 libxml2-devel
 [root@pingweb03 nginx-1.20.0]# ./configure --prefix=/usr/local/nginx-1.16.1 --user=www --group=www --without-http_gzip_module --without-http_rewrite_module
4.安装
 [root@pingweb03 nginx-1.20.0]#  make -j
 [root@pingweb03 nginx-1.20.0]#  make install 
5.环境变量
[root@pingweb03 nginx-1.20.0]# cat /etc/profile.d/nginx.sh 
export PATH=$PATH:/usr/local/nginx-1.20.0/sbin
# export PATH=$PATH:/usr/local/php/sbin
6.开机自启
#启动时没有办法使用system管理,需要我们自己配置

[root@web3 system]# ln /usr/local/nginx-1.20.0 /usr/local/nginx

[root@web3 system]# cat /usr/lib/systemd/system/nginx.service 
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop


[Install]
WantedBy=multi-user.target

[root@web3 system]# systemctl daemon-reload
#启动
[root@pingweb03  ~]# systemctl start nginx
#添加完成以后保存,使用systemctl list-unit-files --type=service查看有没有nginx-fpm.service
#如果没有就是用systemctl daemon-reload重新加载,在使用以上命令查看

#添加开机自启 
[root@pingweb03  ~]# systemctl start nginx
posted @ 2021-04-27 10:09  博客之记  阅读(179)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3