linux下nginx安装方法

本文详细介绍了在Linux环境中安装Nginx的过程,包括安装依赖包、下载并解压Nginx源码、配置安装路径、编译安装以及验证安装成功的方法。遇到常见报错时,提供了解决方案。

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

因为本人不是很懂linux,所以安装步骤是从网上找的一些资料整合后,才部署成功,现将步骤记录下来

部署安装nainx环境:pcre(作用rewrite)、zlib(作用压缩)、ssl、gcc
yum -y install zlib;
yum –y install pcre;
yum –y install openssl;
yum install gcc gcc-c++ ncurses-devel perl;

2、下载安装nginx-*.tar.gz。     (*号表示版本号

tar –zxvf nginx-*.tar.gz –C ./;     #解压
cd nginx-*;                 #进入目录
./congigure --prefix=/usr/local/nginx;   #配置安装位置 也可不加此参数
make;                       
make install;               #安装  就是将你的解压目录复制到配置文件的指定地点,看执行过程能看出,大部分linux命令执行的是 cp

3、安装完成后执行以下操作验证安装是否成功:

#如果你的安装路径不是这个,那么进入到自己的安装目录下 执行第二条命令
cd  /usr/local/nginx/sbin  
./nginx -t   

结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
至此,nginx的安装已成功完成。


如果在操作第二步时报错,请按以下方法解决:
1.错误提示:./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题:
yum -y install pcre-devel

2.错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决办法:
yum -y install openssl openssl-devel

大部分出现问题,都是缺少依赖包导致,如果还有其他的问题,请安装相对应的依赖包;

转载于:https://www.cnblogs.com/bfx-java/p/5109200.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值