proftpd的安装脚本
[ 2010/09/02 10:16 | by admin ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
程序可以从官方下载
下载地址:
http://www.proftpd.org/
默认约定:
程序安装位置为 :/web/proftpd
创建用户为 :www
www家目录为 :/home/wwwroot/htdocs
www密码在安装过程中手工输入
脚本代码如下:
#!/bin/bash
clear
echo "----------------proftpd安装程序,按任意键继续---------------"
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
char=`get_char`
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.3a.tar.gz
tar zxvf proftpd-1.3.3a.tar.gz
cd proftpd-1.3.3a
./configure --prefix=/web/proftpd
make
make install
mkdir -p /home/wwwroot/htdocs
groupadd www
useradd www -g www -d /home/wwwroot/htdocs -s /sbin/nologin
echo "Please input new password for user: www"
passwd www
chown -R www.www /home/wwwroot/htdocs
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
sed -i 's\PATH="$PATH:/usr/local/sbin"\PATH="$PATH:/web/proftpd/sbin"\g' /etc/rc.d/init.d/proftpd
chmod +x /etc/rc.d/init.d/proftpd
chkconfig --add proftpd
chkconfig proftpd on
cd ../
mv /web/proftpd/etc/proftpd.conf /web/proftpd/etc/proftpd.conf.bak
cp proftpd.conf /web/proftpd/etc/
service proftpd start
echo "删除安装临时文件.............."
rm -Rf proftpd-1.3.3a
echo
echo
echo " ------------------- 如需增加新用户,请使用以下命令 -------------------"
echo "| useradd 用户名 -g 用户组 -d 用户家目录 -s /sbin/nologin |"
echo " -------------------------- proftpd 安装结束! -------------------------"
echo
echo
echo
echo
安装过程中的proftpd.conf为直接拷贝,请先行在安装目录创建profptd.conf,代码如下:
本文来自http://blog.gsywx.com
程序可以从官方下载
下载地址:
http://www.proftpd.org/
默认约定:
程序安装位置为 :/web/proftpd
创建用户为 :www
www家目录为 :/home/wwwroot/htdocs
www密码在安装过程中手工输入
脚本代码如下:
#!/bin/bash
clear
echo "----------------proftpd安装程序,按任意键继续---------------"
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
char=`get_char`
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.3a.tar.gz
tar zxvf proftpd-1.3.3a.tar.gz
cd proftpd-1.3.3a
./configure --prefix=/web/proftpd
make
make install
mkdir -p /home/wwwroot/htdocs
groupadd www
useradd www -g www -d /home/wwwroot/htdocs -s /sbin/nologin
echo "Please input new password for user: www"
passwd www
chown -R www.www /home/wwwroot/htdocs
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
sed -i 's\PATH="$PATH:/usr/local/sbin"\PATH="$PATH:/web/proftpd/sbin"\g' /etc/rc.d/init.d/proftpd
chmod +x /etc/rc.d/init.d/proftpd
chkconfig --add proftpd
chkconfig proftpd on
cd ../
mv /web/proftpd/etc/proftpd.conf /web/proftpd/etc/proftpd.conf.bak
cp proftpd.conf /web/proftpd/etc/
service proftpd start
echo "删除安装临时文件.............."
rm -Rf proftpd-1.3.3a
echo
echo
echo " ------------------- 如需增加新用户,请使用以下命令 -------------------"
echo "| useradd 用户名 -g 用户组 -d 用户家目录 -s /sbin/nologin |"
echo " -------------------------- proftpd 安装结束! -------------------------"
echo
echo
echo
echo
安装过程中的proftpd.conf为直接拷贝,请先行在安装目录创建profptd.conf,代码如下:
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "Welcome to my Proftpd"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#欢迎登录 ProFTPD
DefaultRoot ~
# Normally, we want files to be overwriteable.
#允许被写入覆盖
AllowOverwrite on
#下载允许断点续传
AllowRetrieveRestart on
#上传允许断点续传
AllowStoreRestart on
UseReverseDNS off
IdentLookups off
#设置ftp登陆欢迎信息文件
#DisplayLogin welcome.msg
#屏蔽服务器版本信息
#ServerIdent off
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
#以上为全局配置
#以下为具体目录权限配置
<Directory /home/wwwroot/htdocs/>
<Limit SITE_CHMOD>
AllowAll
</Limit>
AllowRetrieveRestart on
AllowOverwrite on
AllowStoreRestart on
</Directory>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<Anonymous ~ftp>
# User ftp
# Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
# MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
# DisplayLogin welcome.msg
# DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
# DenyAll
# </Limit>
#</Anonymous>
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "Welcome to my Proftpd"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
#欢迎登录 ProFTPD
DefaultRoot ~
# Normally, we want files to be overwriteable.
#允许被写入覆盖
AllowOverwrite on
#下载允许断点续传
AllowRetrieveRestart on
#上传允许断点续传
AllowStoreRestart on
UseReverseDNS off
IdentLookups off
#设置ftp登陆欢迎信息文件
#DisplayLogin welcome.msg
#屏蔽服务器版本信息
#ServerIdent off
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
#以上为全局配置
#以下为具体目录权限配置
<Directory /home/wwwroot/htdocs/>
<Limit SITE_CHMOD>
AllowAll
</Limit>
AllowRetrieveRestart on
AllowOverwrite on
AllowStoreRestart on
</Directory>
# A basic anonymous configuration, no upload directories. If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<Anonymous ~ftp>
# User ftp
# Group ftp
# We want clients to be able to login with "anonymous" as well as "ftp"
# UserAlias anonymous ftp
# Limit the maximum number of anonymous logins
# MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
# DisplayLogin welcome.msg
# DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
# <Limit WRITE>
# DenyAll
# </Limit>
#</Anonymous>
linux忘记mysql的root密码密码重设脚本
[ 2010/09/01 16:17 | by admin ]
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
把以下内容保存为:reset_mysql_passwd.sh
并加上可执行权限:chmod +x reset_mysql_passwd.sh
执行即可:./reset_mysql_passwd.sh
默认约定:此时mysqld已经安装为服务,如果未装为服务,需修改脚本内容后运行。
#!/bin/bash
clear
echo "默认约定:mysqld已安装为服务,如不是请修改程序后再执行"
echo
echo "请输入mysql安装路径(如:/web/mysql):"
read -p "mysql路径: " mysqldir
echo
echo "请输入要重设的mysql的root帐户的密码:"
read -p "root新密码: " newpwd
echo
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$newpwd');" > /temp.txt
service mysqld stop
$mysqldir/bin/mysqld_safe --init-file=/temp.txt &
$mysqldir/bin/mysqladmin shutdown -uroot -p$newpwd 2>/dev/null;
sleep 5
service mysqld start
rm -Rf /temp.txt
echo
echo "密码已被重设为:"$newpwd ",程序自动退出!"
本文来自http://blog.gsywx.com
把以下内容保存为:reset_mysql_passwd.sh
并加上可执行权限:chmod +x reset_mysql_passwd.sh
执行即可:./reset_mysql_passwd.sh
默认约定:此时mysqld已经安装为服务,如果未装为服务,需修改脚本内容后运行。
#!/bin/bash
clear
echo "默认约定:mysqld已安装为服务,如不是请修改程序后再执行"
echo
echo "请输入mysql安装路径(如:/web/mysql):"
read -p "mysql路径: " mysqldir
echo
echo "请输入要重设的mysql的root帐户的密码:"
read -p "root新密码: " newpwd
echo
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$newpwd');" > /temp.txt
service mysqld stop
$mysqldir/bin/mysqld_safe --init-file=/temp.txt &
$mysqldir/bin/mysqladmin shutdown -uroot -p$newpwd 2>/dev/null;
sleep 5
service mysqld start
rm -Rf /temp.txt
echo
echo "密码已被重设为:"$newpwd ",程序自动退出!"
mysql-5.1.50-linux-i686-glibc23.tar.gz包的安装方法
[ 2010/08/30 21:08 | by admin ]
mysql-5.1.50-linux-i686-glibc23.tar.gz包的安装
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
习惯于编译安装tar.gz,顺便也学下官方下载的glibc包的安装方法
一、下载源程序
地址:http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/
比如我这里下载的是:mysql-5.1.50-linux-i686-glibc23.tar.gz
mkdir /file/
cd /file/
wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.50-linux-i686-glibc23.tar.gz
二、安装
tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz
cp -rf mysql-5.1.50-linux-i686-glibc23 /usr/local/
cd /usr/local/
mv mysql-5.1.50-linux-i686-glibc23/ mysql
安装为默认的路径,这样就不用为程序目录做软链接了
groupadd mysql
useradd -g mysql mysql
cd mysql/
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's/log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
sed -i 's/binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
sed -i 's/skip-locking/skip-locking\nmax_connections = 1000\nwait_timeout = 5/g' /etc/my.cnf
接下来初始化数据库
scripts/mysql_install_db --user=mysql
安装mysql服务控制
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
bin/mysqladmin -u root password 123654
就这么简单,比编译安装省时不少
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
习惯于编译安装tar.gz,顺便也学下官方下载的glibc包的安装方法
一、下载源程序
地址:http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/
比如我这里下载的是:mysql-5.1.50-linux-i686-glibc23.tar.gz
mkdir /file/
cd /file/
wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.50-linux-i686-glibc23.tar.gz
二、安装
tar zxvf mysql-5.1.50-linux-i686-glibc23.tar.gz
cp -rf mysql-5.1.50-linux-i686-glibc23 /usr/local/
cd /usr/local/
mv mysql-5.1.50-linux-i686-glibc23/ mysql
安装为默认的路径,这样就不用为程序目录做软链接了
groupadd mysql
useradd -g mysql mysql
cd mysql/
cp support-files/my-medium.cnf /etc/my.cnf
sed -i 's/log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
sed -i 's/binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
sed -i 's/skip-locking/skip-locking\nmax_connections = 1000\nwait_timeout = 5/g' /etc/my.cnf
接下来初始化数据库
scripts/mysql_install_db --user=mysql
安装mysql服务控制
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
bin/mysqladmin -u root password 123654
就这么简单,比编译安装省时不少
使用rsync做网站程序的异地同步备份
[ 2010/08/24 10:02 | by admin ]
一、安装rsync,任选一种方式:
A. yum install rsync
B. rpm -ivh rsync-3.0.5-1.el5.rf.i386.rpm
rpm下载地址为: ftp://ftp.pbone.net/mirror/ftp.freshrpms.net/pub/freshrpms/pub/dag/redhat/el5/en/i386/RPMS.dag/rsync-3.0.5-1.el5.rf.i386.rpm
C. 使用源码编译安装
官方下载地址为:
http://rsync.samba.org/ftp/rsync/src/
wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.7.tar.gz
tar zxvf rsync-3.0.7.tar.gz
./configure
make
make install
二、创建rsync配置文件
vi /etc/rsyncd.conf
uid=root
gid=root
use chroot = no
max connections = 20
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
#secrets file = /etc/rsync.pass
#hosts allow = 192.168.0.1,192.168.1.2
#hosts deny = 0.0.0.0/32
[www]
path = /home/wwwroot/htdocs/dz6/
ignore errors
read only = yes
hosts allow = 192.168.0.0/24
hosts deny = 0.0.0.0./32
auth users = www
secrets file = /etc/rsync.pass
因为异地备份,在www段限制可访问的IP,并且使用用户密码来验证
三、创建认证文件,文件格式为:
用户名:密码
vi /etc/rsync.pass
www:123456
chmod 600 /etc/rsync.pass
启动rsync
rsync --daemon
四、rsync客户端设置
客户端机器为192.168.0.3
创建客户端认证密码文件,只有密码部份
vi /rsy.pass
123456
chmod 600 /rsy.pass
mkdir /webback
创建计划任务,每天2点进行同步
rsync -vzrtopg --delete www@192.168.0.2::www /webback/ --password-file=/rsy.pass
echo "00 02 * * * /web/webback.sh" >>/var/spool/cron/root
如果不间断地进行备份可以创建如下脚本(每60秒进行同步一次):
vi /backup.sh
#!/bin/sh
while true
do
rsync -vzrtopg --delete www@192.168.0.2::www /webback/ --password-file=/rsy.pass
sleep 60
done
然后把/backup.sh & 加入到/etc/rc.d/rc.local自启动
五、备份到windows
下载cwrsync
http://www.itefix.no/i2/download
http://sourceforge.net/projects/sereds/files/cwRsync
安装cwRsync_4.0.4_Installer.zip到E:\Program Files\cwRsync\bin
添加环境变量E:\Program Files\cwRsync\bin到path
md D:\webback
创建密码认证文件rsy.txt
内容为: 123456
运行CMD
chmod -c 600 d:\rsy.txt
然后删除d:\rsy.txt所有用户访问权限
在D盘根目录建立如下备份批处理:
backup.bat
@echo off
:start
d:
cd \
echo 同步中......
rsync -rvz --delete www@192.168.0.2::www .\webback --password-file=rsy.pass
ping 127.0 -n 60 >nul 2>nul
goto start
每60秒同步一次.
如果密码文件搞不定,而出现
password file must be owned by root when running as root
continuing without password file
Password:
这时候我们可以创建一个p.txt,内容为:123456
并更改backup.bat为:
@echo off
:start
d:
cd \
echo 同步中......
rsync -vrz --delete www@192.168.0.2::www .\webback --password-file=rsy.pass < p.txt
ping 127.0 -n 60 >nul 2>nul
goto start
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com
A. yum install rsync
B. rpm -ivh rsync-3.0.5-1.el5.rf.i386.rpm
rpm下载地址为: ftp://ftp.pbone.net/mirror/ftp.freshrpms.net/pub/freshrpms/pub/dag/redhat/el5/en/i386/RPMS.dag/rsync-3.0.5-1.el5.rf.i386.rpm
C. 使用源码编译安装
官方下载地址为:
http://rsync.samba.org/ftp/rsync/src/
wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.7.tar.gz
tar zxvf rsync-3.0.7.tar.gz
./configure
make
make install
二、创建rsync配置文件
vi /etc/rsyncd.conf
uid=root
gid=root
use chroot = no
max connections = 20
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
#secrets file = /etc/rsync.pass
#hosts allow = 192.168.0.1,192.168.1.2
#hosts deny = 0.0.0.0/32
[www]
path = /home/wwwroot/htdocs/dz6/
ignore errors
read only = yes
hosts allow = 192.168.0.0/24
hosts deny = 0.0.0.0./32
auth users = www
secrets file = /etc/rsync.pass
因为异地备份,在www段限制可访问的IP,并且使用用户密码来验证
三、创建认证文件,文件格式为:
用户名:密码
vi /etc/rsync.pass
www:123456
chmod 600 /etc/rsync.pass
启动rsync
rsync --daemon
四、rsync客户端设置
客户端机器为192.168.0.3
创建客户端认证密码文件,只有密码部份
vi /rsy.pass
123456
chmod 600 /rsy.pass
mkdir /webback
创建计划任务,每天2点进行同步
rsync -vzrtopg --delete www@192.168.0.2::www /webback/ --password-file=/rsy.pass
echo "00 02 * * * /web/webback.sh" >>/var/spool/cron/root
如果不间断地进行备份可以创建如下脚本(每60秒进行同步一次):
vi /backup.sh
#!/bin/sh
while true
do
rsync -vzrtopg --delete www@192.168.0.2::www /webback/ --password-file=/rsy.pass
sleep 60
done
然后把/backup.sh & 加入到/etc/rc.d/rc.local自启动
五、备份到windows
下载cwrsync
http://www.itefix.no/i2/download
http://sourceforge.net/projects/sereds/files/cwRsync
安装cwRsync_4.0.4_Installer.zip到E:\Program Files\cwRsync\bin
添加环境变量E:\Program Files\cwRsync\bin到path
md D:\webback
创建密码认证文件rsy.txt
内容为: 123456
运行CMD
chmod -c 600 d:\rsy.txt
然后删除d:\rsy.txt所有用户访问权限
在D盘根目录建立如下备份批处理:
backup.bat
@echo off
:start
d:
cd \
echo 同步中......
rsync -rvz --delete www@192.168.0.2::www .\webback --password-file=rsy.pass
ping 127.0 -n 60 >nul 2>nul
goto start
每60秒同步一次.
如果密码文件搞不定,而出现
password file must be owned by root when running as root
continuing without password file
Password:
这时候我们可以创建一个p.txt,内容为:123456
并更改backup.bat为:
@echo off
:start
d:
cd \
echo 同步中......
rsync -vrz --delete www@192.168.0.2::www .\webback --password-file=rsy.pass < p.txt
ping 127.0 -n 60 >nul 2>nul
goto start
本内容为原创内容,转载请注明:
本文来自http://blog.gsywx.com