Centos安装Nginx

1、下载Nginx安装包

快速下载:wget http://nginx.org/download/nginx-1.18.0.tar.gz

官网下载:http://nginx.org/en/download.html

2、安装相关依赖

安装或更新gcc-c++ 依赖

yum -y install gcc gcc-c++ autoconf automake make

否则在安装过程中会报错如下:

./configure: error: C compiler cc is not found

安装或更新pcre、openssl

yum -y install pcre-devel

yum -y install openssl openssl-devel

否则在安装过程中会报错如下:

./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.

安装或更新常用解压或打包工具

yum install -y zip unzip

3、解压Nginx安装包

# 解压到当前目录
tar zxvf nginx-1.18.0.tar.gz

4、配置安装运行目录

# 进入nginx解压目录下
cd /usr/local/nginx/nginx-1.18.0
# 配置安装运行命令
./configure --prefix=/usr/local/nginx/nginx
#若需要https ssl证书模块,执行以下运行命令 ./configure --prefix=/usr/local/nginx/nginx
./configure --prefix=/usr/local/nginx/nginx --with-http_stub_status_module --with-http_ssl_module

参考:https://www.cnblogs.com/aerfazhe/p/15773667.html

5、执行编译安装

make && make install 

6、启动Nginx

# 进入到运行目录
cd /usr/local/nginx/nginx
# 启动Nginx并指定配置文件 -t 测试配置文件是否正确
./sbin/nginx -c conf/nginx.conf
# 停止Nginx -s quit(等待进程处理完毕进行关闭)
./sbin/nginx -s stop
# 重启
./sbin/nginx -s reload

 默认监听80端口,访问测试即可

http://IP/

 

posted @   阿尔法哲  阅读(93)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示