环境archlinux with kernel 2.6.27-ARCH
本文涉及apache的基本配置和rsync的配置,请先自行了解 apache的其它配置含义。并最终以archlinux的二级rsync服务器为源,搭建一个本地的 rsync服务。当然,如果你手上正好又有多余的IP,请你共享出来,其它人就可以使用你搭建好的服务器了。
路径结构:
/etc/httpd/conf/extra/httpd-vhosts.conf apache 配置文件
/storage/mirrors/archlinux根目录,保存所有mirror文件至此
/etc/rsyncd.conf rsync配置文件
软件安装
apache 适用于web访问mirror文件
rsync 提供rsync服务及和远程rsync服务器同步
安装供web访问的apache服务器或其它web服务器,本文使用apache
sudo pacman -Sy apache
新增默认apache web目录
sudo mkdir -p /srv/http
sudo chown http:http /srv/http
启动apache
sudo apachectl start
如果出现
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
可以启用ServerName配置
httpd.conf 169行
#ServerName www.example.com:80
修改为
ServerName *:80
启动apache
sudo apachectl graceful
wget http://127.0.0.1
links http://127.0.0.1
服务启出现403错误,则apache配置正确
启用Virtual hosts
httpd.conf 453行
#Include conf/extra/httpd-vhosts.conf
修改为
Include conf/extra/httpd-vhosts.conf
添加新主机
sudo vi /etc/httpd/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin williamraym@gmail.com
DocumentRoot /storage/mirrors/archlinux
ServerName 127.0.0.1
ServerAlias arch.mirrors.vifir.com
ErrorLog logs/arch.mirrors.error_log
CustomLog logs/arch.mirrors.access_log common
Alias /arch/mirrors/ /storage/mirrors/archlinux/
<Directory /storage/mirrors/archlinux>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
应用配置文件
sudo apachectl graceful
安装 rsync
sudo pacman -S rsync
准备用户&目录
sudo groupadd http -g 48
sudo useradd -u 48 -g http http
mkdir -p /storage/mirrors/archlinux
chmod +w /storage/mirrors/archlinux
sudo chown http:http /storage/mirrors/archlinux
编辑apache配置文件,增加新的WEB访问地址为http://127.0.0.1/mirrors/archlinux
sudo vi /etc/httpd/conf/httpd.conf
支掉453行前面的#号,以启用conf/extra/httpd-vhosts.conf配置文件
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
新建rsync同步服务器文件的脚本/storage/mirrors/archlinux/sync.sh
#!/bin/sh
mirror=/storage/mirrors/archlinux
mkdir $mirror -p
SYNCLOGFILE="$mirror/sync.log"
SYNCLOCKFILE="$mirror/sync_now.lock"
options="-avz --delete --exclude=x86_64"
do_sync() {
rsync $options rsync://mirrors.easynews.com:/mirrors/linux/archlinux/current /$mirror/
rsync $options rsync://mirrors.easynews.com:/mirrors/linux/archlinux/core /$mirror/
rsync $options rsync://mirrors.easynews.com:/mirrors/linux/archlinux/community /$mirror/
rsync $options rsync://mirrors.easynews.com:/mirrors/linux/archlinux/extra /$mirror/
}
if [[ -f $SYNCLOCKFILE ]]; then
exit 1
fi
echo -n ">>> Sync log for " > $SYNCLOGFILE
date >> $SYNCLOGFILE
cd $mirror
touch $SYNCLOCKFILE
do_sync >> $SYNCLOGFILE
#do_sync
rm -f $SYNCLOCKFILE
chmod +x /storage/mirrors/archlinux/sync.sh
sudo sh /storage/mirrors/archlinux/sync.sh
编辑rsync的配置文件
sudo cp /etc/rsyncd.conf /etc/rsyncd.conf.081115
sudo vi /etc/rsyncd.conf
系统默认的配置文件内容
######################the default config start#########################
uid = nobody
gid = nobody
use chroot = no
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
[ftp]
path = /home/ftp
comment = ftp area
######################end of the default config#########################
修改为自已的配置选项
uid=http
gid=http
max connections=10
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[archlinux]
path=/storage/mirrors/archlinux
comment = archlinux
ignore errors
read only = no
hosts allow=192.168.0.0/24 127.0.0.1/24
启动rsync服务
sudo /usr/bin/rsync --daemon
测试rsync服务器
sudo rsync -avz rsync://127.0.0.1:/archlinux /opt/mirror
receiving incremental file list
./
sent 38 bytes received 89 bytes 254.00 bytes/sec
total size is 0 speedup is 0.00
到此,本地的archlinux mirror基本完成,下面就运行同步服务器脚本,download所有pkg至本地mirror。
如果你是在一个局域网内,那这个方法真是太好了,可以省去其它服务器再到外网去下载的痛苦了。以前我也试过备份恢复/var/cache/pacman/pkg目录的方法,这样还是每次都要经过漫长的压包解包的过程。
来源: 作者: 日期:2008-11-17 10:53 网友评论:0条 点击:912
本文涉及apache的基本配置和rsync的配置,请先自行了解apache的其它配置含义。并最终以archlinux的二级rsync服务器为源,搭建一个本地的 rsync服务。当然,如果你手上正好又有多余的IP,请你共享出来,其它人就可以使用你搭建好的服务器了。
【发表评论 0条】
- 2009中国Linux内核开发者...
- 09自由软件日上最耀眼的...
- 病毒木马也开源
- 电信手机单向收费暗藏玄...
- IBM推出LINUX上网本
- VirtualBox 3.0.6
- 乔布斯复出 致Twitter瘫...
- 诺顿反病毒2010年新增行...
- 5大主流浏览器对比
- 开源组织OIN购买微软专利...
- 阿里巴巴即将推出云计算
- Windows Vista最新0day漏...
- 2009年9月语言排行榜-PH...
- Windows7中必须清除的招...
- Ajax框架 Prototype 1.6...
- 微软VLK计划和Windows7企...
- 微软发布Windows 7嵌入式...
- VirtualBox 3.0.6 Beta ...
- Windows盗版层出不穷 靠...
- 《电脑报》:定制版Linux 作...
