nginx 学习
nginx 基础 demo
/etc/nginx/nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
user nginx;
worker_processes 1;
pid logs/nginx.pid;
events { use epoll;
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;
keepalive_timeout 65; tcp_nodelay on;
gzip on; gzip_disable "MSIE [1-6].";
client_header_buffer_size 128k; large_client_header_buffers 4 128k; include /etc/nginx/conf.d/*.conf; }
|
/etc/nginx/conf.d/default.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| server { listen 80; server_name www.nginx.cn; root /home/tpm/html; access_log logs/nginx.access.log main; location / { index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { } location ~ ^/(images|javascript|js|css|flash|media|static)/ { expires 30d; } location ~ /.ht { deny all; }
}
|
nginx install
1 2 3 4 5 6 7 8
| Ubuntu sudo apt-get install nginx -------------------------- centos sudo yum install epel-release #更新存储库并安装Nginx sudo yum update sudo yum install nginx
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #定义要包含在负载均衡方案中的服务器。 #最好使用服务器的私有IP以获得更好的性能和安全性。 http { upstream backend { server 10.1.0.101; server 10.1.0.102; server 10.1.0.103; } #该服务器接受到端口80的所有流量并将其传递给上游。 #请注意,上游名称和proxy_pass需要匹配。 server { listen 80; location / { proxy_pass http: } } }
|
如有问题可联系 Email:afacode@outlook.com 或 微信:afacode