阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux(RHEL7.0)下安装Nginx-1.10.2

178次阅读
没有评论

共计 3001 个字符,预计需要花费 8 分钟才能阅读完成。

Linux(RHEL7.0)下安装 Nginx-1.10.2

阅读目录

  • 查看当前系统版本是否支持
  • 下载
  • 配置
  • 编译
  • 启动服务
  • 验证服务是否启动
  • 遇到的问题
 

查看当前系统版本是否支持

当前,nginx 发布包支持以下 Linux 操作系统版本:

RHEL/CentOS:

Version Supported Platforms
5.x x86_64, i386
6.x x86_64, i386
7.x x86_64, ppc64le

Debian:

Version Codename Supported Platforms
7.x wheezy x86_64, i386
8.x jessie x86_64, i386

Ubuntu:

Version Codename Supported Platforms
12.04 precise x86_64, i386
14.04 trusty x86_64, i386, aarch64/arm64
16.04 xenial x86_64, i386, ppc64el

SLES:

Version Supported Platforms
12 x86_64

我们可以在命令行输入命令 “cat /etc/os-release” 查看当前操作系统版本,如下所示:

[root@localhost local]# cat /etc/os-release
NAME=”Red Hat Enterprise Linux Server”
VERSION=”7.0 (Maipo)”
ID=”rhel”
ID_LIKE=”Fedora”
VERSION_ID=”7.0″
PRETTY_NAME=”Red Hat Enterprise Linux Server 7.0 (Maipo)”
ANSI_COLOR=”0;31″
CPE_NAME=”cpe:/o:RedHat:enterprise_linux:7.0:GA:server”
HOME_URL=”https://www.redhat.com/”
BUG_REPORT_URL=”https://bugzilla.redhat.com/”

REDHAT_BUGZILLA_PRODUCT=”Red Hat Enterprise Linux 7″
REDHAT_BUGZILLA_PRODUCT_VERSION=7.0
REDHAT_SUPPORT_PRODUCT=”Red Hat Enterprise Linux”
REDHAT_SUPPORT_PRODUCT_VERSION=7.0

可见,操作系统属于 RHEL7.X,符合要求。

 

下载

可以输入 wget http://nginx.org/download/nginx-1.10.2.tar.gz 命令直接从网上获取资源包,也可以自己下载。

我这里直接从官网下载 nginx-1.10.2.tar.gz 包,并放到 /usr/local 目录下;

输入 tar -zxvf nginx-1.10.2.tar.gz 命令解压。

 

配置

进入解压后的目录:

cd /usr/local/nginx-1.10.2

开始配置,可以配置各种参数以及是否启用某些模块等,,详细配置参数可参考官网,有很详细的说明,

http://nginx.org/en/docs/configure.html

如下,是我的配置:

./configure --prefix=/usr/local/nginx-1.10.2 \
--conf-path=/etc/nginx/nginx.conf \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-ipv6
 

编译

输入以下命令即可:

make && make install
 

启动服务

进入 sbin 目录,输入 nginx 命令即可,另外重启命令是 nginx -s reload

 

验证服务是否启动

查看进程即可,如下是我的 nginx 服务进程

root    20646    1  0 11:04 ?        00:00:00 nginx: master process nginx
nobody  20647 20646  0 11:04 ?        00:00:00 nginx: worker process

遇到的问题

1、”conf/koi-win” 与 ”/usr/local/nginx/conf/koi-win” 为同一文件”

配置的时候,指定 –conf-path 参数的配置即可。

2、nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

端口被占用了,修改端口号即可。我这里是有个 tomcat 的端口配置为 80,改成其它的即可。

更多 Nginx 相关教程见以下内容

CentOS 6.2 实战部署 Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm

使用 Nginx 搭建 WEB 服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm

搭建基于 Linux6.3+Nginx1.2+PHP5+MySQL5.5 的 Web 服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

CentOS 6.3 下 Nginx 性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm

CentOS 6.3 下配置 Nginx 加载 ngx_pagespeed 模块 http://www.linuxidc.com/Linux/2013-09/89657.htm

CentOS 6.4 安装配置 Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx 安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm

Nginx 日志过滤 使用 ngx_log_if 不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-10/136484.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3001字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中