Linux nginx目录设置
上一节记录了nginx的安装,这里来试着修改下配置文件。
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost;
root /data/wwwroot1;
charset utf-8;
#access_log logs/host.access.log main;
# / 所有做负债均衡 + 反向代理
location / {
root /data/wwwroot1;
index index.html index.htm;
} error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
注意 这行代码,将访问目录由默认的html目录指向了,root 下面配置的目录,
root /data/wwwroot1;
修改完成后软重启
[root@VM_0_4_centos ~]# kill -HUP 28041
也可以使用
#检测配置文件是否合法
/usr/local/nginx/sbin/nginx -t
重启:
/usr/local/nginx/sbin/nginx -s reload
这样,文件放置到 /data/wwwroot1 目录下,就能够访问到了。
Linux nginx目录设置的更多相关文章
- Linux(CentOS)下设置nginx开机自动启动(2个办法)
首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令: vim /etc/init.d/nginx 在脚本中添加如下命令: #!/bin/sh # # nginx - ...
- linux nginx配置新项目加域名(设置绑定域名)
转自:linux nginx配置新项目加域名 找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_pro ...
- linux网站目录及Apache权限的设置
apache服务器访问权限设置禁止所有访问:Options Indexes FollowSymLinks 改为 Option None Apache单个或多个目录禁止访问方法 这种方法通常用来 ...
- nginx目录安全设置
nginx目录安全设置<pre> location ~ /\. { deny all; }</pre>这样所有隐藏文件都不会以URL方式打开了
- linux 网站目录权限设置
Linux下Apache网站目录读写权限的设置 网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定. 我们假设http服务器运行的用户和用户组是www,网站用户为cen ...
- LINUX动态库(.SO)搜索路径(目录)设置方法
LINUX动态库(.SO)搜索路径(目录)设置方法 [root@VM_0_11_centos ld.so.conf.d]# cat /etc/ld.so.confinclude ld.so.conf. ...
- Linux上如何设置nginx开机启动
连接上linux后输入以下命令--vim /etc/init.d/nginx 然后在这个空文件写入下面内容: 保存好后,修改下该文件权限--chmod 777 /etc/init.d/nginx 然后 ...
- linux+nginx+mysql+php
LNMP(linux+nginx+mysql+php)服务器环境配置 一.简介 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为 “engine X”, 是一个高性能的 ...
- Linux Debian 7部署LEMP(Linux+Nginx+MySQL+PHP)网站环境
我们在玩VPS搭建网站环境的时候,都经常看到所谓的LAMP.LNMP.LEMP,LAMP, 其中的A代表APECHE WEB驱动环境,LNMP中的N代表NGINX驱动环境,只不过海外的叫法NGINX ...
随机推荐
- ==和equals的简单比较
前言:==和equals这个两个东西,经常放在一块做比较,下面我也给出一个简单的例子,对他俩进行一个简单的比较,先看例子,然后在看结论.(实验环境:win7+jdk7) 1:==和equals简单比较 ...
- TOP字句加SQL变量的相关问题
SQL Server数据库中的变量可以加载TOP字句之后,下文将对TOP字句加SQL变量的相关问题进行讨论,供您参考,希望对您学习SQL数据库有所帮助. SQL Server2005开始,TOP子句后 ...
- html input控件总结
Input表示Form表单中的一种输入对象,其又随Type类型的不同而分文本输入框,密码输入框,单选/复选框,提交/重置按钮等,下面一一介绍. 1,type=text 输入类型是text,这是我们见的 ...
- Spring-MVC配置Gson做为Message Converter解析Json
Spring-MVC配置Gson做为Message Converter解析Json 在学习Spring的时候看到可以使用@RequestBody 和@ResponseBody注解来是的Spring自动 ...
- MongoDB联合查询 -摘自网络
1.简单手工关联 首先将结果查询出来放到一个变量里面,然后再查询 u = db.user.findOne({author:"wangwenlong"}); for(var p = ...
- Python 3 的安装
python 3 的安装: 背景: 之前都是在Pychram上写,我的windows下的python版本是3.5,今天要把一个小脚本上到生产环境上. 无奈我服务器上的python版本是2.6.6.所以 ...
- 802.11ax前瞻4:802.11ax与HiperLan
序言 在早期wi-fi发展过程中,欧洲还出现过一个同期的无线局域网协议.HiperLan .所谓网络发展始终是"分久必合.合久必分".不管是有线网络当前SDN的引入.还是无线网络下 ...
- 云服务设置多台tomcat开机自启动
紧接此篇文章:http://www.cnblogs.com/leechenxiang/p/7091731.html 1. 修改profile,添加红框内6行代码 vim /etc/profile 代码 ...
- IOS 学习 Key-value coding
1 前言 本节我们主要介绍键值编码,以及如何使一个类符合KVC编码. 2 详述 键-值编码是一个对于间接访问一个对象属性和关系使用字符标识的机制.它支持或者关系几个特别的Cocoa编程机制和技术,在C ...
- HTML杂记
1.URL uniform resource locator 遵循格式: scheme://host.domain:port/path/filename scheme - 定义因特网服务的类型.最常 ...