nginx存放 资源的位置

/usr/share/nginx/html
image.png

  1. cat 配置路径 // 查看配置的内容

image.png

更改配置
vi /etc/nginx/nginx.conf

  1. user nginx;
  2. worker_processes auto;
  3. error_log /var/log/nginx/error.log;
  4. pid /run/nginx.pid;
  5. # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
  6. include /usr/share/nginx/modules/*.conf;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. tcp_nopush on;
  17. tcp_nodelay on;
  18. keepalive_timeout 65;
  19. types_hash_max_size 4096;
  20. include /etc/nginx/mime.types;
  21. default_type application/octet-stream;
  22. # Load modular configuration files from the /etc/nginx/conf.d directory.
  23. # See http://nginx.org/en/docs/ngx_core_module.html#include
  24. # for more information.
  25. include /etc/nginx/conf.d/*.conf;
  26. server {
  27. listen 80;
  28. listen [::]:80;
  29. server_name _;
  30. root /data/lcj; /// 更改静态资源目录为自己的目录
  31. # Load configuration files for the default server block.
  32. include /etc/nginx/default.d/*.conf;
  33. error_page 404 /404.html;
  34. location / {
  35. }
  36. location = /404.html {
  37. }
  38. error_page 500 502 503 504 /50x.html;
  39. location = /50x.html {
  40. }
  41. }
  42. # Settings for a TLS enabled server.
  43. #
  44. # server {
  45. # listen 443 ssl http2;
  46. # listen [::]:443 ssl http2;
  47. # server_name _;
  48. # root /usr/share/nginx/html;
  49. #
  50. # ssl_certificate "/etc/pki/nginx/server.crt";
  51. # ssl_certificate_key "/etc/pki/nginx/private/server.key";
  52. # ssl_session_cache shared:SSL:1m;
  53. # ssl_session_timeout 10m;
  54. # ssl_ciphers HIGH:!aNULL:!MD5;
  55. # ssl_prefer_server_ciphers on;
  56. #
  57. # # Load configuration files for the default server block.
  58. # include /etc/nginx/default.d/*.conf;
  59. #
  60. # error_page 404 /404.html;
  61. # location = /40x.html {
  62. # }
  63. #
  64. # error_page 500 502 503 504 /50x.html;
  65. # location = /50x.html {
  66. # }
  67. # }
  68. }
  1. mkdir -p /data/lcj // 创建目录
  2. touch /data/www/index.html //创建一个静态文件
  3. vi /data/www/index.html // 自由填写文件内容

加载nginx配置后访问http:///index.html 403了!!

关闭SElinux

  1. setenforce 0