Linux Nginx安装

来源:互联网 发布:centos 7 安装desktop 编辑:程序博客网 时间:2024/06/05 20:00

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_64checking 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_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically 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/ -s reload
0 0
原创粉丝点击