nginx配置文件
  1. ###核心模块(进程数等)
  2. user nginx; #启动用户
  3. worker_processes auto; #开启nginx数量
  4. error_log /var/log/nginx/error.log notice; #错误日志
  5. pid /var/run/nginx.pid; #进程号
  6. ####事件驱动模块(工作模式等)
  7. events {
  8. worker_connections 1024; #工作连接数,默认1个程序可以为10000个人服务
  9. }
  10. ###http内核模块(文档程序)
  11. http {
  12. include /etc/nginx/mime.types; #mime.types包含了能够打开的格式
  13. default_type application/octet-stream; #应用程序流
  14. #日志格式
  15. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  16. '$status $body_bytes_sent "$http_referer" '
  17. '"$http_user_agent" "$http_x_forwarded_for"';
  18. #访问日志,main格式
  19. access_log /var/log/nginx/access.log main;
  20. sendfile on; #加速nginx访问
  21. #tcp_nopush on; #优化nginx访问
  22. keepalive_timeout 65; #长连接
  23. #gzip on; #压缩
  24. include /etc/nginx/conf.d/*.conf; #导入子配置文件
  25. }

默认网站:/etc/nginx/conf.d/default.conf

  1. ###server默认会在http里面
  2. server {
  3. listen 80; #监听端口
  4. server_name localhost; #域名,服务器购买的域名
  5. #access_log /var/log/nginx/host.access.log main; #访问日志路径
  6. location / { #网址的位置
  7. root /usr/share/nginx/html; #网站放那个目录
  8. index index.html index.htm; #默认主页
  9. }
  10. #error_page 404 /404.html;
  11. # redirect server error pages to the static page /50x.html
  12. #
  13. error_page 500 502 503 504 /50x.html; #错误日志
  14. location = /50x.html {
  15. root /usr/share/nginx/html;
  16. }
  17. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  18. #
  19. #
  20. #location ~ \.php$ {
  21. # proxy_pass http://127.0.0.1;
  22. #}
  23. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  24. #
  25. #location ~ \.php$ {
  26. # root html;
  27. # fastcgi_pass 127.0.0.1:9000;
  28. # fastcgi_index index.php;
  29. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  30. # include fastcgi_params;
  31. #}
  32. # deny access to .htaccess files, if Apache's document root
  33. # concurs with nginx's one
  34. #
  35. #location ~ /\.ht {
  36. # deny all;
  37. #}
  38. }