test_port
1234567891011121314151617package mainimport ( "fmt" "net")var address_str stringfunc main() { fmt.Scanln(&address_str) _, err := net.Dial("tcp", address_str) if err != nil { fmt.Println(address_str + " is error,check it!!!") }}
nginx root与alias的区别
nginx root与alias的区别nginx指定文件路径有两种方式root和alias,指令的使用方法和作用域:
12345678[root]语法:root path默认值:root html配置段:http、server、location、if[alias]语法:alias path配置段:location
root与alias主要区别在于nginx如何解释location后面的uri,这会使两者分别以不同的方式将请求映射到服务器文件上。root的处理结果是:root路径+location路径alias的处理结果是:使用alias路径替换location路径alias是一个目录别名的定义,root则是最上层目录的定义。还有一个重要的区别是alias后面必须要用“/”结束,否则会找不到文件。而root则可有可无。
root实例:
1234567location ^~ /t/ { root /www/root/html/;}location ^~ /t/ { root /www/root/html/;}
如果一个请求的URI是/ ...
iostat命令详解
iostat用于输出cpu和磁盘I/O的统计信息。命令格式
iostat --help
Usage: iostat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]
[ -j { ID | LABEL | PATH | UUID | ... } [ <device> [...] | ALL ] ]
[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ]
输出示例
# iostat
Linux 2.6.32-573.el6.x86_64 (localhost.localdomain) 03/28/2017 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %i ...
安装爬虫框架
安装爬虫框架
背景介绍
直接使用requests,Selenium等库进行爬虫时,可以达到预期的效果。但是写多了会发现许多模块是可以复用的。如果把这些组件抽取出来,就会慢慢行程一个框架的雏形。
利用框架,可以不去关心功能的实现方式,大大简化代码量。。
pyspider安装
pyspider需要Phantomjs。具体安装详见 4.安装请求库
12345678910111213yum install libcurl*export LDFLAGS=-L/usr/local/opt/openssl/libexport CPPFLAGS=-I/usr/local/opt/openssl/includeexport PYCURL_SSL_LIBRARY=opensslexport PYCURL_SSL_LIBRARY=nsspip3 install pycurlpip3 install pyspider#验证pyspider all #命令行输入#会开启本地的5000端口
scrapy安装
1234567891011yum groupinstall development to ...
cdn
准备工作server1
yum install varnish-*
#关闭selinux和iptables
server2server3
yum install -y httpd
#编辑默认发布文件
#关闭selinux和iptables
单个缓存cd /etc/varnish/
vim /etc/sysconfig/varnish #配置文件
#66行 端口改为80
vim default.vcl
8行 地址改为server2IP
/etc/init.d/varnish start #启动服务
vim default.vcl #在第10行』之后
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT from westos cache";
}
else {
set resp.http. ...