nginx的具体作用不用细说,很强大,做负载均衡、反向代理服务器解决前端跨域问题等等。下面是nginx的安装过程

首先nginx主要的依赖:

 pcre、 pcre-devel
zlib zlib-devel
openssl openssl-devel

因此安装nginx需要安装以下依赖(本教程只介绍centos在线安装,离线安装见另一篇文章)

1.安装依赖

 yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel

2.下载解压nginx

 cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz (解压文件)

3.安装nginx

 //进入nginx目录
cd /usr/local/nginx-1.13.7
//执行命令
./configure
//执行make命令
make
//执行make install命令
make install

4.配置nginx

cd到nginx配置文件,配置相应的信息数据,主要是配置好upstream 以及server即可,现在贴出我本机的配置

cd /usr/local/nginx/conf
vim nginx.conf

5.测试nginx是否配置正确

/usr/local/nginx/sbin/nginx  -t

如果出现以下所示,则配置没有问题

6.nginx的启停

启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
停止/重启
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop(quit、reload)
命令帮助
[root@localhost ~]# /usr/local/nginx/sbin/nginx -h
验证配置文件
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
配置文件
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf

其他介绍

1.VIM语法

默认vim打开后是不能录入的,需要按键才能操作,具体如下:
开启编辑:按“i”或者“Insert”键
退出编辑:“Esc”键
退出vim:“:q”
保存vim:“:w”
保存退出vim:“:wq”
不保存退出vim:“:q!”

2.nginx配置语法介绍

 #user  nobody;  

 #开启进程数 <=CPU数
worker_processes 1; #错误日志保存位置
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #进程号保存文件
#pid logs/nginx.pid; #每个进程最大连接数(最大连接=连接数x进程数)每个worker允许同时产生多少个链接,默认1024
events {
worker_connections 1024;
} http {
#文件扩展名与文件类型映射表
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"'; #请求日志保存位置
#access_log logs/access.log main; #打开发送文件
sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
#连接超时时间
keepalive_timeout 65; #打开gzip压缩
#gzip on; server {
#监听端口,默认是80端口
listen 80;
#监听域名
server_name localhost; #charset koi8-r; #nginx访问日志放在logs/host.access.log下,并且使用main格式(还可以自定义格式)
#access_log logs/host.access.log main; #如果没有location更明确的匹配访问路径的话,访问请求都会被该location处理。
location / {
#root指定nginx的根目录为/usr/local/nginx/html
root html;
#默认访问文件,欢迎页先去html目录下找index.html,如果找不到再去找index.htm
index index.html index.htm;
} #error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
# #错误页面及其返回地址,错误码为500、502、503、504都会返回50.html错误页面。
error_page 500 502 503 504 /50x.html;
#location后面是"="的话,说明是精确匹配
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} } --------------------- 本文来自 PengTDY 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/yougoule/article/details/78186138?utm_source=copy

No mapping for the Unicode character exists in the target multi-byte code page

使用windows版本的nginx启动时遇到(1113: No mapping for the Unicode character exists in the target multi-byte code page)这个错误

后来查阅资料发现是因为解压的路径里面包含有中文的缘故,只要把解压后的文件剪切到没有包含中文的目录即可解决问题

