【nginx】源码安装nginx

基于Linux环境源码安装nginx服务

1、登录nginx官网下载nginx的安装包
nginx官网地址:https://nginx.org/en/download.html
下载nginx

[root@k8s opt]# wget https://nginx.org/download/nginx-1.26.1.tar.gz
--2024-07-23 14:26:27--  https://nginx.org/download/nginx-1.26.1.tar.gz
Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:5c0:2600::6, ...
Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1244738 (1.2M) [application/octet-stream]
Saving to: ‘nginx-1.26.1.tar.gz’

100%[=====================================================================================>] 1,244,738   1.45MB/s   in 0.8s

2024-07-23 14:26:29 (1.45 MB/s) - ‘nginx-1.26.1.tar.gz’ saved [1244738/1244738]

2、安装nginx编译需要的依赖

[root@k8s opt]# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

3.创建一个nginx的安装目录,并将nginx解压导安装目录

[root@k8s opt]# mkdir -p /usr/local/nginx
[root@k8s opt]# tar -xvf nginx-1.26.1.tar.gz -C /usr/local/nginx

4、安装nginx

#进入安装目录
[root@k8s opt]# cd /usr/local/nginx/
[root@k8s nginx]# cd nginx-1.26.1
#执行命令 考虑到后续安装ssl证书 添加两个模块
[root@k8s nginx-1.26.1]# ./configure --with-http_stub_status_module --with-http_ssl_module
[root@k8s nginx-1.26.1]# make
[root@k8s nginx-1.26.1]# make install

5、启动nginx

安装完成后/usr/local/nginx 会有一个sbin

[root@k8s sbin]# cd /usr/local/nginx/sbin
[root@k8s sbin]# ./nginx
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装nginx源码包,您可以按照以下步骤进行操作: 1. 首先,您需要下载nginx源码包。您可以从官方网站上下载最新版本的源码包。您可以在http://nginx.org/download/找到最新的源码包下载链接。 2. 下载完成后,解压源码包。您可以使用tar命令来解压文件。例如,如果您的源码包是nginx-1.20.1.tar.gz,您可以使用以下命令进行解压: ``` tar -zxvf nginx-1.20.1.tar.gz ``` 3. 进入解压后的目录: ``` cd nginx-1.20.1 ``` 4. 在源码目录中,执行configure命令进行配置。该命令将根据您的系统环境进行一些必要的配置: ``` ./configure ``` 5. 配置完成后,运行make命令编译源码: ``` make ``` 6. 编译完成后,运行make install命令将nginx安装到系统中: ``` make install ``` 7. 安装完成后,您可以检查是否成功安装nginx。您可以使用id命令来检查是否存在nginx用户: ``` id nginx ``` 以上就是nginx源码安装的一般步骤。请注意,这里只提供了基本的安装步骤,具体的安装过程可能会因系统环境和配置需求而有所不同。建议您在安装前阅读官方文档或参考更详细的安装指南以确保正确安装nginx。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [nginx源码安装](https://blog.csdn.net/weixin_49185464/article/details/127326489)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值