停止 nginx -s stop
启动 nginx
配置 conf 下的nginx.conf 中的location->root 设置首页
安装nginx----------------------------------------------------------------------------------------
1.安装pcre (ubantu: apt-get install pcre \ centos:rpm -ivh pcre)
2.安装nginx (ubantu: apt-get install nginx \ centos:rpm -ivh nginx)
3.配置conf nginx.conf location->root
4.多配置 多个location /otherpath(~^ 等等)
详情可参考:http://www.runoob.com/linux/nginx-install-setup.html
求关注,相互交流喔
启动 nginx
配置 conf 下的nginx.conf 中的location->root 设置首页
安装nginx----------------------------------------------------------------------------------------
1.安装pcre (ubantu: apt-get install pcre \ centos:rpm -ivh pcre)
2.安装nginx (ubantu: apt-get install nginx \ centos:rpm -ivh nginx)
3.配置conf nginx.conf location->root
4.多配置 多个location /otherpath(~^ 等等)
详情可参考:http://www.runoob.com/linux/nginx-install-setup.html
nginx配置基本结构:http{ server{ location{ } } }
这里主要讲nginx的配置文件
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;#最大连接数
# multi_accept on;
}
http {
sendfile on;#是否支持文件下载
tcp_nopush on;#tcp禁止推送
tcp_nodelay on;#tcp禁止延时发送请求,一一回应,不采用打包发送的算法
keepalive_timeout 65;#超时时间
types_hash_max_size 2048;#文件上传大小MB
# server_tokens off; #采用令牌方式
# server_names_hash_bucket_size 64;#缓冲空间大小
# server_name_in_redirect off;#是否开启重定向,重定向会自动解析Local>http://blog.youkuaiyun.com/weiyuefei/article/details/38556593
include /etc/nginx/mime.types;#支持哪些方式访问
default_type application/octet-stream;
##
# Logging Settings 日志系统
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings 压缩支持
##
gzip on;
gzip_disable "msie6";#对于IE6不压缩
# gzip_vary on;#开启压缩缓存
# gzip_proxied any;# 做前端代理时启用该选项,表示无论后端服务器的headers头返回什么信息,都无条件启用压缩
# gzip_comp_level 6;#压缩级别,越小越快压缩效果越差
# gzip_buffers 16 8k;#压缩流大小
# gzip_http_version 1.1;#http协议版本
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;#防攻击的配置 include后就不需要在这个文件里面配置了 http://www.2cto.com/article/201308/238947.html
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
# 8000 server yy 文件服务器
server {
listen 8000; #指定端口
server_name file;#名称
charset utf-8;#编码
root /data/nginxfile ;#根目录
autoindex on;#自动索引文件
autoindex_exact_size off;#自动索引大小
autoindex_localtime on;#展示文件为服务器时间
}
# static server 80 静态服务器
server {
listen 80;
server_name yimaodang.cn;#访问该关键词(网站)时跳转到这个server
charset utf-8;
root /data/staticweb/WebContent;#根目录
index index.html index.htm;#指定首页
#这些类型的文件缓存时间是30天
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
}
}
#mail { 邮件服务器,不建议用这个...
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
求关注,相互交流喔