歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> LinuxEye開源鏡像站運營

LinuxEye開源鏡像站運營

日期:2017/2/27 15:55:34   编辑:Linux教程

技術在於折騰,最近手上有空閒國內服務器資源,於是忍不住折騰,為了方便廣大開源愛好者下載Linux發行版,Linux運維筆記自己搭建了一個鏡像網站。

LinuxEye開源鏡像站網址:http://mirrors.linuxeye.com/

原本准備像mirrors.ustc.edu.cn鏡像整個包,但是服務器磁盤容量有限,於是LinuxEye只收錄最新版本(mini)的策略,鏡像定期更新獲取最新版本的Linux發行版,並自動替換所在目錄,包含對應md5值

ps:如果大家有什麼特別需要的發行版,請回帖,可以考慮加到鏡像站中,謝謝!

LinuxEye開源鏡像站搭建過程
1. 使用《lnmp一鍵安裝包》,安裝lnmp,執行vhost.sh 添加虛擬主機mirrors.linuxeye.com

2. 在nginx中添加fancyindex模塊實現漂亮的索引目錄

cd lnmp/src
wget http://gitorious.org/ngx-fancyindex/ngx-fancyindex/archive-tarball/master
tar xvzf master
# /usr/local/nginx/sbin/nginx -V #查看nginx已經編譯參數
cd nginx-1.6.2
make clean
#增加ngx-fancyindex模塊(--add-module=../ngx-fancyindex-ngx-fancyindex)
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module \
--with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module \
--with-http_flv_module --with-ld-opt=-ljemalloc --add-module=../ngx-fancyindex-ngx-fancyindex
make
mv /usr/local/nginx/sbin/nginx{,_`date +%F`}
cp objs/nginx /usr/local/nginx/sbin

3. 修改虛擬主機配置文件(/usr/local/nginx/conf/vhost/mirrors.linuxeye.com.conf)

server {
listen 80;
server_name mirrors.linuxeye.com;
access_log off;
index index.html index.htm index.php;
root /home/wwwroot/mirrors.linuxeye.com;
location / {
fancyindex on;
fancyindex_exact_size off;
fancyindex_localtime on;
fancyindex_footer "/footer.html";
fancyindex_ignore "footer.html" "exclude_centos.list";
}
}

參數解釋:
fancyindex on:開啟fancy索引
fancyindex_exact_size off:不使用精確的大小,使用四捨五入,1.9M會顯示為2M這樣.如果開啟的話,單位為字節
fancyindex_localtime on:使用本地時間
fancyindex_footer /footer.html:把網站根目錄下footer.html內容作為底部.文件不存在底部會出現404
footer.html內容如下:

<!-- footer START -->
<div id="footer">
<div id="copyright">
版權所有 &copy; 2015 LinuxEye  </div>
</div>
<!-- footer END -->

fancyindex_ignore:哪些文件/目錄隱藏掉

fancy指令使用:
fancyindex
語法: *fancyindex* [*on* | *off*]
默認值: fancyindex off
配置塊: http, server, location
描述: 開啟/關閉目錄索引功能

fancyindex_css_href
語法: *fancyindex_css_href uri*
默認值: fancyindex_css_href “”
配置塊: http, server, location
描述: 外置css路徑,可以用這個css替代掉現有的css樣式

fancyindex_exact_size
語法: *fancyindex_exact_size* [*on* | *off*]
默認值: fancyindex_exact_size on
配置塊: http, server, location
描述: 定義如何顯示文件的大小,默認是on,on:文件大小使用精確值,單位為字節.off:單位為KB,MB,GB,如果含有小數點,將會四捨五入。例如1.9MB,將會顯示為2MB。

fancyindex_footer
語法: *fancyindex_footer path*
默認值: fancyindex_footer “”
配置塊: http, server, location
描述: 指定哪個文件嵌入到索引頁面的底部

fancyindex_header
語法: *fancyindex_header path*
默認值: fancyindex_header “”
配置塊: http, server, location
描述: 指定哪個文件嵌入到索引頁面的頭部.用法和fancyindex_footer類似

fancyindex_ignore
語法: *fancyindex_ignore string1 [string2 [… stringN]]*
默認值: No default.
配置塊: http, server, location
描述: 哪些文件/目錄隱藏掉,支持nginx正則

fancyindex_localtime
語法: *fancyindex_localtime* [*on* | *off*]
默認值: fancyindex_localtime off
配置塊: http, server, location
Description: 使用當地時間顯示文件的創建時間,默認是off(GMT時間)

4. 同步ustc centos鏡像

mkdir -p /home/wwwroot/mirrors.linuxeye.com/centos
tmux #後台同步
rsync -avrt rsync://mirrors.ustc.edu.cn/centos/ \
--exclude-from=/home/wwwroot/mirrors.linuxeye.com/exclude_centos.list \
/home/wwwroot/mirrors.linuxeye.com/centos/
原文:http://blog.linuxeye.com/409.html
Copyright © Linux教程網 All Rights Reserved