Linux下nginx的使用
day02
.远程连接服务器故障排查
)道路是否通畅
)是否有劫财劫色
xxxxxx no route to host xxxx
)洗浴中心是否提供你想要的服务
sshd远程连接服务 == ip 端口 用户名 密码 ll /var/log/secure #用户访问系统的记录 rz windows文件上传到linux
sz 把Linux文件下载到windows .tar.gz .zip压缩包是linux和windows默认支持的。 unzip secure-.zip xshell 远程连接
xftp ftp工具
https://www.netsarang.com/download/down_form.html?code=523 查看日志
.less f或空格向下一页 b上一页
.head/tail
.grep grep 'Failed password' secure- .命令 . day03
.yum源 使用光盘里面的rpm包
.关闭 iptables 和selinux
)当前正在运行的
/etc/init.d/iptables stop )关门开机自启动
chkconfig iptables off
.运行级别与单用户
.定时任务 linux启动过程 http请求与响应过程 nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz 编译安装nginx前的准备
.添加一个用户
useradd -s /sbin/nologin -M www
#创建虚拟用户
#linux每个进程要有一个对应的用户 [root@oldboyedu-s6 nginx-1.12.]# id www
uid=(www) gid=(www) groups=(www)
[root@oldboyedu-s6 nginx-1.12.]# su - www
su: warning: cannot change directory to /home/www: No such file or directory
This account is currently not available. .安装nginx依赖软件包
#pcre-devel perl语言的兼容正则表达式
#openssl-devel https yum install pcre-devel openssl-devel -y [root@oldboyedu-s6 nginx-1.12.]# rpm -qa pcre-devel openssl-devel
pcre-devel-7.8-.el6.x86_64
openssl-devel-1.0.1e-.el6.x86_64 ##
##[root@oldboyedu-s6 ~]# ll /mnt/Packages/pcre-devel-7.8-.el6.x86_64.rpm /mnt/Packages/openssl-devel-1.0.1e-.el6.x86_64.rpm
##-r--r--r-- root root Mar /mnt/Packages/openssl-devel-1.0.1e-.el6.x86_64.rpm
##-r--r--r-- root root Jul /mnt/Packages/pcre-devel-7.8-.el6.x86_64.rpm
## .编译安装nginx ./configure --user=www --group=www --prefix=/application/nginx-1.12. --with-http_stub_status_module --with-http_ssl_module
#--user 用户
#--group 用户组
#--prefix 安装到哪里
#两个模块--with-http_stub_status_module --with-http_ssl_module echo $? make make install [root@oldboyedu-s6 ~]# md5sum /root/nginx-1.12..tar.gz
4d2fc76211435f029271f1cf6d7eeae3 /root/nginx-1.12..tar.gz [root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx -t
nginx: the configuration file /application/nginx-1.12./conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.12./conf/nginx.conf test is successful [root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx
[root@oldboyedu-s6 nginx-1.12.]# ss -lntup|grep
tcp LISTEN *: *:* users:(("nginx",,),("nginx",,)) [root@oldboyedu-s6 nginx-1.12.]# pwd
/application/nginx-1.12.
[root@oldboyedu-s6 nginx-1.12.]# ll
total
drwx------ www root Mar : client_body_temp
drwxr-xr-x root root Mar : conf nginx配置文件的目录
drwx------ www root Mar : fastcgi_temp
drwxr-xr-x root root Mar : html nginx站点目录 网站的根目录
drwxr-xr-x root root Mar : logs nginx日志
drwx------ www root Mar : proxy_temp
drwxr-xr-x root root Mar : sbin nginx命令
drwx------ www root Mar : scgi_temp
drwx------ www root Mar : uwsgi_temp ├── client_body_temp
├── conf
│ ├── fastcgi.conf
│ ├── fastcgi.conf.default
│ ├── fastcgi_params
│ ├── fastcgi_params.default
│ ├── koi-utf
│ ├── koi-win
│ ├── mime.types
│ ├── mime.types.default
│ ├── nginx.conf #nginx的主配置文件
│ ├── nginx.conf.default
│ ├── scgi_params
│ ├── scgi_params.default
│ ├── uwsgi_params
│ ├── uwsgi_params.default
│ └── win-utf
├── fastcgi_temp
├── html
│ ├── 50x.html
│ └── index.html #网站默认的首页文件
├── logs
│ ├── access.log #访问日志
│ ├── error.log
│ └── nginx.pid
├── proxy_temp
├── sbin
│ └── nginx
├── scgi_temp
└── uwsgi_temp directories, files 10.0.0.1 - - [/Mar/::: +] "GET /favicon.ico HTTP/1.1" "http://10.0.0.200/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET / HTTP/1.1" "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET /favicon.ico HTTP/1.1" "http://10.0.0.200/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET / HTTP/1.1" "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET /favicon.ico HTTP/1.1" "http://10.0.0.200/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET / HTTP/1.1" "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"
10.0.0.1 - - [/Mar/::: +] "GET /favicon.ico HTTP/1.1" "http://10.0.0.200/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" egrep -v '^$|#' conf/nginx.conf.default >conf/nginx.conf #优雅的重启nginx √√√√√√
/application/nginx-1.12./sbin/nginx -s reload #关闭nginx 然后开启
/application/nginx-1.12./sbin/nginx -s stop
/application/nginx-1.12./sbin/nginx mkdir -p /application/nginx-1.12./html/{www,bbs,blog} for name in www bbs blog;do echo $name.etiantian.org> /application/nginx-1.12./html/$name/index.html ;done
for name in www bbs blog;do cat /application/nginx-1.12./html/$name/index.html ;done [root@oldboyedu-s6 nginx-1.12.]# cat conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
} [root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx -t
nginx: the configuration file /application/nginx-1.12./conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.12./conf/nginx.conf test is successful
[root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx -s reload 搭建www.etiantian.org网站流程
.修改nginx.conf文件 worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
} .创建环境
mkdir -p /application/nginx-1.12./html/{www,bbs,blog}
for name in www bbs blog;do echo $name.etiantian.org> /application/nginx-1.12./html/$name/index.html ;done
for name in www bbs blog;do cat /application/nginx-1.12./html/$name/index.html ;done .检查语法并重启 [root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx -t
nginx: the configuration file /application/nginx-1.12./conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.12./conf/nginx.conf test is successful
[root@oldboyedu-s6 nginx-1.12.]# /application/nginx-1.12./sbin/nginx -s reload .windows测试 浏览器(注意缓存)
)修改 \etc\hosts
10.0.0.200 www.etiantian.org bbs.etiantian.org blog.etiantian.org )浏览器测试 .Linux命令行测试
curl -vH Host: www.etiantian.org 10.0.0.200 排错流程:
.linux命令行是否能显示
curl -vH Host:www.etiantian.org 10.0.0.200 .windows 本地shell
ping [root@oldboyedu-s6 nginx-1.12.]# cat conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
server {
listen ;
server_name bbs.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
server {
listen ;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
} } [root@oldboyedu-s6 nginx-1.12.]# curl -H Host:bbs.etiantian.org 10.0.0.200
bbs.etiantian.org
[root@oldboyedu-s6 nginx-1.12.]# curl -H Host:blog.etiantian.org 10.0.0.200
blog.etiantian.org 小结:
.软件目录 配置文件讲解
.搭建www网站
.搭建多个网站(虚拟主机) location “~”用于区分大小写(大小写敏感)的匹配; ~ /images {} “~*” 用于不区分大小写的匹配。还可以用逻辑操作符!对上面的匹配取反,即!~ 和 !~*。 “^~”作用是在常规的字符串匹配检查之后,不做正则表达式的检查,即如果最明确的那个字符串匹配的location配置中有此前缀,那么不做正则表达式的检查。 [root@oldboyedu-s6 nginx-1.12.]# cat conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ; server {
listen ;
server_name www.etiantian.org etiantian.org;
root html/www;
location / {
return ;
} location /documents/ {
return ;
}
location ^~ /images/ {
return ;
}
location ~* \.(gif|jpg|jpeg)$ {
return ;
}
}
} ^~
~*
/documents/
/ 第1名:“location ~* \.(gif|jpg|jpeg)$ {” 正则匹配
第2名:“location /documents/ {” 匹配常规字符串,如果有正则则优先匹配正则。
第3名:“location / {” 所有location都不能匹配后的默认匹配。 [root@oldboyedu-s6 nginx-1.12.]# curl -I 10.0.0.200
HTTP/1.1 Unauthorized
Server: nginx/1.12.
Date: Thu, Mar :: GMT
Content-Type: text/html
Content-Length:
Connection: keep-alive [root@oldboyedu-s6 nginx-1.12.]#
[root@oldboyedu-s6 nginx-1.12.]# curl -I 10.0.0.200/documents/index.html
HTTP/1.1 Forbidden
Server: nginx/1.12.
Date: Thu, Mar :: GMT
Content-Type: text/html
Content-Length:
Connection: keep-alive [root@oldboyedu-s6 nginx-1.12.]# curl -I 10.0.0.200/documents/w.jpg
HTTP/1.1 Internal Server Error
Server: nginx/1.12.
Date: Thu, Mar :: GMT
Content-Type: text/html
Content-Length:
Connection: close [root@oldboyedu-s6 nginx-1.12.]#
[root@oldboyedu-s6 nginx-1.12.]# curl -I 10.0.0.200/images/www.jpg
HTTP/1.1 Not Found
Server: nginx/1.12.
Date: Thu, Mar :: GMT
Content-Type: text/html
Content-Length:
Connection: keep-alive 小结:
.linux启动过程
.nginx 软件目录 配置文件讲解
.搭建www网站
.搭建多个网站(虚拟主机)
.nginx location 用法 redis day03
.yum源 使用光盘里面的rpm包
.关闭 iptables 和selinux
)当前正在运行的
/etc/init.d/iptables stop )关门开机自启动
chkconfig iptables off
.运行级别与单用户
.定时任务 linux启动过程 day02
.远程连接服务器故障排查
ll /var/log/secure #用户访问系统的记录
.lrzsz zip tar
rz windows文件上传到linux
sz 把Linux文件下载到windows
unzip secure-.zip
查看日志
).less f或空格向下一页 b上一页
).head/tail
).grep grep 'Failed password' secure- .命令 day01
.
Linux下nginx的使用的更多相关文章
- 【转】Linux下nginx配置https协议访问的方法
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- VMware Linux 下 Nginx
负载 VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三) Weiseditor 2014-11-26 23:42 阅读:1 评论 ...
- VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)
首先启动Nginx 1. 相关浏览 两个 Tomcat 配置: VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...
- VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)
准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...
- Linux下nginx编译安装教程和编译参数详解
这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...
- linux下nginx+php+mysql 自助环境搭建
++++++++++++++++++++++++++++++++++++++++++++++linux下nginx+php+mysql环境搭建+++++++++++++++++++++++++++++ ...
- linux下nginx结合keepalived实现主从切换的配置
linux下nginx结合keepalived实现主从切换的配置 解决方法: 实现一个主nginx宕机,请求转到另一个nginx中. 1.确保两台nginx已启动,假如端口分别是192.168.0 ...
- linux下nginx服务器域名指定目录
一般,域名指定ip之后,需要在ip所在的机器去指定相应站点的目录,否则域名会不起作用: 下面说说linux下的nginx服务器指定目录的细节: 域名绑定目录的配置文件都放到这里: /usr/local ...
- Linux下Nginx的安装与配置
安装前需要安装pcre:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/1.解压缩: tar xjpf pcre-7.8.tar.b ...
- Linux下Nginx安装/启动/重启/停止
Nginx是高性能的web服务器也是非常好用反向代理服务器,可以实现负载均衡,动静分离等策略,在linux下用的非常多.下面是下载地址 http://nginx.org/en/download.h ...
随机推荐
- spring cloud Hystrix监控面板Hystrix Dashboard和Turbine
我们提到断路器是根据一段时间窗内的请求情况来判断并操作断路器的打开和关闭状态的.而这些请求情况的指标信息都是HystrixCommand和HystrixObservableCommand实例在执行过程 ...
- String 类的实现(3)String类常用函数
2 #include<iostream> 3 #include<stdio.h> 4 #include<assert.h> 5 #include <iom ...
- Ajax增删改查-----------查
查询所有 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- Android常用框架和控件使用
Router框架 https://github.com/iqiyi/Andromeda/blob/master/CHINESE_README.md https://github.com/alibaba ...
- [转] 跨域资源共享 CORS 详解
CORS是一个W3C标准,全称是"跨域资源共享"(Cross-origin resource sharing). 它允许浏览器向跨源服务器,发出XMLHttpRequest请求,从 ...
- javascript OOP实例—探测器
<script> /*所有探测器都有探测的方法和分析的方法,分析当前的浏览器环境,不管是浏览器还是nodejs*/ /*container容器探测器*/ /*link链接探测器*/ /*外 ...
- springboot中使用拦截器、监听器、过滤器
拦截器.过滤器.监听器在web项目中很常见,这里对springboot中怎么去使用做一个总结. 1. 拦截器(Interceptor) 我们需要对一个类实现HandlerInterceptor接 ...
- Android抓包方法(转)
Android抓包方法(转) 作者:Findyou 地址:http://www.cnblogs.com/findyou/p/3491014.html 前言: 做前端测试,基本要求会抓包,会分析请求数据 ...
- onclick传对象
用onclick传对象的时候,用jquery无法进行操作 onclick=(this) 接收到参数后只需要转化一下 console.log($(obj).html());
- BeautifulSoup下Unicode乱码解决
今天在用scrapy爬某个网站的数据,其中DOM解析我用的是BeautifulSoup,速度上没有XPath来得快,不过因为用了习惯了,所以一直用的bs,版本是bs4 不过在爬取过程中遇到了一些问题, ...