Ubuntu环境安装nginx-1.24.0

# 1. 创建service目录
mkdir service

# 2. 进入service
cd service

# 3. 下载nginx
curl -o nginx-1.24.0.tar.gz https://nginx.org/download/nginx-1.24.0.tar.gz

# 4. 解压
tar -zxvf nginx-1.24.0.tar.gz

# 5. 进入nginx-1.24.0
cd nginx-1.24.0

# 6. 执行./configure
./configure

# 如果出现 ./configure: error: C compiler cc is not found
sudo apt-get install gcc
sudo apt-get install g++
./configure

#  如果出现 ./configure: error: the HTTP rewrite module requires the PCRE library.
# You can either disable the module by using --without-http_rewrite_module
# option, or install the PCRE library into the system, or build the PCRE library
# statically from the source with nginx by using --with-pcre=<path> option.
# 需要安装pcre 依赖
sudo apt-get install libpcre3-dev
./configure

# 如果出现 ./configure: error: the HTTP gzip module requires the zlib library.
# You can either disable the module by using --without-http_gzip_module
# option, or install the zlib library into the system, or build the zlib library
# statically from the source with nginx by using --with-zlib=<path> option.
# 需要安装zlib 依赖
sudo apt-get install zlib1g.dev
# 然后在执行 
./configure

# 出现此内容说明执行成功
# Configuration summary
#  + using system PCRE library
#  + OpenSSL library is not used
#  + using system zlib library
#  nginx 提醒OpenSSL library没使用
#  安装OpenSSL library依赖
sudo apt-get install openssl
sudo apt-get install libssl-dev

#  nginx 编译的默认位置
#  nginx path prefix: "/usr/local/nginx"
#  nginx binary file: "/usr/local/nginx/sbin/nginx"
#  nginx modules path: "/usr/local/nginx/modules"
#  nginx configuration prefix: "/usr/local/nginx/conf"
#  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
#  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
#  nginx error log file: "/usr/local/nginx/logs/error.log"
#  nginx http access log file: "/usr/local/nginx/logs/access.log"
#  nginx http client request body temporary files: "client_body_temp"
#  nginx http proxy temporary files: "proxy_temp"
#  nginx http fastcgi temporary files: "fastcgi_temp"
#  nginx http uwsgi temporary files: "uwsgi_temp"
#  nginx http scgi temporary files: "scgi_temp"

# 设置系统配置参数
./configure --with-http_ssl_module --with-http_v2_module --with-stream

# 7. 编译
make 

# -bash: make: command not found
sudo apt-get update
sudo apt-get install make
make 


# 8. 安装
make install

# 9.启动nginx
nginx
-bash: nginx: 未找到命令
# 需要修改环境变量
# vim /etc/profile
# 在最后一排输入 export PATH=$PATH:/usr/local/nginx/sbin
# source /etc/profile
  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值