Redhat 5.5 安装nginx

一、安装nginx非常简单,本篇主要说下nginx的特点,以及我对大牛张宴的膜拜。

二、nginx的特点

  1. nginx静态文件处理非常好;反向代理非常好;FastCGI好;稳定性非常好;安全性一般等特点
  2. 我喜欢nginx的原因是内存和cpu占用率低(1个nginx进程消耗15M内存),可以高并发连接
  3. nginx能不能取代apache我不知道,它和apache各有千秋
  4. nginx的模块有很多,这里我只用了两个:

--with-http_stub_status_module  通过web界面查看时nginx的并发连接数需要开启status模块

--with-http_ssl_module          开启http_ssl模块,使nginx可以支持HTTPS请求

三、nginx的停止

1.Nginx支持的信号:

信号名  作用描述

TERM, INT  快速关闭程序,中止当前正在处理的请求

QUIT  处理完当前请求后,关闭程序

HUP  重新加载配置,并开启新的工作进程,关闭就的进程,此操作不会中断请求

USR1  重新打开日志文件,用于切换日志,例如每天生成一个新的日志文件

USR2  平滑升级可执行程序

WINCH  从容关闭工作进程

2.如果配置文件nginx.conf定义了pid的路径/usr/local/nginx/logs/nginx.pid,可以用该路径结束进程。

重新加载配置,并开启新的工作进程,关闭旧的进程,此操作不会中断请求

kill -HUP 6438(master的pid)

kill -HUP  `/usr/local/nginx/logs/nginx.pid`

快速关闭程序,中止当前正在处理的请求

kill -TERM 6438(master的pid)

kill -TERM `/usr/local/nginx/logs/nginx.pid`

强制停止所有nginx进程

pkill -9 nginx

确认nginx的配置文件是否正确

[[email protected] ~]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

四、安装nginx

1.nginx官网,下载了目前最新的版本nginx-1.7.10.tar.gz

http://nginx.org/

2.安装依赖包和库

[[email protected] ~]#yum -y install gcc gcc-c++ autoconf automake

[[email protected] ~]#yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

3.创建用户和组

[[email protected] ~]#groupadd www

[[email protected] ~]#useradd -g www www

4.解压

[[email protected] ~]# tar -xzvf nginx-1.7.10.tar.gz

[[email protected] ~]# cd nginx-1.7.10

5.编译安装到/usr/local/nginx目录

[[email protected] nginx-1.7.10]#./configure --user=www --group=www  --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

出现这些,编译就没问题

Configuration summary

+ using system PCRE library

+ using system OpenSSL library

+ md5: using OpenSSL library

+ sha1: using OpenSSL library

+ using system zlib library

nginx path prefix: "/usr/local/nginx"

nginx binary file: "/usr/local/nginx/sbin/nginx"

nginx configuration prefix: "/usr/local/nginx/conf"

nginx configuration file: "/usr/local/nginx/conf/nginx.conf"

nginx pid file: "/usr/local/nginx/logs/nginx.pid"

nginx error log file: "/usr/local/nginx/logs/error.log"

nginx http access log file: "/usr/local/nginx/logs/access.log"

nginx http client request body temporary files: "client_body_temp"

nginx http proxy temporary files: "proxy_temp"

nginx http fastcgi temporary files: "fastcgi_temp"

nginx http uwsgi temporary files: "uwsgi_temp"

nginx http scgi temporary files: "scgi_temp"

6.安装

[[email protected] nginx-1.7.10]# make && make install

7.启动nginx

[[email protected] nginx-1.7.10]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

8.验证

9.创建首页测试

[[email protected] ~]# mkdir -p /var/www/bbs/

在www目录下创建index.html

在bbs目录下创建test.html

在nginx.conf文件添加:

location / {

root   /var/www;

index index.html index.htm;

}

location /bbs {

root   /var/www/;

index test.html;

}

10.验证首页

时间: 2024-07-28 13:32:30

Redhat 5.5 安装nginx的相关文章

RedHat 7 编译安装Nginx 1.12并配置WEB站点

一.安装环境 1.操作系统版本:Red Hat Enterprise Linux Server release 7.2 (Maipo) 2.Nginx版本:nginx-1.12.2.tar.gz 3.pcre版本:pcre-8.42.tar.gz 4.zlib版本:zlib-1.2.11.tar.gz 5.openssl版本:openssl-1.0.2l.tar.gz 二.安装说明 官网上关于Nginx的依赖包说明如下: 三.安装过程 1.安装gcc:yum install gcc-c++ -y

centos和redhat下安装nginx最新版

在ubuntn下通过agp-get install nginx就可以按照最新版本的nginx,很方便 在ctentos和redhat下需要添加yum 仓库才能安装最新版的nginx,在/etc/yum.repos.d/目录下新建nginx.repo 文件输入以下内容就可以了:[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1 之后运行yum

服务器 CentOS上yum安装Nginx服务

一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses a new mirrorlist system developed by Lance Davis for CentOS. # The mirror system uses the connecting IP address of the client and the # update status

在Linux和Windows系统上安装Nginx服务器的教程

在Linux和Windows系统上安装Nginx服务器的教程 ?1.在CentOS系统上安装Nginx 在 CentOS6 版本的 EPEL 源中,已经加入了 nginx 的 rpm 包,不过此 RPM 包版本较低.如果需要更新版本,可以使用官方制作的 rpm 包,或者使用源码包编译安装. 还可以使用一些二次开发功能增强的 nginx 版本,例如淘宝的 Tengine 和 OpenResty 都是不错的选择.1.1 常用编译参数 ??? --prefix=PATH:指定 nginx 的安装目录?

Linux--YUM 安装 nginx php mysql

Linux--YUM 安装 nginx php mysql (2011-11-13 11:27:14) 转载▼ 标签: 杂谈 分类: Linux 1.先新建一个 repo # vi /etc/yum.repos.d/centos.21andy.com.repo 放入如下内容 [21Andy.com] name=21Andy.com Packages for Enterprise Linux 5 - $basearch baseurl=http://www.21andy.com/centos/5/

centos7更换阿里云yum源后无法安装nginx的问题解决

在centos7上,我将yum源更换为阿里云源,按照配置完成后,想使用yum安装nginx,但是老是提示我找不到nginx,没有可用的安装包,无论我是换为华为云的yum源,还是其他国内源,都无法找到.我的centos版本为7.7 无论我是安装epel-release,还是安装nginx的仓库,都没办法找到nginx包 我的nginx repo配置也没问题 一安装就找不到 但是可以用yum搜索到nginx的其他组件 这不科学 后来我想一个办法,在能够yum安装nginx的同样的机器上,把nginx

编译安装Nginx

############## 安装OpenSSL ######################wget https://www.openssl.org/source/openssl-1.0.2l.tar.gztar zxvf openssl-1.0.2l.tar.gzcd openssl-1.0.2l/./config --prefix=/opt/local/openssl :make && sudo make install ################ 安装PCRE #######

centos7编译安装nginx

linux及nginx版本 CentOS Linux release 7.2.1511 nginx-1.11.9 第一步安装依赖包 [[email protected] ~]# yum -y install pcre pcre-devel gcc openssl openssl-devel 第二步创建nginx用户 [[email protected] ~]# useradd nginx -s /sbin/nologin -M 第三部进入下载的nginx目录下编译 [[email protect

配置LANMP环境(5)-- 安装NGINX与配置

安装nginx yum install nginx 若提示找不到nginx,则在软件源中添加nginx的软件源文件: vim /etc/yum.repos.d/nginx.repo 添加如下内容: [nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=0 enabled=1 在根目录中创建data文件夹,在data文件夹中创建nginx文件夹,里面放置ngin