您的位置:首页 > 运维架构 > Nginx

linux 安装nginx

2016-08-27 20:00 295 查看
Nginx介绍

Nginx ("engine x") 是一个高性能的HTTP和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 服务器。Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。

特点:

Nginx是一款面向性能设计的HTTP服务器,相较于Apache、lighttpd具有占有内存少,稳定性高等优势。

优点:

1.处理静态文件,索引文件以及自动索引;打开文件描述符缓冲.

2.无缓存的反向代理加速,简单的负载均衡和容错.

3.FastCGI,简单的负载均衡和容错.

4.模块化的结构。包括gzipping, byte ranges, chunked responses, 以及 SSI-filter等filter。如果由FastCGI或其它代理服务器处理单页中存在的多个SSI,则这项处理可以并行运行,而不需要相互等待。

5.支持SSL 和 TLS SNI.

安装前准备

系统版本

[root@linuxidc ~]# cat /etc/RedHat-release 
CentOS release 6.5 (Final)

[root@linuxidc ~]# uname -r

2.6.32-431.23.3.el6.x86_64

[root@linuxidc ~]# uname -m

x86_64

安装依赖包

1.pcre库 perl兼容正则表达式

安装pcre库后nginx可以使用URI重写功能和rewrite模块。

检查pcre是否安装

[root@linuxidc ~]# rpm -qa pcre pcre-devel

pcre-devel-7.8-7.el6.x86_64

pcre-7.8-7.el6.x86_64

可以使用yum安装

[root@linuxidc ~]# yum install pcre pcre-devel -y

2.openssl-devel

安装openssl-devel后nginx可以使用加密服务

检查openssl-devel是否安装

[root@linuxidc ~]# rpm -qa openssl-devel

openssl-devel-1.0.1e-42.el6_7.4.x86_64

可以使用yum安装

[root@linuxidc ~]# yum install openssl-devel -y

安装nginx

下载目录

[root@linuxidc ~]# mkdir -p /home/evan/tools/

[root@linuxidc ~]# cd /home/evan/tools/

下载nginx

[root@linuxidc tools]# wget http://nginx.org/download/nginx-1.8.1.tar.gz
[root@linuxidc tools]# ls -l nginx-1.8.1.tar.gz 

-rw-r--r-- 1 root root 833473 1月  27 00:30 nginx-1.8.1.tar.gz

解压

[root@linuxidc tools]# tar xf nginx-1.8.1.tar.gz 

创建用户nginx所需用户(这里可以根据个人环境创建)

[root@linuxidc tools]# useradd -s /sbin/nologin -M www

不创建服务可能跑不起来

编译安装

[root@linuxidc tools]# cd nginx-1.8.1

编译参数

./configure --user=www --group=www \

--prefix=/application/nginx-1.8.1/ \

--with-http_stub_status_module \

--with-http_ssl_module

make

make install

去版本号方便维护管理

[root@linuxidc nginx-1.8.1]# ln -s /application/nginx1.8.1/ /application/nginx

启动nginx

检查语法

[root@linuxidc nginx-1.8.1]# /application/nginx/sbin/nginx -t

nginx: the configuration file /application/nginx1.8.1/conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx1.8.1/conf/nginx.conf test is successful

启动

[root@linuxidc nginx-1.8.1]# /application/nginx/sbin/nginx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx linux