no comments yet
14 May 2018

MySQL中删除重复记录,只保留Id最小的一条

表结构为:

+--------+--------------+------+-----+---------+----------------+
| Field  | Type         | Null | Key | Default | Extra          |
+--------+--------------+------+-----+---------+----------------+
| id     | int(255)     | NO   | PRI | NULL    | auto_increment |
| url    | varchar(255) | NO   |     | NULL    |                |
| mdnum  | bigint(255)  | NO   | UNI | NULL    |                |
| status | int(255)     | NO   |     | 0       |                |
+--------+--------------+------+-----+---------+----------------+

目前想到的最简单快捷的方法:

Read more

no comments yet
20 Apr 2018

iptables安全设置

配置文件路径:/etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Fri Apr 20 13:12:14 2018
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [40:6082]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri Apr 20 13:12:14 2018

Read more

no comments yet
19 Apr 2018

ssh连接远程IP的指定端口

ssh 到远程ip的指定端口:

ssh -p xx user@ip

xx 为 端口号,user为用户名,ip为要登陆的ip。

no comments yet
14 Apr 2018

htaccess禁止通过ip直接访问网站

通过IP直接访问的话会301跳转到相应域名,.htaccess内容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{http_host} ^101.100.102.90 [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteBase /
</IfModule>