Linux for CentOS 下的 nginx 绿色安装-超省心安装
1.我这里是nginx-1.13.0-1.x86_64 .rpm(点击下载)版本的。
2.安装nginx的相应环境。有些环境可能不必须,但是安装了,确保以防万一,多多益善
yum install gd-devel
yum install gcc-c++
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-developenssl openssl-devel pcre pcre-devel
yum install libgd2-devel
yum install libpcre-devel
yum install libcurl-devel
yum install gd-devel
3.我再opt目录下建立了一个software文件夹,用来存放资源包的
进入该目录 cd /opt/software/
随之解压 rpm -ivh nginx-1.13.0-1.x86_64 .rpm
4.这个时候,nginx的相关配置都在你/etc/nginx目录下
根据自己的需要,修改nginx.conf
user nobody;
worker_processes auto;
worker_rlimit_nofile 102400;
pid /run/nginx.pid; events {
use epoll;
worker_connections 10240;
multi_accept on;
} http { ##
# Basic Settings
## sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;
# allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on; # number of requests client can make over keep-alive -- for testing environment
keepalive_requests 1000;
proxy_next_upstream error timeout invalid_header;
proxy_intercept_errors on;
proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_redirect http:// $scheme://;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
include /etc/nginx/mime.types;
default_type application/octet-stream; ##
# SSL Settings
## # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
# ssl_prefer_server_ciphers on; ##
# Logging Settings
##
log_format main '$upstream_addr $scheme $http_host [$request_time|$upstream_response_time|$upstream_status] '
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $gzip_ratio'; access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log; ##
# Gzip Settings
##
gzip on;
gzip_static on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "msie6"; ##
# Virtual Host Configs
##
include /etc/nginx/http-conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/sites-available/*.conf;
} stream {
include /etc/nginx/stream-conf.d/*.conf;
include /etc/nginx/stream-enabled/*;
}
此时,你可以把你的IP端口号写在这个配置里面,也可以写在这个下面
/etc/nginx/sites-available/*.conf;
这里我把我的IP端口就写在这里,命名叫做TestSite.conf
upstream upstream_10009 {
#sticky;
ip_hash;
server 10.10.0.112:10009;
server 10.10.0.113:10009;
keepalive 64;
}
upstream upstream_10010 {
sticky;
server 10.10.0.112:10010;
server 10.10.0.113:10010;
keepalive 64;
}
upstream upstream_10020 {
sticky;
server 10.10.0.112:10020;
server 10.10.0.113:10020;
keepalive 64;
}
upstream upstream_10030 {
sticky;
server 10.10.0.112:10030;
server 10.10.0.113:10030;
keepalive 64;
}
#------------------------------
#------------------------------
因为我的服务器项目需要传递Token,我使用的是 ip_hash 负载算法。
配置完毕之后,可以使用 可以用systemctl启动、重载、停止nginx
例如:
systemctl status nginx.service #状态
systemctl start nginx.service #开始
systemctl stop nginx.service #停止
然后开始访问你的项目吧!此部署nginx是最省心的方法。
Linux for CentOS 下的 nginx 绿色安装-超省心安装的更多相关文章
- Ubuntu/CentOS下编译Nginx最基本参数
Ubuntu/CentOS下编译Nginx安装基本参数,做个记录: groupadd www useradd -g www www ./configure --user=www --group=www ...
- 【Linux】CentOS下升级Python和Pip版本全自动化py脚本
[Linux]CentOS下升级Python和Pip版本全自动化py脚本 CentOS7.6自带py2.7和py3.6 想要安装其它版本的话就要自己重新下载和编译py其它版本并且配置环境,主要是软链接 ...
- centos下 Apache、php、mysql默认安装路径
centos下 Apache.php.mysql默认安装路径 http://blog.sina.com.cn/s/blog_4b8481f70100ujtp.html apache: 如果采用RPM包 ...
- linux和mac下的nginx和php的安装
linux版本相关文档:http://www.nginx.cn/231.html 一.安装php 1.下载包,这里以php 5.3.10为例 2.执行下面shell命令 注意:下面配置的命令中第一行 ...
- Linux(CentOS)下设置nginx开机自动启动(2个办法)
首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令: vim /etc/init.d/nginx 在脚本中添加如下命令: #!/bin/sh # # nginx - ...
- linux(centos)下安装git并上传代码些许步骤(亲自验证过的步骤)
曾经听说了好多次github,但直到近期才第一次学习使用github来托管自己在linux下的代码! 说实话.我自己在使用的时候从网上查了好多教程.但总认为难以掌握(步骤过于繁琐),自己操作的时候还 ...
- 服务器学习--Linux、CentOS下安装zip与unzip指令
Linux下安装zip解压功能 Linux服务器上一般默认没是没有有安装zip命令 安装zip指令 apt-get install zip 或 yum install zip 输入zip OK li ...
- centos 7.0 nginx 1.7.9成功安装过程
centos 7.0根目录 的目录构成 [root@localhost /]# lsbin dev home lib64 mnt proc run srv tmp varboot etc lib me ...
- (转) centos 7.0 nginx 1.7.9成功安装过程
centos 7.0根目录 的目录构成 [root@localhost /]# lsbin dev home lib64 mnt proc run srv tmp varboot etc lib me ...
随机推荐
- JQuery学习基础
## 今日内容 1. JQuery 基础: 1. 概念 2. 快速入门 3. JQuery对象和JS对象区别与转换 4. 选择器 ...
- SQLAlchemy加载数据到数据库
SQLAlchemy加载数据到数据库 最近在研究基于知识图谱的问答系统,想要参考网上分享的关于NLPCC 2016 KBQA任务的经验帖,自己实现一个原型.不少博客都有提到,nlpcc-kbqa训练数 ...
- 『现学现忘』Git基础 — 10、配置Git用户签名说明
目录 1.为什么要创建用户签名 2.为什么要在Git中配置这些信息 3.创建用户签名的方式 4.总结 1.为什么要创建用户签名 作为版本控制系统的客户端,每台客户机对版本库的所有提交操作,都需要注明操 ...
- nodejs mysql pool 只能插入10条记录或者较少记录
BEGIN; 解决方案:从连接池获取到的Connection,执行完操作后,必须及时关闭! 即:connection.end(); 使用后发现console有打印出警告信息,大致意思为 end() 方 ...
- RxJava + Retrofit源码解析
RxJava + Retrofit怎么请求网络,具体的用法这里就不讲了,本文只讲一些重点源码. 版本如下: okhttp : "com.squareup.okhttp3:okhttp:3.1 ...
- 【远古黑历史】List链表及其功能
前言 我知道有学校是禁用STL的, 但STL是真的香,加个蛋,嗯,好吃 所以,本人希望有更多OIer能使用STL,减少工作量! 初见STL 首先,什么是STL? STL,全称 Standard Tem ...
- MPLS L3 跨域 optionB 配置
mpls跨域optionB optionB的核心思想是私网路由传递过程是 PE-ASBR1-ASBR2-PE2 在传递过程中私网标签发生了变化(由ASBR重新分配了私网标签),而在数据平面(不考虑PH ...
- 爬取豆瓣喜剧类热门TOP60的电影
学习任务:爬取豆瓣喜剧类热门TOP60的电影并保存在douban.txt文件中. 代码示例: import requests url="https://movie.douban.com/j/ ...
- Java类包
学习内容:Java类包 一.Java类包 1.一个完整的类名需要包名和类名的组合,每一个类都隶属于一个包. 例:完整类名--java.sql.Date 2.同一个包中类相互访问时可以不指明包名. 3. ...
- python之部分内置函数与迭代器与异常处理
目录 常见内置函数(部分) 可迭代对象 迭代器对象 for循环内部原理 异常处理 异常信息的组成部分 异常的分类 异常处理实操 异常处理的其他操作 for循环本质 迭代取值与索引取值的区别 常见内置函 ...