大流量网站必备的软件——nginx,需要的看看
来源:一笔一笔画世界     阅读:790
芳年居
发布于 2018-12-27 23:09
查看主页

众所周知,nginx性能高,而nginx的高性能与其架构是分不开的。

nginx在启动后,在unix系统中会以daemon的方式在后端运行,后端进程包含一个master进程和多个worker进程。

Nginx能做什么?

1.反向代理商

2.负载均衡

3.HTTP服务器(包含动静分离,就是web服务器最常用的)

4.正向代理商

反向代理商代码:

server {

listen 80;

server_name localhost;

client_max_body_size 1024M;

location / {

proxy_pass http://localhost:8080;

proxy_set_header Host $host:$server_port;

}

}

访问localhost的时候,就相当于访问localhost:8080。

负载均衡,代码

upstream test {

server localhost:8080;

server localhost:8081;

}

server {

listen 81;

server_name localhost;

client_max_body_size 1024M;

location / {

proxy_pass http://test;

proxy_set_header Host $host:$server_port;

}

}

8081的服务器是不存在的,也就是说访问不到,但是我们访问http://localhost 的时候,也不会有问题,会默认跳转到http://localhost:8080 具体是由于Nginx会自动判断服务器的状态,假如服务器处于不能访问(服务器挂了),就不会跳转到这台服务器,所以也避免了一台服务器挂了影响使用的情况。

nginx的热启动,修改配置文件完后,不必重启nginx。命令

nginx -s reload (Linux)

nginx.exe -s reload (win)

CentOS下安装nginx,

yum install epel-release

便于安装源以外的软件,如Nginx,phpMyAdmin等。

yum install nginx。

安装php-fpm

yum install php-fpm

开机启动nginx和php-fpm

chkconfig php-fpm on

chkconfig nginx on

安装MySQL

yum install mysql mysql-server

大流量网站必备的软件——nginx,需要的看看

免责声明:本文为用户发表,不代表网站立场,仅供参考,不构成引导等用途。 系统环境 软件环境
相关推荐
Apache Solr 7.0.0发布,亮点多的看不过来!
异地技术团队高效协作的经验分享
Windows10平台下使用Linux子系统Ubuntu
Apache自动跳转到 HTTPS
android RecycleView 局部刷新方式总结
首页
搜索
订单
购物车
我的