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
.

最新文章

  1. tomcat和HTTP
  2. linux下,Python 多版本共存,及Pip,Easy_install 安装扩展包
  3. C语言字符串与数字相互转换
  4. scala泛型
  5. Codeforces Round #259 (Div. 2)AB
  6. java软件设计的三层结构
  7. javabean实现serializable有什么用?为什么数据库持久就Bean实现这个接口?
  8. Hadoop on Mac with IntelliJ IDEA - 1 解决input path does not exist问题
  9. [LeetCode] 11. Container With Most Water My Submissions Question 解题思路
  10. datatables,表格
  11. Linux Redis自动启动,Redis开机启动,Linux Redis设置开机启动
  12. 使用quartz实现不重启服务器修改自定义配置
  13. 【移动开发】SharedPreferences的兼容版本
  14. scp 脚本
  15. java中构造方法和普通方法的区别
  16. springMvc + Maven 项目提示 hessian 依赖包 无法下载;
  17. C++下实现同接口下多个类作为参数的调用和传参
  18. 【20181031T1】一串数字【分解质因数+贪心】
  19. How To Use XDOLoader to Manage, Download and Upload Files? (DOC ID 469585.1)
  20. 最短路问题(floyd算法)(优化待续)

热门文章

  1. 论文阅读笔记十二:Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation(DeepLabv3+)(CVPR2018)
  2. 将labelme 生成的.json文件进行可视化的代码+label.png 对比度处理的matlab代码
  3. ubuntu下配置反向代理
  4. 步步为营-74-Request,Response和server的其他成员
  5. 常见的User-Agent及免费代理IP网站
  6. python基础面试题(一)
  7. OpenCV-Python入门教程7-PyQt编写GUI界面
  8. 【C++ Primer | 10】泛型算法
  9. mysql如何在一张表中插入一万条数据?(用存储过程解决)
  10. exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused