一、安装部署
1、yum安装
yum -y install openssl-devel
yum -y install gcc
yum -y install pcre-devel
yum -y install zlib-devel
2、rpm安装
rpm -qa| grep openssl
rpm -qa| grep gcc
rpm -qa| grep pcre
rpm -qa| grep zlib
rpm -ivh pcre-devel-7.8-6.el6.x86_64.rpm
rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
rpm -vih openssl-devel-1.0.1e-30.el6.x86_64.rpm --nodeps --force
tar -xzvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure
make
make install
二、常用命令
1、Nginx启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c:指定配置文件的路径,如果不加-c参数,则默认加载conf目录下的nginx.conf配置文件。
2、Nginx停止:
a)从容停止:kill -QUIT 2072 |./ nginx -s quit
b)快速停止:kill -TERM 2132 | kill -INT 2132 | ./nginx -s stop
c)强制停止:pkill -9 nginx
3、Nginx重启:kill -HUP 主进程号 | ./ nginx -s reload
4、检查Nginx配置文件:./nginx -t
三、nginx的配置文件
user root;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 20000;
}
http {
charset utf-8;
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for "$request_time"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream 192.168.2.212 {
ip_hash;
server 192.168.2.212:8081;
}
#设定负载均衡服务器列表
upstream sos.com{
ip_hash;
server 192.168.2.212:8180;
}
upstream cms.com{
ip_hash;
server 192.168.2.212:8086;
}
upstream bms.com{
ip_hash;
server 192.168.2.212:8084;
}
upstream portalms.com{
ip_hash;
server 192.168.2.212:8080;
}
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/plain application/x-javascript text/css text/javascript application/xml;
gzip_vary on;
server {
listen 9031;
server_name 192.168.2.212;
location / {
root /resource;
}
location /css/template {
root /resource;
}
location /js {
root /resource;
}
location /resource/ {
charset utf-8;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /poster {
root /resource;
}
location /portal2_pfs/generateManage/generateTemplate/root/ {
alias /resource/;
}
location ~ \.(jsp|do)|asg|Play|services/*|PlayVod|ToOrder|OrderProdVOD|stbsimulator/*|portalFrontProcessor|userMark|OrderPage|ChannelOrder {
proxy_pass http://192.168.2.212;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
}
server {
listen 9005;
server_name 192.168.2.212;
location / {
root /resource;
}
location /css/template {
root /resource;
}
location /js {
root /resource;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /poster {
root /resource;
}
location /video {
root /resource;
}
location /portal2_pfs/generateManage/generateTemplate/root/ {
alias /resource/;
}
location ~ \.(jsp|do)|asg|Play|services/*|PlayVod|ToOrder|OrderProdVOD|stbsimulator/*|portalFrontProcessor|userMark|OrderPage|ChannelOrder {
proxy_pass http://192.168.2.212;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
}
server {
listen 80;
server_name 192.168.2.212;
location /resource/ui/template/ {
charset utf-8;
}
location / {
root /resource;
}
location /css/template {
root /resource;
}
location /ui/ {
alias /resource/ui/template/;
}
location /js {
root /resource;
}
location ^~ /poster/09ui {
root /;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /poster {
root /resource;
}
location /video {
root /resource;
}
location /portal2_pfs/generateManage/generateTemplate/root/ {
alias /resource/;
}
location ~ \.(jsp|do)|asg|Play|services/*|PlayVod|ToOrder|OrderProdVOD|stbsimulator/*|portalFrontProcessor|userMark|OrderPage|ChannelOrder {
proxy_pass http://192.168.2.212;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
}
server {
listen 9015;
server_name 192.168.2.212;
location / {
root /resource;
}
location /css/template {
root /resource;
}
location /js {
root /resource;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /poster {
root /resource;
}
location /portal2_pfs/generateManage/generateTemplate/root/ {
alias /resource/;
}
location ~ \.(jsp|do)|asg|Play|services/*|PlayVod|ToOrder|OrderProdVOD|stbsimulator/*|portalFrontProcessor|userMark|OrderPage|ChannelOrder {
proxy_pass http://192.168.2.212;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
}
server {
listen 90;
server_name 192.168.2.212;
location / {
root /resource;
}
location /css/template {
root /resource;
}
location /js {
root /resource;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /poster {
root /resource;
}
location /OTTAppDownload {
root /resource;
}
location /10086 {
root /resource;
}
location /tangguohtml {
root /resource;
}
location /zhongxinhtml {
root /resource;
}
location /portal2_pfs/generateManage/generateTemplate/root/ {
alias /resource/;
}
location ~ \.(jsp|do)|asg|Play|services/*|PlayVod|ToOrder|OrderProdVOD|stbsimulator/*|portalFrontProcessor|userMark|OrderPage|ChannelOrder {
proxy_pass http://192.168.2.212;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
}
server {
listen 9080;
server_name 192.168.2.212;
location / {
root html;
index index.html index.htm;
}
location ^~ /sos/ {
proxy_pass http://sos.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location ^~ /cms/ {
#定义服务器的默认网站根目录位置
root html;
#定义首页索引文件的名称
index index.html index.htm;
#定义后端负载服务器组
proxy_pass http://cms.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location ^~ /bms/ {
#定义服务器的默认网站根目录位置
root html;
#定义首页索引文件的名称
index index.html index.htm;
#定义后端负载服务器组
proxy_pass http://bms.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location ^~ /portalms/ {
#定义服务器的默认网站根目录位置
root html;
#定义首页索引文件的名称
index index.html index.htm;
#定义后端负载服务器组
proxy_pass http://portalms.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
相关推荐
本文档将详细介绍 Nginx 安装部署的步骤和配置,包括必要的工具包安装、Nginx 安装、插件安装、配置 Nginx.conf 文件等方面的知识点。 必要的工具包安装 在安装 Nginx 之前,需要安装一些必要的工具包。这些工具包...
nginx 本着开源精神 小白一枚,大家一起努力! HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送协议。 HTTP是一...
Nginx安装部署文档 本文档详细介绍了Nginx的安装部署过程,包括环境准备、安装依赖、下载离线安装包、安装步骤、启动Nginx、开放端口、停止Nginx等内容。 一、环境准备 在开始安装Nginx之前,需要准备一个CentOS ...
Nginx 安装部署文档详细介绍了 Nginx 的安装过程和配置方法。以下是该文档的知识点摘要: 一、编译环境准备 在开始安装 Nginx 之前,需要准备好编译环境。对于 Ubuntu 平台,可以使用以下命令安装编译环境:apt-...
nginx安装部署配置及常见问题说明
【标题】:“基于Linux下Nginx的安装与项目部署详解” 【描述】:本文将详细介绍如何在Linux系统中安装Nginx,并探讨其主要功能,包括反向代理、负载均衡以及项目部署的具体操作。 【标签】:“Nginx”,“Nginx...
### Nginx安装部署配置详解 #### 一、Nginx简介 Nginx是一款开源的高性能HTTP服务器和反向代理服务器,同时也可用作邮件(IMAP/POP3)代理服务器。它以其高性能、稳定性以及丰富的功能集而闻名,并且具有低资源消耗...
详细说明了windows服务器nginx+tomcat+mysql部署及配置(配置阿里云后台安全组,配置域名)很适合新手学习 附件中包含: 1.操作说明文档 2.操作录屏 3.安装所用到的软件安装包 1)Windows Server 2019 数据中心版 ...
通过本指南,你应该能够在 Linux 系统上安装并配置 Nginx,并理解基本的 Nginx 配置,包括虚拟主机、反向代理和负载均衡。Nginx 是一个强大而灵活的服务器,进一步的配置和优化可以根据具体需求进行。
本文将详细介绍如何在Linux系统中安装Nginx,以及相关的配置和部署步骤。 **一、安装Nginx** 1. **更新系统**: 在开始安装前,确保系统是最新的,运行以下命令: ```bash sudo apt-get update sudo apt-get ...
Nginx的安装部署配置步骤
本文将详细解析在Linux环境下如何安装和配置Nginx与Tomcat的整合,帮助读者实现高效的Web服务部署。 #### 安装Nginx 首先,我们需要在Linux系统上安装Nginx。以下步骤以上传的`nginx-0.7.63.tar.gz`为例,进行详细...
在本文中,我们将深入探讨如何使用Nginx部署配置高可用环境,特别是在与Tomcat集成的情况下。Nginx是一款高性能的HTTP和反向代理服务器,常用于负载均衡和静态资源处理,而Tomcat则是一个流行的Java应用服务器,主要...
3. 配置 Nginx:在安装 Nginx 之后,需要配置 Nginx 的参数,例如 prefix、user、group 等。 二、Nginx 启动和检查 1. 启动 Nginx:使用 /application/nginx/sbin/nginx 命令启动 Nginx 服务。 2. 检查 Nginx ...
- 编译与安装:`make && sudo make install` **Nginx配置** Nginx 的配置文件通常位于 `/etc/nginx/nginx.conf`,也可以通过创建多个 server 块来为不同的域名或服务定制配置。主要配置项包括: 1. **基本配置**...
### Nginx的使用教程、安装部署与配置 #### 一、Nginx简介与应用场景 Nginx是一款开源的高性能HTTP服务器和反向代理服务器,同时也支持IMAP/POP3/SMTP等协议的代理服务器。它以其轻量级、高并发处理能力以及出色的...