cent7配置nginx(一),nginx基础安装

1 篇文章 0 订阅

这文章主要讲一下nginx的安装。

说明:本文章内容已经在CentOS Linux release 7.3.1611 (Core)上测试通过。

访问nginx官网下载适合的nginx版本,使用tar命令解压,进入解压目录执行

./configure

在centos7.3执行上面命令会出现如下错误,

错误内容1:

./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 -y install pcre-devel

错误内容2:

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

解决方法:

yum install -y zlib-devel

错误内容23

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

解决方法:

yum install gcc

接着执行

./configure
make
make install

安装便可成功。

进入/usr/local/nginx/sbin执行./nginx可以启动nginx,执行netstat -nlp可以看到80端口已经被监听,在浏览器输入http://127.0.0.1可以看到Welcome to nginx!表示nginx已经启动成功。

nginx环境变量配置

每次操作nginx都需要进入/usr/local/nginx/sbin目录中,过于繁琐,因此可以在通过配置nginx环境变量解决,如下配置,执行

vim /etc/profile

打开环境配置文件,

HGINX_HOME=/usr/local/nginx/sbin
PATH=$PATH:$HGINX_HOME:
export PATH

修改好以后,执行source /etc/profile是配置生效。

最后附上安装nginx必备的所有的库,如果在编译安装nginx报错的情况下请检查如下库

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

nginx常用命令参考:http://www.jb51.net/article/47750.htm

==手机QQ扫描下方二维码,快速加入Java架构师交流群==

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值