linux的nginx安装

本文详细描述了在CentOS系统中通过yum安装Nginx和源码编译安装的方法,包括下载软件源、安装依赖、配置用户组、编译及安装过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、yum安装

1.下载安装nginx 的软件源
[root@localhost ~]# wget https://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root@localhost ~]# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
2. 安装nginx
[root@localhost ~]# yum install -y nginx

二、源码安装

1.安装依赖环境、库
gcc环境、pcre重写功能、压缩解压缩库zlib、安全套接字层密码库openssl
[root@localhost nginx]# yum install -y gcc gcc-c++ autoconf automake make pcre pcre-devel zlib zlib-devel make libtool openssl-devel
2.创建用户和用户组
[root@localhost ~]# useradd nginx
[root@localhost ~]# groupadd nginx
3.下载、解压并编译对应版本压缩包(我这里是1.18.0)
[root@localhost ~]# wget https://nginx.org/download/nginx-1.18.0.tar.gz
[root@localhost ~]# tar zxf nginx-1.18.0.tar.gz
[root@localhost ~]# cd nginx-1.18.0/
##检查安装环境
[root@localhost nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --user=nginx --group=nginx --with-cc-opt="-Wno-error=deprecated-declarations"
[root@localhost nginx-1.18.0]# make  #编译
[root@localhost nginx-1.18.0]# install   #安装
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值