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 ...
随机推荐
- 2021.08.09 P5658 括号树(树形结构)
2021.08.09 P5658 括号树(树形结构) [P5658 CSP-S2019] 括号树 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题意: 太长,在链接中. 分析及代码 ...
- python基础练习题(输入三个整数x,y,z,请把这三个数由小到大输出)
day3 --------------------------------------------------------------- 实例005:三数排序 题目: 输入三个整数x,y,z,请把这三 ...
- JavaWeb和WebGIS学习笔记(四)——使用uDig美化地图,并叠加显示多个图层
系列链接: Java web与web gis学习笔记(一)--Tomcat环境搭建 Java web与web gis学习笔记(二)--百度地图API调用 JavaWeb和WebGIS学习笔记(三)-- ...
- jmeter元件分析
jmeter元件分析 一.脚本通用性 1.性能测试脚本改动一下,加入断言等元件,就可以作为接口测试脚本来使用 2.但是接口测试的脚本不可以作为性能测试脚本来使用 3.原因:因为性能测试考虑更多的性能, ...
- PowerDotNet平台化软件架构设计与实现系列(13):应用监控平台
本文再写一篇和具体业务逻辑几乎无关的公共服务应用监控平台.PowerDotNet自研的应用监控平台系统,是服务治理的重要拼图,和服务治理平台配合使用效果更好. 监控开源产品非常丰富,站在巨人的肩膀上, ...
- 单片机DIY制作-基于STM32单片机甲醛二氧化碳温度湿度采集系统
基于STM32单片机甲醛二氧化碳温度湿度采集系统 实践制作DIY-GC008-甲醛二氧化碳温度湿度采集系统 一.功能说明: 基于STM32单片机设计-甲醛二氧化碳温度湿度采集系统 二.功能介绍: 1. ...
- 实战 | 一文带你读懂Nginx反向代理
一个执着于技术的公众号 前言 在前面的章节中,我们已经学习了nginx基础知识: 给小白的 Nginx 10分钟入门指南 Nginx编译安装及常用命令 完全卸载nginx的详细步骤 Nginx 配置文 ...
- 【总结】2022GDOI普及组试题与题解(缺两天的T4)
标签 2022 广东省选普及组 GDOI 试题 前往Luogu下载 Luogu下载:This Day1题解 T1 邹忌讽齐王纳谏 打卡题,建议模拟 建议使用map,时间复杂度为\(O(nlogn)\) ...
- HamsterBear Linux Low Res ADC按键驱动的适配 + LVGL button移植
HamsterBear lradc按键驱动的适配 平台 - F1C200s Linux版本 - 5.17.2 ADC按键 - 4 KEY tablet 驱动程序位于主线内核: drivers/inpu ...
- Golang 函数 方法 接口的简单介绍
函数 函数是基本的代码块,通常我们会将一个功能封装成一个函数,方便我们调用,同时避免代码臃肿复杂. 函数的基本格式 func TestFunc(a int, b string) (int, strin ...