nginx反向代理服务器以及负载均衡,从安装到配置的更多相关文章

  1. 简单聊聊不可或缺的Nginx反向代理服务器--实现负载均衡【上篇】

    今天又是新的一周,我养足了精神去对待新一周的工作,但是今天到公司发现还是有一点空闲时间的,所以就想与之前接触过的Nginx再交往得更深一点儿. 什么是Nginx: Nginx是一款高性能的http服务 ...

  2. Nginx反向代理服务器、负载均衡和正向代理

    Nginx("engine x")是一个高性能的 HTTP 和反向代理服务器,第一个公开版本 0.1.0 发布于 2004 年 10 月 4 日.官方测试 nginx 能够支撑5万 ...

  3. Nginx反向代理,负载均衡,redis session共享,keepalived高可用

    相关知识自行搜索,直接上干货... 使用的资源: nginx主服务器一台,nginx备服务器一台,使用keepalived进行宕机切换. tomcat服务器两台,由nginx进行反向代理和负载均衡,此 ...

  4. 【转】Nginx反向代理和负载均衡

    原文链接:http://www.cnblogs.com/shuoer/p/7820899.html Nginx反向代理和负载均衡 环境说明 由于我使用的是windows系统,所以我用虚拟机虚拟出来了3 ...

  5. Nginx反向代理、负载均衡及日志

    Nginx反向代理.负载均衡及日志 1.原理图   2.正向代理与反向代理 (1)代理服务器 代理服务器,客户机在发送请求时,不会直接发送给目的主机,而是先发送给代理服务器,代理服务接受客户机请求之后 ...

  6. Nginx反向代理与负载均衡应用实践(二)

    Nginx反向代理与负载均衡应用实践(二) 链接:https://pan.baidu.com/s/1xB20bnuanh0Avs4kwRpSXQ 提取码:migq 复制这段内容后打开百度网盘手机App ...

  7. Nginx反向代理与负载均衡应用实践(一)

    Nginx反向代理与负载均衡应用实践(一) 链接:https://pan.baidu.com/s/1xB20bnuanh0Avs4kwRpSXQ 提取码:migq 复制这段内容后打开百度网盘手机App ...

  8. Nginx反向代理实现负载均衡配置图解

    Nginx反向代理实现负载均衡配置图解 [导读] 负载均衡配置是超大型机器需要考虑的一些问题,同时也是数据安全的一种做法,下面我来介绍在nginx中反向代理 负载均衡配置图解,大家可参考本文章来操作. ...

  9. 一篇文章搞定 Nginx 反向代理与负载均衡

    代理 要想弄明白反向代理,首先要知道啥是正向代理,要搞懂正向代理只需要知道啥是代理即可.代理其实就是一个中介,在不同事物或同一事物内部起到居间联系作用的环节.比如买票黄牛,房屋中介等等. 在互联网中代 ...

随机推荐

  1. Wondershare Video Converter Ultimate 注册码 License

    这个软件可以直接将DVD iso转换成mp4播放,可以破解,还不错,特地记录 官网下载最新版: https://videoconverter.wondershare.com/gl/video-conv ...

  2. brew 切换国内的源

    切换到国内源 # 替换brew.git: cd "$(brew --repo)" # 中国科大: git remote set-url origin https://mirrors ...

  3. sqlserver 锁表进程及执行的SQL

    --1.查进程select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableNamefrom sys.d ...

  4. PC通过netsh获取wifi密码

    1.查看当前系统所有保存wifi的ssid netsh wlan show profiles 2.根据指定ssid查看wifi密码,密码就是关键内容 netsh wlan show profile n ...

  5. c++ template Queue

    #pragma once#include <iostream>#include <iomanip> using namespace std; template<class ...

  6. 阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_12-webpack研究-webpack安装

    npm默认安装配置的路径配置在nodejs的node_modules目录 j加上 -g 就是全局安装 后面只写webpack默认安装的是最新版本 指定版本号 视频中建议指定版本号进行安装

  7. 模型压缩-L1-norm based channel pruning(Pruning Filters for Efficient ConvNets)

    论文笔记——PRUNING FILTERS FOR EFFICIENT CONVNETS  转载:https://www.cnblogs.com/zhonghuasong/p/7642000.html ...

  8. 看看可爱c#中的delegate(委托)和event(事件)用法好不好

    一.开篇忏悔 对自己最拿手的编程语言C#,我想对你说声对不起,因为我到现在为止才明白c#中的delegate和event是怎么用的,惭愧那.好了,那今天就趁月黑风高的夜晚简单来谈谈delegate和e ...

  9. Scrapy框架学习参考资料

    00.Python网络爬虫第三弹<爬取get请求的页面数据> 01.jupyter环境安装 02.Python网络爬虫第二弹<http和https协议> 03.Python网络 ...

  10. 《精通并发与Netty》学习笔记(11 - 详解NIO (二) 分散/聚集 Scatter/Gather、Selector)

    一.分散/聚集 Scatter/Gather scatter/gather指的在多个缓冲区上实现一个简单的I/O操作,比如从通道中读取数据到多个缓冲区,或从多个缓冲区中写入数据到通道:scatter( ...