CentOS6.5编译安装Nginx和Openssl

简介:

    Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的小文件并发能力在同类型的网页服务器中表现较好。


Nginx的编译安装:

1.下载Openssl

1
[root@Node1 ~] # wget http://www.openssl.org/source/openssl-1.0.2.tar.gz


2.下载nginx

1
[root@Node1 ~] # wget http://nginx.org/download/nginx-1.6.2.tar.gz


3.解压软件

1
2
[root@Node1 ~] # tar zxf openssl-1.0.2.tar.gz
[root@Node1 ~] # tar zxf nginx-1.6.2.tar.gz


4.编译Nginx

1
2
[root@Node1 ~] # cd nginx-1.6.2
[root@Node1 nginx-1.6.2] # ./configure  --user=www --group=www --prefix=/data/nginx1.6.2 --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/root/openssl-1.0.2

注意:编译nginx添加ssl支持,如果需要编译的openssl,是不需要编译opensll,--with-openssl=DIR DIR是openssl的源码路径,不是openssl的安装路径,否则make时将出错:

1
2
3
4
5
6
7
8
9
10
11
12
make [1]: Entering directory ` /root/nginx-1 .6.2'
cd  /server/openssl  \
         &&  make  clean \
         && . /config  --prefix= /server/openssl/openssl  no-shared  no-threads \
         &&  make  \
         &&  make  install
make [2]: Entering directory ` /server/openssl '
make [2]: *** No rule to  make  target `clean'.  Stop.
make [2]: Leaving directory ` /server/openssl '
make [1]: *** [ /server/openssl/openssl/include/openssl/ssl .h] Error 2
make [1]: Leaving directory ` /root/nginx-0 .7.61'
make : *** [build] Error 2


如果出现

1
2
3
4
. /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.

这说明没有安装pcre &  pcre-devel包,这里yum安装

1
[root@Node1 nginx-1.6.2] # yum -y install pcre pcre-devel


5.安装Nginx

1
2
3
[root@Node1 nginx-1.6.2] # make
 
[root@Node1 nginx-1.6.2] # make install


6.启动之前检查nginx

1
2
3
4
[root@Node1 nginx-1.6.2] # /data/nginx1.6.2/sbin/nginx -t
nginx: the configuration  file  /data/nginx1 .6.2 /conf/nginx .conf syntax is ok
nginx: [emerg] getpwnam( "www" ) failed
nginx: configuration  file  /data/nginx1 .6.2 /conf/nginx .conf  test  failed

检查发现是没有运行用户,新增www账户

1
2
[root@Node1 nginx-1.6.2] # groupadd www
[root@Node1 nginx-1.6.2] # useradd -g www -s /sbin/nologin -d /dev/null www

7.再次检查

[root@Node1 nginx-1.6.2]# /data/nginx1.6.2/sbin/nginx -t
nginx: the configuration file /data/nginx1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx1.6.2/conf/nginx.conf test is successful

8.启动Nginx

1
[root@Node1 nginx-1.6.2] # /data/nginx1.6.2/sbin/nginx

9.检查端口

1
2
[root@Node1 nginx-1.6.2] # netstat -ntlup |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      19849 /nginx

10.检查进程

1
2
3
4
[root@Node1 nginx-1.6.2] # ps aux |grep nginx
root     19849  0.0  0.0  22664   852 ?        Ss   11:19   0:00 nginx: master process  /data/nginx1 .6.2 /sbin/nginx
www      19850  0.0  0.1  23100  1448 ?        S    11:19   0:00 nginx: worker process
root     19858  0.0  0.0 103244   856 pts /0     S+   11:21   0:00  grep  nginx

11.网站访问

wKioL1T2fL_zYxrrAAGEdK_4bkY849.jpg



本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1617167

相关文章
|
13天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
14 0
|
1月前
|
Linux 开发工具 C语言
Centos8下编译安装最新版ffmpeg解决方案(含Centos8换源阿里云)
Centos8下编译安装最新版ffmpeg解决方案(含Centos8换源阿里云)
149 3
|
3月前
|
应用服务中间件 Linux 网络安全
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
109 0
|
2月前
|
Linux 应用服务中间件 网络安全
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
CentOS7搭建本地离线局域网yum源(Httpd/Nginx+yum)
301 0
|
2月前
|
缓存 负载均衡 应用服务中间件
如何在 CentOS 7 上为 NGINX 安装开源 HTTP 加速器:Varnish
如何在 CentOS 7 上为 NGINX 安装开源 HTTP 加速器:Varnish
71 1
如何在 CentOS 7 上为 NGINX 安装开源 HTTP 加速器:Varnish
|
13天前
|
网络协议 应用服务中间件 Linux
centos7 Nginx Log日志统计分析 常用命令
centos7 Nginx Log日志统计分析 常用命令
23 2
|
2月前
|
存储 Linux 应用服务中间件
VMware安装无GUI版本的Linux(CentOS7)——安装Nginx示例demo
VMware安装无GUI版本的Linux(CentOS7)——安装Nginx示例demo
120 1
|
3月前
|
Linux C语言
centos 7 下使用高版本gcc编译安装
centos 7 下使用高版本gcc编译安装
114 0
|
3月前
|
负载均衡 NoSQL 应用服务中间件
Nginx编译安装及配置文件详解
Nginx编译安装及配置文件详解
|
3月前
|
安全 应用服务中间件 Linux
百度搜索:蓝易云【CentOS7使用Nginx、Supervisor部署Go/Golang服务教程】
这些是在CentOS 7 x64上使用Nginx和Supervisor部署Go/Golang服务的基本步骤。根据您的需求和具体环境,可能还需要进行其他配置和调整。请确保在进行任何与网络连接和安全相关的操作之前,详细了解您的网络环境和安全需求,并采取适当的安全措施。
61 0