linux nginx1.24.0安装

nginx高性能web服务器,可作为一般http应用转发,也可以做mySql、redis、zk、rabbit MQ等tcp数据流转发。

常用Linux服务系统centos和ububtu 只是安装命令不同 yum/apt-get,流程和依赖包是一样的安装方式

1、下载nginx安装包tar.gz官方下载地址
wget https://nginx.p2hp.com/download/nginx-1.24.0.tar.gz
2、安装所有的nginx需要的依赖

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel automake autoconf libtool make

3、解压nginx压缩包,进入解压后的nginx目录

tar -xvf ./nginx-1.24.0.tar.gz

cd ./nginx

4、执行编译
以下编译命令中增加模块有,ssl支持 stream支持,需要其他的模块可以自行添加即可。这里配置安装目录为/usr/local/nginx

# 编译
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream

# 安装
make && make install

5、进入安装目录

cd /usr/local/nginx

6、启动

./sbin/nginx -c ./conf/nginx.conf

7、常用命令

# 启动nginx
./sbin/nginx -c ./conf/nginx.conf
# 停止
./sbin/nginx -s stop
# 修改配置文件后重新加载配置文件
# 检测配置文件是否有错
./sbin/nginx -t
# 重新加载配置
./sbin/nginx -s reload
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您可以按照以下步骤编译安装nginx 1.24.0: 1. 首先,下载nginx的源码包。您可以访问官方网站的下载页面,找到对应版本的源码包,并将其下载到您的CentOS服务器上。 2. 安装编译nginx所需的依赖项。 3. 解压源码包,并进入解压后的目录。 4. 运行配置命令,指定安装路径、用户和组,并选择需要的模块。例如: ``` ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module ``` 这个命令将设置nginx安装路径为`/usr/local/nginx`,将使用`nginx`用户和组运行nginx,并启用`stub_status`模块。 5. 运行`make`命令编译nginx,并使用`make install`命令安装nginx。 6. 创建nginx用户组,以及nginx用户,并指定其使用`/sbin/nologin`作为shell。 7. 解压下载的源码包,并进入解压后的目录。 8. 运行配置命令,指定用户和组,以及其他需要的模块。例如: ``` ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-openssl=/usr/local/openssl ``` 这个命令将设置nginx的用户和组为`nginx`,安装路径为`/usr/local/nginx`,并启用一些常用的模块,如`stream`模块、`http_ssl`模块和`http_gzip_static`模块等。 9. 运行`make`命令编译nginx,并使用`make install`命令安装nginx。 10. 配置启动脚本。将nginx可执行文件拷贝到`/etc/rc.d/init.d/`目录,并设置正确的权限。然后,使用`chkconfig`命令将nginx添加到系统服务,并使用`service`命令启动nginx。 ``` cp /opt/nginx-1.24.0/nginx /etc/rc.d/init.d/ chmod 744 /etc/rc.d/init.d/nginx chkconfig nginx on service nginx start ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值