上一节记录了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目录设置的更多相关文章

  1. Linux(CentOS)下设置nginx开机自动启动(2个办法)

    首先,在linux系统的/etc/init.d/目录下创建nginx文件,使用如下命令: vim /etc/init.d/nginx 在脚本中添加如下命令: #!/bin/sh # # nginx - ...

  2. linux nginx配置新项目加域名(设置绑定域名)

    转自:linux nginx配置新项目加域名 找到nginx的配置文件 nginx/nginx.conf 第一种方,法直接在nginx.com里面配置 user www www; worker_pro ...

  3. linux网站目录及Apache权限的设置

    apache服务器访问权限设置禁止所有访问:Options Indexes FollowSymLinks 改为 Option None   Apache单个或多个目录禁止访问方法   这种方法通常用来 ...

  4. nginx目录安全设置

    nginx目录安全设置<pre> location ~ /\. { deny all; }</pre>这样所有隐藏文件都不会以URL方式打开了

  5. linux 网站目录权限设置

    Linux下Apache网站目录读写权限的设置 网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定. 我们假设http服务器运行的用户和用户组是www,网站用户为cen ...

  6. LINUX动态库(.SO)搜索路径(目录)设置方法

    LINUX动态库(.SO)搜索路径(目录)设置方法 [root@VM_0_11_centos ld.so.conf.d]# cat /etc/ld.so.confinclude ld.so.conf. ...

  7. Linux上如何设置nginx开机启动

    连接上linux后输入以下命令--vim /etc/init.d/nginx 然后在这个空文件写入下面内容: 保存好后,修改下该文件权限--chmod 777 /etc/init.d/nginx 然后 ...

  8. linux+nginx+mysql+php

    LNMP(linux+nginx+mysql+php)服务器环境配置   一.简介 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为 “engine X”, 是一个高性能的 ...

  9. Linux Debian 7部署LEMP(Linux+Nginx+MySQL+PHP)网站环境

    我们在玩VPS搭建网站环境的时候,都经常看到所谓的LAMP.LNMP.LEMP,LAMP, 其中的A代表APECHE WEB驱动环境,LNMP中的N代表NGINX驱动环境,只不过海外的叫法NGINX ...

随机推荐

  1. Postgresql: UUID的使用

    默认安装的 Postgresql 是不带 UUID 函数的,为了生成一个 UUID,我们必须装载它到数据库中. CREATE EXTENSION "uuid-ossp"; 然后就可 ...

  2. mvc 使用预置队列类型存储异常对象

    using PaiXie.Utils; using System; using System.Collections.Generic; using System.Linq; using System. ...

  3. SteveY对Amazon和Google平台的吐槽

    Steve Yegge, Amazon的前员工,现任Google员工,其本来想在Google+上和Google的员工讨论一些关于平台的东西,结果不小心把圈子设成了Public,结果这篇文章就公开给了全 ...

  4. spring MVC中传递的参数对象中包含list的情况

    测试需要的jar包:spring 3.2.jar +  jackson-all-1.8.5.jar. 写代码时碰到个需要将对象里的子明细一起传递到controller里去,当时就想直接将参数一起传递过 ...

  5. 设计模式C++实现——模板方法模式

    模式定义: 模板方法模式在一个方法中定义了一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类能够在不改变算法结构的情况下,又一次定义算法中的某些步骤. 模板就是一个方法.更详细的说.这种方法将 ...

  6. 知识点:Oracle+表连接方式(内连接-外连接-自连接)+详解 来自百度文库

    Oracle 表之间的连接分为三种: 1. 内连接(自然连接) 2. 外连接 (1)左外连接 (左边的表不加限制)        (2)右外连接(右边的表不加限制)        (3)全外连接(左右 ...

  7. [转]Greenplum 通过gpfdist + EXTERNAL TABLE 并行导入数据

    摘要: Greenplum 提供了快速导入数据的方法,下面通过一个例子演示给大家. Greenplum 提供了快速导入数据的方法,下面通过一个例子演示给大家. 我们用TPCH测试中最大的表做导入测试 ...

  8. meterpreter命令大全

    在其最基本的使用,meterpreter 是一个 Linux 终端在受害者的计算机上.这样,我们的许多基本的Linux命令可以用在meterpreter甚至是在一个窗口或其他操作系统. 这里有一些核心 ...

  9. MySql(十):MySQL性能调优——MySQL Server性能优化

    本章主要通过针对MySQL Server( mysqld)相关实现机制的分析,得到一些相应的优化建议.主要涉及MySQL的安装以及相关参数设置的优化,但不包括mysqld之外的比如存储引擎相关的参数优 ...

  10. spark-submit的参数名称解析

    执行时需要传入的参数说明 Usage: spark-submit [options] <app jar | Python file> [app options] 参数名称 含义 --mas ...