https://github.com/DocsHome/nginx-docs

部署

  1. yum -y install nginx

启动相关

虚拟主机

vim /etc/nginx/nginx.conf

  1. user nginx;
  2. worker_processes auto;
  3. worker_rlimit_nofile 65535;
  4. error_log /var/log/nginx/error.log;
  5. pid /run/nginx.pid;
  6. include /usr/share/nginx/modules/*.conf;
  7. events {
  8. use epoll; #使用epoll事件驱动
  9. worker_connections 51200;
  10. accept_mutex on;
  11. multi_accept on;
  12. }
  13. http {
  14. server_tokens off;
  15. sendfile on;
  16. tcp_nopush on;
  17. tcp_nodelay on;
  18. keepalive_timeout 65;
  19. types_hash_max_size 2048;
  20. client_max_body_size 10m;
  21. #开启gzip
  22. gzip on;
  23. gzip_min_length 1k;
  24. gzip_buffers 4 16k;
  25. gzip_http_version 1.1;
  26. gzip_comp_level 2;
  27. gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
  28. gzip_vary on;
  29. gzip_proxied expired no-cache no-store private auth;
  30. gzip_disable "MSIE [1-6]\.";
  31. include /etc/nginx/mime.types;
  32. default_type application/octet-stream;
  33. #设置日志的记录格式
  34. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  35. '$status $body_bytes_sent "$http_referer" '
  36. '"$http_user_agent" "$http_x_forwarded_for"';
  37. log_format log404 '$status [$time_local] $remote_addr $host$request_uri $sent_http_location';
  38. access_log /var/log/nginx/access.log main;
  39. access_log /var/log/nginx/access_404.log log404;
  40. include /etc/nginx/vhost/*.conf;
  41. }
  1. mkdir /etc/nginx/vhost #创建虚拟主机目录
  2. mkdir /opt/www #网站存放目录
  3. chown www:www /opt/www
  4. chmod 755 /opt/www

进阶配置见
Nginx 进阶