相信看过我之前apache文章的朋友们,对服务优化也有了一个大概的了解,相比较而言,Nginx企业中应用的更多一些,因此今天也会详细阐述Nginx的优化,有人说,服务器不需要优化,开虚拟化,分分钟成倍增加并发量,但是网站服务器优化不仅仅是为了高并发而做,有些优化也涉及到了安全和控制,请大家耐心往下看,如果有哪里写的不明白你们可以评论,我基本每天都上线,会仔细思考大家的问题。

  首先提供Nginx主配置文件,大家可先参考了解一下

 1 #user  nobody;
 2 worker_processes  1;
 3 #error_log  logs/error.log;
 4 #error_log  logs/error.log  notice;
 5 #error_log  logs/error.log  info;
 6 #pid        logs/nginx.pid;
 7 events {
 8     worker_connections  1024;
 9 }
10 http {
11     include       mime.types;
12     default_type  application/octet-stream;
13     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
14     #                  '$status $body_bytes_sent "$http_referer" '
15     #                  '"$http_user_agent" "$http_x_forwarded_for"';
16     #access_log  logs/access.log  main;
17     sendfile        on;
18     #tcp_nopush     on;
19     #keepalive_timeout  0;
20     keepalive_timeout  65;
21     #gzip  on;
22     server {
23         listen       80;
24         server_name  localhost;
25         #charset koi8-r;
26         #access_log  logs/host.access.log  main;
27         location / {
28             root   html;
29             index  index.html index.htm;
30         }
31         #error_page  404              /404.html;
32         # redirect server error pages to the static page /50x.html
33         #
34         error_page   500 502 503 504  /50x.html;
35         location = /50x.html {
36             root   html;
37         }
38         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
39         #
40         #location ~ \.php$ {
41         #    proxy_pass   http://127.0.0.1;
42         #}
43         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
44         #
45         #location ~ \.php$ {
46         #    root           html;
47         #    fastcgi_pass   127.0.0.1:9000;
48         #    fastcgi_index  index.php;
49         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
50         #    include        fastcgi_params;
51         #}
52         # deny access to .htaccess files, if Apache's document root
53         # concurs with nginx's one
54         #
55         #location ~ /\.ht {
56         #    deny  all;
57         #}
58     }
59     # another virtual host using mix of IP-, name-, and port-based configuration
60     #
61     #server {
62     #    listen       8000;
63     #    listen       somename:8080;
64     #    server_name  somename  alias  another.alias;
65     #    location / {
66     #        root   html;
67     #        index  index.html index.htm;
68     #    }
69     #}
70     # HTTPS server
71     #
72     #server {
73     #    listen       443 ssl;
74     #    server_name  localhost;
75     #    ssl_certificate      cert.pem;
76     #    ssl_certificate_key  cert.key;
77     #    ssl_session_cache    shared:SSL:1m;
78     #    ssl_session_timeout  5m;
79     #    ssl_ciphers  HIGH:!aNULL:!MD5;
80     #    ssl_prefer_server_ciphers  on;
81     #    location / {
82     #        root   html;
83     #        index  index.html index.htm;
84     #    }
85     #}
86 }
View Code

相关文章:

  • 2021-11-21
  • 2021-05-27
  • 2021-11-14
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-11-08
相关资源
相似解决方案