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的使用的更多相关文章

  1. 【转】Linux下nginx配置https协议访问的方法

    一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...

  2. VMware Linux 下 Nginx

    负载   VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三) Weiseditor 2014-11-26 23:42 阅读:1 评论 ...

  3. VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)

    首先启动Nginx 1. 相关浏览 两个 Tomcat 配置:  VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...

  4. VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)

    准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...

  5. Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...

  6. linux下nginx+php+mysql 自助环境搭建

    ++++++++++++++++++++++++++++++++++++++++++++++linux下nginx+php+mysql环境搭建+++++++++++++++++++++++++++++ ...

  7. linux下nginx结合keepalived实现主从切换的配置

    linux下nginx结合keepalived实现主从切换的配置   解决方法: 实现一个主nginx宕机,请求转到另一个nginx中. 1.确保两台nginx已启动,假如端口分别是192.168.0 ...

  8. linux下nginx服务器域名指定目录

    一般,域名指定ip之后,需要在ip所在的机器去指定相应站点的目录,否则域名会不起作用: 下面说说linux下的nginx服务器指定目录的细节: 域名绑定目录的配置文件都放到这里: /usr/local ...

  9. Linux下Nginx的安装与配置

    安装前需要安装pcre:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/1.解压缩:     tar xjpf pcre-7.8.tar.b ...

  10. Linux下Nginx安装/启动/重启/停止

    Nginx是高性能的web服务器也是非常好用反向代理服务器,可以实现负载均衡,动静分离等策略,在linux下用的非常多.下面是下载地址   http://nginx.org/en/download.h ...

随机推荐

  1. 获取git更新文件

    #获取最后一个版本的更新日志workspace2=/testtemplogdir=/testtmprm -rf ${logdir}/change.loggit diff --stat $GIT_PRE ...

  2. The error may exist in com/bjpowernode/dao/StudentDao.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderExcept

    The error may exist in com/bjpowernode/dao/StudentDao.xml### Cause: org.apache.ibatis.builder.Builde ...

  3. azkaban使用

    新建一个text文件,a.job,打包成zip包传到azkaban即可 方式1:job流   1. a.job内容范例: type=command command=hive shell command ...

  4. Vue.js货币格式化函数

    函数: const digitsRE = /(\d{3})(?=\d)/g export function currency (value, currency, decimals) { value = ...

  5. python下载想听的有声书,让喜马拉雅收费,我是程序员!

    from urllib import parse,request import urllib header_dict = {'User-Agent': 'Mozilla/5.0 (Windows NT ...

  6. WPF:如何高速更新Model中的属性

    原文:[WPF/MVVM] How to deal with fast changing properties In this article, I will describe a problem w ...

  7. 使用python解决算法和数据结构--使用栈实现符号匹配

    现在要自己来实现这些数据结构和常用算法了. 把基础再打牢一些. 栈的作用很大,无须多言. 我尽量看了题目要求,自己来实现代码的. # coding = utf-8 class Stack: def _ ...

  8. C#学习-面向对象

    封装:把客观事物封装成类,并将类内部的实现隐藏,以保证数据的完整性: 比如年龄赋值为负数,就是个例子.当我们把类的字段定义为公共类型时,外部对象可以直接对类内部的数据进行操作,此时无法对这些操作进行一 ...

  9. ASP.NET Core JWT认证授权介绍

    using JWTWebApi.Models; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetC ...

  10. Java 中 static 和 volatile 关键字的区别?

    static指的是类的静态成员,实例间共享 volatile跟Java的内存模型有关,线程执行时会将变量从主内存加载到线程工作内存,建立一个副本,在某个时刻写回.valatile指的每次都读取主内存的 ...