Wednesday, February 29, 2012

Tuesday, February 21, 2012

ftp: connect: No route to host

error:
[root@test2 ~]# ftp 172.22.113.132
ftp: connect: No route to host

check iptables: stop iptables.
[root@localhost home]# /etc/init.d/iptables stop

Or open port 21

[root@test2 ~]# ftp 172.22.113.132
Connected to 172.22.113.132.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (172.22.113.132:root):

centos ftp server

1, Install ftp server
[root@localhost ~]# yum install vsftpd

2, changing default directory on vsftpd server
add this line to the end of conf file: /etc/vsftpd/vsftpd.conf
[root@localhost greg]# vim /etc/vsftpd/vsftpd.conf
......
local_root=/home/greg/

3, start ftp server
[root@localhost ~]# /etc/init.d/vsftpd start

4, add new ftp user
a, All ftp user must already be a system user with a valid password.
So, if you want to create user 'greg'
do:
adduser greg
passwd greg

b, edit conf file: /etc/vsftpd/vsftpd.conf
Uncomment these two lines:
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list

c: add user 'greg' to chroot_list
[root@localhost chang]# vim /etc/vsftpd/chroot_list
greg
"/etc/vsftpd/chroot_list" 1L, 6C

5, restart ftp server
[root@localhost ~]# /etc/init.d/vsftpd restart

6.1 Config firewall
You may need to open port 21 for FTP in your iptables

#ftp
-A RH-Firewall-1-INPUT -p TCP -i eth0 --dport 21 -m state --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p ALL -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
-A OUTPUT -p ALL -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

6.2 Config firewall config
Add ip_conntrack ip_conntrack_ftp in this line
IPTABLES_MODULES="ip_conntrack_netbios_ns  ip_conntrack ip_conntrack_ftp"

6.3 Run following commands
[root@test2 html]# modprobe ip_conntrack_ftp

Tuesday, February 14, 2012

mysqli error: Cannot pass parameter 2 by reference in

mysqli error:

$stmt = $mysqli->prepare("INSERT INTO regex_comment (product_id,user_ip, uname, uemail, comments, sessionid )
VALUES ( ?, ?, ?, ?, ? ,? )" );

$stmt->bind_param('ssssss', '1', $i , $n, $e, $m, $s );

Correct :
$p=1;
$stmt = $mysqli->prepare("INSERT INTO regex_comment (product_id,user_ip, uname, uemail, comments, sessionid )
VALUES ( ?, ?, ?, ?, ? ,? )" );

$stmt->bind_param('ssssss', $p, $i , $n, $e, $m, $s );

You can't specify target table xxxx for update in FROM clause

wrong:

mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY) and id not in ( (select max(a.id) from  sig_dumps a group by a.profile_id) ) ; ERROR 1093 (HY000): You can't specify target table 'sig_dumps' for update in FROM clause correct: mysql>
delete from sig_dumps
where date(created_on) < DATE_SUB(CURdate(), INTERVAL 7 DAY)
and id not in
( select * from
(select max(a.id) from  sig_dumps a group by a.profile_id) t
) ;
Query OK, 0 rows affected (0.02 sec)

mysql insert multiple rows

mysql> insert into sig_dumps (profile_id, created_on) values (9, '2012-02-01 05:05:52') , (9, '2012-02-02 05:05:52'), (9, '2012-02-03 05:05:52');