nginx编译安装

jupiter
2025-08-10 / 0 评论 / 2 阅读 / 正在检测是否收录...

1.依赖安装

yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

2.下载安装包并解压

官网地址:https://nginx.org

wget https://nginx.org/download/nginx-1.27.2.tar.gz
tar -zxvf nginx-1.27.2.tar.gz
cd nginx-1.27.2

3.开始编译安装

./configure --with-http_ssl_module

make && make install

安装完成后的安装目录在/usr/local/nginx

4.配置开机启动项

cd /usr/local/ngin
useradd nginx

vim nginx.service
[Unit]
Description=nginx
After=network.target

[Service]
User=nginx
Group=nginx

Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target
ln -s /usr/local/nginx/nginx.service /usr/lib/systemd/system/nginx.service
systemctl daemon-reload
service nginx status
service nginx restart
service nginx status

5.配置启动bin的软连接

ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
# nginx -V
nginx version: nginx/1.27.2
built by gcc 7.3.0 (GCC)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --with-http_ssl_module
[root@oa-app-7 nginx]#

参考资料

  1. nginx源码编译安装(详解) - penngke - 博客园 (cnblogs.com)
  2. nginx: download
  3. nginx配置https后报错nginx: [emerg] https protocol requires SSL support in XXX.conf详细解决方法-CSDN博客
  4. nginx 普通用户使用80端口启动nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)_nginx 端口80普通用户-CSDN博客
0

评论 (0)

打卡
取消