Chinaunix首页 | 论坛 | 博客
  • 博客访问: 460376
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1139
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-14 16:47
个人简介

路漫漫其修远兮,吾将上下而求索

文章分类

全部博文(145)

文章存档

2016年(10)

2015年(15)

2014年(120)

我的朋友

分类: 系统运维

2015-06-17 16:34:59

安装完nginx服务器后发现nginx的根目录在/usr/share/nginx/html/下,但是对于部署文件来说,在该目录下是不太习惯的,我就尝试着更改nginx访问的根目录

点击(此处)折叠或打开

  1. # vi /etc/nginx/conf.d/default.conf

  2.  

  3. #
  4. # The default server
  5. #
  6. server {
  7. listen 80;
  8. server_name localhost;
  9. root /var/www; #修改新的目录为var下的www目录

  10. #charset koi8-r;

  11. #access_log logs/host.access.log main;

  12. location / {
  13. root /var/www;
  14. index index.html index.htm index.php index.phtml; #添加index.php和index.phtml
  15. # example
  16. #ModSecurityEnabled on;
  17. #ModSecurityConfig /etc/nginx/modsecurity.conf;
  18. }

  19. error_page 404 /404.html;
  20. location = /404.html {
  21. root /var/www; #修改新的目录文件
  22. }

  23. # redirect server error pages to the static page /50x.html
  24. #
  25. error_page 500 502 503 504 /50x.html;
  26. location = /50x.html {
  27. root /var/www; #修改新的目录文件
  28. }

  29. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  30. #
  31. #location ~ \.php$ {
  32. # proxy_pass http://127.0.0.1;
  33. #}

  34. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  35. #
  36. location ~ \.php$ {
  37. root /var/www; #修改新的目录文件
  38. fastcgi_pass 127.0.0.1:9000;
  39. fastcgi_index index.php;
  40. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  41. include fastcgi_params;
  42. }

  43. # deny access to .htaccess files, if Apache's document root
  44. # concurs with nginx's one
  45. #
  46. #location ~ /\.ht {
  47. # deny all;
  48. #}
  49. }
#  :wq!  #保存并退出


 重启nginx服务器


#  service nginx restart


即可修改成功!

阅读(1162) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~