当前位置:   article > 正文

Nginx配置

Nginx配置

目录

1.主配置文件

2.server配置文件

3.html配置文件


1.主配置文件

  1. vim /etc/nginx/nginx.conf
  2. # For more information on configuration, see:
  3. # * Official English Documentation: http://nginx.org/en/docs/
  4. # * Official Russian Documentation: http://nginx.org/ru/docs/
  5. user nginx;
  6. worker_processes auto;
  7. error_log /var/log/nginx/error.log;
  8. pid /run/nginx.pid;
  9. # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
  10. include /usr/share/nginx/modules/*.conf;
  11. events {
  12. worker_connections 1024;
  13. }
  14. http {
  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. access_log /var/log/nginx/access.log main;
  19. sendfile on;
  20. tcp_nopush on;
  21. tcp_nodelay on;
  22. keepalive_timeout 65;
  23. types_hash_max_size 4096;
  24. include /etc/nginx/mime.types;
  25. default_type application/octet-stream;
  26. # Load modular configuration files from the /etc/nginx/conf.d directory.
  27. # See http://nginx.org/en/docs/ngx_core_module.html#include
  28. # for more information.
  29. include /etc/nginx/conf.d/*.conf;
  30. include vhost/*.conf;
  31. }
  32. # Settings for a TLS enabled server.
  33. #
  34. # server {
  35. # listen 443 ssl http2;
  36. # listen [::]:443 ssl http2;
  37. # server_name _;
  38. # root /usr/share/nginx/html;
  39. #
  40. # ssl_certificate "/etc/pki/nginx/server.crt";
  41. # ssl_certificate_key "/etc/pki/nginx/private/server.key";
  42. # ssl_session_cache shared:SSL:1m;
  43. # ssl_session_timeout 10m;
  44. # ssl_ciphers HIGH:!aNULL:!MD5;
  45. # ssl_prefer_server_ciphers on;
  46. #
  47. # # Load configuration files for the default server block.
  48. # include /etc/nginx/default.d/*.conf;
  49. #
  50. # error_page 404 /404.html;
  51. # location = /40x.html {
  52. # }
  53. #
  54. # error_page 500 502 503 504 /50x.html;
  55. # location = /50x.html {
  56. # }
  57. # }
  58. }

2.server配置文件

  1. mkdir /etc/nginx/vhost && cd /etc/nginx/vhost
  2. vim welcome.com.conf
  3. server {
  4. listen 80;
  5. server_name welcome.com;
  6. #charset koi8-r;
  7. #access_log logs/host.access.log main;
  8. location / {
  9. root /data/webroot/dictation/;
  10. index index.html index.htm;
  11. }
  12. #error_page 404 /404.html;
  13. # redirect server error pages to the static page /50x.html
  14. error_page 500 502 503 504 /50x.html;
  15. location = /50x.html {
  16. root html;
  17. }
  18. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  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. }

3.html配置文件

  1. cd /data/webroot/dictation
  2. vim index.html
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="UTF-8">
  7. <title>我的 Nginx 网页</title>
  8. </head>
  9. <body>
  10. <h1>欢迎来到我的 Nginx 网页!</h1>
  11. <p>这是一个简单的 HTML 页面,由 Nginx 服务器提供服务。</p>
  12. </body>
  13. </html>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/210113
推荐阅读
相关标签
  

闽ICP备14008679号