一、编辑my.conf
vi /etc/my.conf
二、在[mysqld]下添加
port=3506
三、重启mysql服务
#/etc/init.d/mysqld restart
一、编辑my.conf
vi /etc/my.conf
二、在[mysqld]下添加
port=3506
三、重启mysql服务
#/etc/init.d/mysqld restart
1、启用lighttpd的反向代理模块:
编辑/etc/lighttpd/modules.conf文件,找到以下代码:
## ## mod_proxy ## #include "conf.d/proxy.conf"
去掉以下代码开头的“#”号即可
#include "conf.d/proxy.conf"
2、编辑/etc/lighttpd/lighttpd.conf文件,添加以下代码:
#tomcat $HTTP["host"] =~ "(abc\.com|www\.abc\.com)$" { proxy.balance = "hash" proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 8080 ) ) ) }
3、重启lighttpd服务器
service lighttpd restart
关于匹配符的初步理解:
== 意味着匹配规则将使用普通的方法
=~ 意味着匹配规则将使用正则表达式?(未确定)
!~ 意味着不匹配规则将使用正则表达式
^表示开头
其他的一些配置参考:
$HTTP["host"] =~ "(sway\.com\.cn|www\.sway\.com\.cn)$" { server.document-root = "/home/xinsiwei.20150120.igongcha/ROOT" $HTTP["url"] !~ "\.(gif|jpg|png|txt|html|css|js|swf)$" { proxy.server = ( "/" => ( ( "host" => "127.0.0.1", "port" => 8128 ) ) ) } }
这个的意思是,除了gif|jpg|png|txt|html|css|js|swf外,其余请求全部转发到127.0.0.1:8128端口上去
$HTTP["host"] == "liaoxuefeng.com" { url.redirect = ( "^/(.*)" => "http://www.sway.com.cn/$1" ) }
这个的意思是,所有域名为liaoxuefeng.com的请求,全部跳转到http://www.liaoxuefeng.com/上去,并且自动匹配并补充url地址
$HTTP["host"] == "www.sway.com.cn" { server.name = "www.sway.com.cn" server.document-root = "/home/www/sway/" $HTTP["url"] !~ "^(favicon.ico|.*/static/.*)$" { proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 8000 ))) } }
这个的意思是,除了favicon.ico及文件夹为/static/的url外,将全部请求转发到8000端口上
jrebel-6.4.0-Enterprise.Cracked-ZCT
通用破解6.4.0
1.下载并解压压缩包
2.复制jrebel6文件夹里面的jrebel.jar文件到myeclipse目录下的plugins\org.zeroturnaround.eclipse.embedder_6.4.1.RELEASE\jrebel里面
3.复制jrebel.lic到myeclipse目录下的plugins\org.zeroturnaround.eclipse.embedder_6.4.1.RELEASE里面
4.运行myeclipse后打开jrebel界面,选择刚刚拷贝的jrebel.lic文件,破解完成
yum install gcc
你的机器里没有安装任何C语言编译器,可以安装gcc。 可以在安装盘里找到gcc相关的包进行安装,不过会比较繁琐,因为关联的包会比较多。 如果可以上网,使用yum安装是比较好的选择:
yum install gcc
由于公司产品用了很多activex dll,而我的操作系统是64位的win7,在注册这些dll时碰到了很多问题,经过摸索,最后还是成功注册了,步骤如下:
1、在C:\Windows\SysWOW64\下新建目录egs29oa,复制所有的dll到这个目录下
2、点击开始,在“搜索程序和文件”里键入cmd,然后在搜索出来的cmd菜单上右键,以管理员的权限运行,
3、此时cmd提示符为c:\Windows\System32,键入cd \windows\syswow64,改变提示符为c:\windows\syswow64
4、在cmd里键入regsvr32 egs29oa\flow.dll,回车,然后提示注册成功(注意此时使用的是syswow64目录下的regsvr32.exe,而不是system32下的regsvr32.exe)。
5、如果有其他的dll,也可依样画葫芦。
1、关闭所有的 INPUT FORWARD OUTPUT 只对某些端口开放。
下面是命令实现:
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
再用命令 iptables -L -n 查看 是否设置好, 好看到全部 DROP 了
这样的设置好了,我们只是临时的, 重启服务器还是会恢复原来没有设置的状态
还要使用 service iptables save 进行保存
看到信息 firewall rules 防火墙的规则 其实就是保存在 /etc/sysconfig/iptables
可以打开文件查看 vi /etc/sysconfig/iptables
2、
下面我只打开22端口,看我是如何操作的,就是下面2个语句
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT
再查看下 iptables -L -n 是否添加上去, 看到添加了
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:22
现在Linux服务器只打开了22端口,用putty.exe测试一下是否可以链接上去。
可以链接上去了,说明没有问题。
最后别忘记了保存 对防火墙的设置
通过命令:service iptables save 进行保存
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT
针对这2条命令进行一些讲解吧
-A 参数就看成是添加一条 INPUT 的规则
-p 指定是什么协议 我们常用的tcp 协议,当然也有udp 例如53端口的DNS
到时我们要配置DNS用到53端口 大家就会发现使用udp协议的
而 –dport 就是目标端口 当数据从外部进入服务器为目标端口
反之 数据从服务器出去 则为数据源端口 使用 –sport
-j 就是指定是 ACCEPT 接收 或者 DROP 不接收
3、禁止某个IP访问
1台Linux服务器,2台windows xp 操作系统进行访问
Linux服务器ip 192.168.1.99
xp1 ip: 192.168.1.2
xp2 ip: 192.168.1.8
下面看看我2台xp 都可以访问的
192.168.1.2 这是 xp1 可以访问的,
192.168.1.8 xp2 也是可以正常访问的。
那么现在我要禁止 192.168.1.2 xp1 访问, xp2 正常访问,
下面看看演示
通过命令 iptables -A INPUT -p tcp -s 192.168.1.2 -j DROP
这里意思就是 -A 就是添加新的规则, 怎样的规则呢? 由于我们访问网站使用tcp的,
我们就用 -p tcp , 如果是 udp 就写udp,这里就用tcp了, -s就是 来源的意思,
ip来源于 192.168.1.2 ,-j 怎么做 我们拒绝它 这里应该是 DROP
好,看看效果。好添加成功。下面进行验证 一下是否生效
一直出现等待状态 最后 该页无法显示 ,这是 192.168.1.2 xp1 的访问被拒绝了。
再看看另外一台 xp 是否可以访问, 是可以正常访问的 192.168.1.8 是可以正常访问的
4、如何删除规则
首先我们要知道 这条规则的编号,每条规则都有一个编号
通过 iptables -L -n –line-number 可以显示规则和相对应的编号
num target prot opt source destination
1 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
2 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
3 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
多了 num 这一列, 这样我们就可以 看到刚才的规则对应的是 编号2
那么我们就可以进行删除了
iptables -D INPUT 2
删除INPUT链编号为2的规则。
再 iptables -L -n 查看一下 已经被清除了。
5、过滤无效的数据包
假设有人进入了服务器,或者有病毒木马程序,它可以通过22,80端口像服务器外传送数据。
它的这种方式就和我们正常访问22,80端口区别。它发向外发的数据不是我们通过访问网页请求
而回应的数据包。
下面我们要禁止这些没有通过请求回应的数据包,统统把它们堵住掉。
iptables 提供了一个参数 是检查状态的,下面我们来配置下 22 和 80 端口,防止无效的数据包。
iptables -A OUTPUT -p tcp –sport 22 -m state –state ESTABLISHED -j ACCEPT
可以看到和我们以前使用的:
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT
多了一个状态判断。
同样80端口也一样, 现在删掉原来的2条规则,
iptables -L -n –line-number 这个是查看规则而且带上编号。我们看到编号就可以
删除对应的规则了。
iptables -D OUTPUT 1 这里的1表示第一条规则。
当你删除了前面的规则, 编号也会随之改变。看到了吧。
好,我们删除了前面2个规则,22端口还可以正常使用,说明没问题了
下面进行保存,别忘记了,不然的话重启就会还原到原来的样子。
service iptables save 进行保存。
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
其实就是把刚才设置的规则写入到 /etc/sysconfig/iptables 文件中。
6、DNS端口53设置
下面我们来看看如何设置iptables来打开DNS端口,DNS端口对应的是53
大家看到我现在的情况了吧,只开放22和80端口, 我现在看看能不能解析域名。
host www.google.com 输入这个命令后,一直等待,说明DNS不通
出现下面提示 :
;; connection timed out; no servers could be reached
ping 一下域名也是不通
[root@localhost ~ping www.google.com
ping: unknown host www.google.com
我这里的原因就是 iptables 限制了53端口。
有些服务器,特别是Web服务器减慢,DNS其实也有关系的,无法发送包到DNS服务器导致的。
下面演示下如何使用 iptables 来设置DNS 53这个端口,如果你不知道 域名服务端口号,你
可以用命令 : grep domain /etc/services
[root@localhost ~grep domain /etc/services
domain 53/tcp # name-domain server
domain 53/udp
domaintime 9909/tcp # domaintime
domaintime 9909/udp # domaintime
看到了吧, 我们一般使用 udp 协议。
好了, 开始设置。。。
iptables -A OUTPUT -p udp –dport 53 -j ACCEPT
这是我们 ping 一个域名,数据就是从本机出去,所以我们先设置 OUTPUT,
我们按照ping这个流程来设置。
然后 DNS 服务器收到我们发出去的包,就回应一个回来
iptables -A INPUT -p udp –sport 53 -j ACCEPT
同时还要设置
iptables -A INPUT -p udp –dport 53 -j ACCEPT
iptables -A OUTPUT -p udp –sport 53 -j ACCEPT
好了, 下面开始测试下, 可以用 iptables -L -n 查看设置情况,确定没有问题就可以测试了
[root@localhost ~iptables -L -n
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp spt:53
ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp dpt:53
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:22 state ESTABLISHED
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:80 state ESTABLISHED
ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp spt:53
可以测试一下 是否 DNS 可以通过iptables 了。
[root@localhost ~host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com is an alias for www-china.l.google.com.
www-china.l.google.com has address 64.233.189.104
www-china.l.google.com has address 64.233.189.147
www-china.l.google.com has address 64.233.189.99
正常可以解析 google 域名。
ping 方面可能还要设置些东西。
用 nslookup 看看吧
[root@localhost ~nslookup
> www.google.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
www.google.com canonical name = www.l.google.com.
www.l.google.com canonical name = www-china.l.google.com.
Name: www-china.l.google.com
Address: 64.233.189.147
Name: www-china.l.google.com
Address: 64.233.189.99
Name: www-china.l.google.com
Address: 64.233.189.104
说明本机DNS正常, iptables 允许53这个端口的访问。
7、iptables对ftp的设置
现在我开始对ftp端口的设置,按照我们以前的视频,添加需要开放的端口
ftp连接端口有2个 21 和 20 端口,我现在添加对应的规则。
[root@localhost rootiptables -A INPUT -p tcp –dport 21 -j ACCEPT
[root@localhost rootiptables -A INPUT -p tcp –dport 20 -j ACCEPT
[root@localhost rootiptables -A OUTPUT -p tcp –sport 21 -j ACCEPT
[root@localhost rootiptables -A OUTPUT -p tcp –sport 20 -j ACCEPT
好,这样就添加完了,我们用浏览器访问一下ftp,出现超时。
所以我刚才说 ftp 是比较特殊的端口,它还有一些端口是 数据传输端口,
例如目录列表, 上传 ,下载 文件都要用到这些端口。
而这些端口是 任意 端口。。。 这个 任意 真的比较特殊。
如果不指定什么一个端口范围, iptables 很难对任意端口开放的,
如果iptables允许任意端口访问, 那和不设置防火墙没什么区别,所以不现实的。
那么我们的解决办法就是 指定这个数据传输端口的一个范围。
下面我们修改一下ftp配置文件。
我这里使用vsftpd来修改演示,其他ftp我不知道哪里修改,大家可以找找资料。
[root@localhost rootvi /etc/vsftpd.conf
在配置文件的最下面 加入
pasv_min_port=30001
pasv_max_port=31000
然后保存退出。
这两句话的意思告诉vsftpd, 要传输数据的端口范围就在30001到31000 这个范围内传送。
这样我们使用 iptables 就好办多了,我们就打开 30001到31000 这些端口。
[root@localhost rootiptables -A INPUT -p tcp –dport 30001:31000 -j ACCEPT
[root@localhost rootiptables -A OUTPUT -p tcp –sport 30001:31000 -j ACCEPT
[root@localhost rootservice iptables save
最后进行保存, 然后我们再用浏览器范围下 ftp。可以正常访问
用个账号登陆上去,也没有问题,上传一些文件上去看看。
看到了吧,上传和下载都正常。。 再查看下 iptables 的设置
[root@localhost rootiptables -L -n
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:20
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpts:30001:31000
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:22
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:21
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spt:20
ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp spts:30001:31000
这是我为了演示ftp特殊端口做的简单规则,大家可以添加一些对数据包的验证
例如 -m state –state ESTABLISHED,RELATED 等等要求更加高的验证
修改tomcat下bin目录中的daemon.sh文件,
原本有一行是这样:
JAVA_OPTS=
这行代表tomcat运行时jdk的执行参数为空,我们在后面补充上 “-Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8” , 也就是:
JAVA_OPTS="-Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8"
保存后重新启动tomcat即可解决乱码问题。
真机iphone 6
xcode 6.1
target: ios 8.1
Appdelegate里已经registerApp了,Controller也实现了WXApiDelegate。
解决方法:在info.plist文件的URL types中的URL Schemes 加入微信开放平台申请的AppID
Int转换Float或Double:
let intVar : Int = 3 let doubleVar : Double = Double(intVar)
Int转换为String:
let intVar : Int = 3 let strVar : String = String(intVar)
String转换为Int:
let strVar : String = "123" let intVar : Int? = strVar.toInt()
Double转换为String:
let doubleVar : Double = 3.14 let strVar : String = String(doubleVar)
Double保留两位小数,需要对Double进行扩展:
extension Double { func format(f: String) -> String { return NSString(format: "%\(f)f", self) } } let myDouble = 1.234567 println(myDouble.format(".2")
String转换Double:
let strVar : String = "3.14" var string = NSString(string: strVar) string.doubleValue