前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux(centos)安装nginx

Linux(centos)安装nginx

作者头像
上帝
发布2021-04-09 15:08:26
1.3K0
发布2021-04-09 15:08:26
举报
文章被收录于专栏:影子影子

Linux(centos)安装nginx

转载请注明出处https://cloud.tencent.com/developer/article/1811140

注意,本教程安装环境为centos7,使用nginx官网压缩包编译安装(非rpm或apt),本人亲测有效~

chapter One: 卸载系统自带nginx

  • 停止Nginx软件。 service nginx stop
  • 删除Nginx的自动启动。 chkconfig nginx off
  • 删除yum安装 yum remove nginx
  • 从源头删除Nginx rm -rf /usr/sbin/nginx rm -rf /etc/nginx rm -rf /etc/init.d/nginx

chapter Two: 安装nginx

  • 更新依赖
代码语言:txt
复制
- `yum update`
- `yum install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed`下载
  • 解压 tar -xvzf nginx-1.18.0.tar.gz
  • 添加nginx用户及用户组
代码语言:javascript
复制
 useradd nginx
 usermod -s /sbin/nologin nginx
  • 编译
  • 进入:cd nginx-1.18.0
  • 帮助项: ./configure --help
  • 编译:./configure --user=nginx --group=nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-cpp_test_module --with-cpu-opt=CPU --with-pcre --with-pcre-jit --with-zlib-asm=CPU --with-libatomic --with-debug --with-ld-opt="-Wl,-E"

注意不同版本的nginx其参数可能会有差异,具体请使用--help查看

  • 编译:make && make install

chapter Three: 服务使用

  • start: /usr/sbin/nginx -c /etc/nginx/nginx.conf
  • stop: /usr/sbin/nginx -s stop or kill -9 xxx
  • reload: /usr/sbin/nginx -s reload
  • check status: ps -ef|grep nginx

chapter Four: 防护墙白名单

  • firewall-cmd --zone=public --add-port=80/tcp --permanent
  • firewall-cmd --reload
  • firewall-cmd --zone= public --query-port=80/tcp

-- 以上安装步骤较为简要,如有谬误之处请留言哈?--

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-04-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Linux(centos)安装nginx
    • chapter One: 卸载系统自带nginx
      • chapter Two: 安装nginx
        • chapter Three: 服务使用
          • chapter Four: 防护墙白名单
          相关产品与服务
          命令行工具
          腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档