Linux Nginx安装

Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。下面就来说明一下它的安装步骤。

1、下载压缩包

http://nginx.org/

2、上传到Linux

我是使用rz/sz命令把下载好的压缩包上传到目录.

/carl/data/program/

创建nginx的安装目录,与源码目录区分开。

/carl/data/program/nginx
3、解压nginx
tar -zxvf nginx-1.10.3.tar.gz

然后

cd nginx-1.10.3
4、安装nginx

安装nginx到指定目录,就也就第二步创建的目录。

./configure --prefix=/carl/data/program/nginx

注意:可能出现以下错误。

1)缺少gcc

checking for OS
 + Linux 3.10.0-327.el7.x86_64 x86_64
checking for C compiler ... not found

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

使用下面命令安装

yum -y install make gcc gcc-c++ ncurses-devel

2)缺少pcre

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

3)缺少zlib


./configure: error: the HTTP gzip module requires the zlib library.

使用以下命令安装:

yum -y install zlib zlib-devel
5、编译
make&&make install
6、启动Nginx
/carl/data/program/nginx/sbin/nginx [-c nginx.conf]

访问虚拟机地址:

这里写图片描述

7、nginx命令总结

1) 启动命令

NGINX_HOME/sbin/nginx -c nginx.conf

2) 停止服务

NGINX_HOME/sbin/nginx -s stop

3) 检验配置文件语法格式

NGINX_HOME/sbin/nginx -t

4) 重新加载配置文件(重启)

NGINX_HOME/sbin/nginx -s reload
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值