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 ...
随机推荐
- 【webservice】使用命令wsimport构建WebService客户端
wsimport命令介绍 在JDK的bin文件夹中,有一个wsimport.exe,这个工具依据wsdl文件生成相应的类文件,然后用这些类文件,就可以像调用本地的类一样调用WebService提供的方 ...
- mysql开发常用小结
1.时间转换 时间戳转时间 FROM_UNIXTIME 比如 FROM_UNIXTIME(1449480551/1000,'%Y-%m-%d %H:%i:%s') 如果是精确到毫秒的时间戳,则必 ...
- ViewPager 源码分析(一) —— setAdapter() 与 populate()
写在前面 做安卓也有一定时间了,虽然常用控件都已大致掌握,然而随着 Android N 的发布,不自觉的愈发焦虑起来.说来惭愧,Android L 的 Material Design 库里的许多控件都 ...
- Struts2之数据标签(二)
Struts2之数据标签(一):http://blog.csdn.net/u012561176/article/details/46848817 1.action标签:使用此标签能够同意在JSP页面中 ...
- Java Nashorn--Part 4
Nashorn 和 javax.script 包 Nashorn 并不是第一个在 Java 平台上运行的脚本语言.在Java 6 就提供了 javax.script java 包,它为脚本语言引擎提供 ...
- php-fpm进程关闭与重启脚本详解
先来理解一下什么是php-fpm PHP-FPM是一个PHP FastCGI管理器,是只用于PHP的. PHP-FPM其实是PHP源代码的一个补丁,旨在将FastCGI进程管理整合进PHP包中.必须将 ...
- Android 获取自带浏览器上网记录
先是搜索了一下,在manifest里添加 <uses-permission android:name="com.android.browser.permission.READ_HIST ...
- MySQL复制表结构、表数据
1.复制表结构及数据到新表 CREATE TABLE 新表SELECT * FROM 旧表 这种方法会将oldtable中所有的内容都拷贝过来,当然我们可以用delete from newtable; ...
- [转]Java中使用Runtime和Process类运行外部程序
帖子1: 使用Runtime.getRuntime().exec()方法可以在java程序里运行外部程序. 1. exec(String command) 2. exec(String comma ...
- springboot 整合 Redis 方法二
方法一请参考之前博文 spring boot 整合 redis 自己的版本 java8 + redis3.0 + springboot 2.0.0 1 spring boot已经支持集成 redis ...