Linux nginx目录设置

上一节记录了nginx的安装,这里来试着修改下配置文件。

1#user nobody; 2worker_processes 1; 3 4#error_log logs/error.log; 5#error_log logs/error.log notice; 6#error_log logs/error.log info; 7 8#pid logs/nginx.pid; 9 10 11events { 12 worker_connections 1024; 13} 14 15 16http { 17 include mime.types; 18 default_type application/octet-stream; 19 20 #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 21 # '$status $body_bytes_sent "$http_referer" ' 22 # '"$http_user_agent" "$http_x_forwarded_for"'; 23 24 #access_log logs/access.log main; 25 26 sendfile on; 27 #tcp_nopush on; 28 29 #keepalive_timeout 0; 30 keepalive_timeout 65; 31 32 #gzip on; 33 34 server { 35 listen 80; 36 server_name localhost; 37 root /data/wwwroot1; 38 charset utf-8; 39 #access_log logs/host.access.log main; 40 # / 所有做负债均衡 + 反向代理 41 location / { 42 root /data/wwwroot1; 43 index index.html index.htm; 44 } 45 46 error_page 404 /404.html; 47 48 # redirect server error pages to the static page /50x.html 49 # 50 error_page 500 502 503 504 /50x.html; 51 location = /50x.html { 52 root html; 53 } 54 55 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 56 # 57 #location ~ \.php$ { 58 # proxy_pass http://127.0.0.1; 59 #} 60 61 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 62 # 63 #location ~ \.php$ { 64 # root html; 65 # fastcgi_pass 127.0.0.1:9000; 66 # fastcgi_index index.php; 67 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 68 # include fastcgi_params; 69 #} 70 71 # deny access to .htaccess files, if Apache's document root 72 # concurs with nginx's one 73 # 74 #location ~ /\.ht { 75 # deny all; 76 #} 77 } 78 79 80 # another virtual host using mix of IP-, name-, and port-based configuration 81 # 82 #server { 83 # listen 8000; 84 # listen somename:8080; 85 # server_name somename alias another.alias; 86 87 # location / { 88 # root html; 89 # index index.html index.htm; 90 # } 91 #} 92 93 94 # HTTPS server 95 # 96 #server { 97 # listen 443 ssl; 98 # server_name localhost; 99 100 # ssl_certificate cert.pem; 101 # ssl_certificate_key cert.key; 102 103 # ssl_session_cache shared:SSL:1m; 104 # ssl_session_timeout 5m; 105 106 # ssl_ciphers HIGH:!aNULL:!MD5; 107 # ssl_prefer_server_ciphers on; 108 109 # location / { 110 # root html; 111 # index index.html index.htm; 112 # } 113 #} 114 115}

注意 这行代码,将访问目录由默认的html目录指向了,root 下面配置的目录,

root /data/wwwroot1;  

修改完成后软重启

[root@VM_0_4_centos ~]# kill -HUP 28041

也可以使用

1#检测配置文件是否合法 2/usr/local/nginx/sbin/nginx -t

重启:

/usr/local/nginx/sbin/nginx -s reload

这样,文件放置到 /data/wwwroot1 目录下,就能够访问到了。

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

mysql设置时区

mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0

Linux nginx目录设置 - HelloWorld