“安装” 标签页面:

  • 安装aria2及使用yaaw配置WebGUI界面

    现在一般的linux发行版的gcc都不太新,而aria2 1.18之后需要gcc 4.8,所以只能装之前的版本咯。反正下载功能没有区别,都支持http、ftp、bt、magnet磁力链接等协议。

    wget http://jaist.dl.sourceforge.net/project/aria2/stable/aria2-1.17.1/aria2-1.17.1.tar.gz
    tar zxf aria2-1.17.1.tar.gz
    cd aria2-1.17.1
    ./configure --prefix=/usr/local/blog.creke.net/aria2 --enable-static=true --enable-shared=true --enable-libaria2 --with-tcmalloc --with-sqlite3=/usr/local
    #注:configure输出最主要看Xml-RPC是yes就行
    make
    make install

    然后摸一下session文件:

    touch /home/blog.creke.net/work/aria2/aria2.session

    配置(/home/blog.creke.net/work/aria2/aria2.conf):

    #Basic
    dir=/home/blog.creke.net/work/aria2/download
    continue=true

    #HTTP
    user-agent=Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0

    #BT
    enable-dht=true
    seed-time=0
    dht-listen-port=6882
    dht-entry-point=loki.uplinklabs.net:33445

    #network
    max-overall-download-limit=5M
    max-overall-upload-limit=1M
    max-upload-limit=512K

    #RPC
    enable-rpc=true
    #rpc-listen-all=true
    rpc-allow-origin-all=true
    rpc-listen-port=35002
    #rpc-user=none
    #rpc-passwd=none

    #Advanced

    配置nginx代理aria2的jsonrpc:

    location /aria2/jsonrpc {
    proxy_pass http://localhost:35002/jsonrpc;
    proxy_redirect off;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    安装web gui:

    wget https://github.com/binux/yaaw/archive/master.zip
    mv master yaaw.zip
    unzip yaaw.zip
    mv yaaw-master/ yaaw/

    值得一提的是,yaaw不支持用户名密码,所以用nginx进行反向代理。修改
    打开yaaw的js目录中aria2.js和yaaw.js,搜寻端口号,改成自己定义的端口号和路径。

    附:init.d适用的自动启动脚本如下:

    #! /bin/sh
    # chkconfig: 2345 55 25
    # Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
    # run 'update-rc.d -f nginx defaults', or use the appropriate command on your
    # distro. For CentOS/Redhat run: 'chkconfig --add aria2'

    ### BEGIN INIT INFO
    # Provides:          aria2c
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts aria2c
    # Description:       starts aria2c as a service
    ### END INIT INFO

    # Author:   Creke
    # website:  http://blog.creke.net/

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DESC="aria2c daemon"
    NAME=aria2c
    DAEMON=/usr/local/blog.creke.net/aria2/bin/$NAME
    CONFPATH=/home/blog.creke.net/work/aria2/aria2.conf
    SESSION=/home/blog.creke.net/work/aria2/aria2.session
    #PIDFILE=/usr/local/haproxy/etc/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    USER="blog.creke.net"

    set -e
    [ -x "$DAEMON" ] || exit 0

    do_start() {
    su - $USER -c "$DAEMON --conf-path=$CONFPATH -D --input-file=$SESSION --save-session=$SESSION" || echo -n "aria2c already running"
    }

    do_stop() {
    killall -INT $NAME || echo -n "aria2c not running"
    }

    do_reload() {
    kill -HUP $NAME || echo -n "aria2c can't reload"
    }

    case "$1" in
    start)
    echo -n "Starting $DESC: $NAME"
    do_start
    echo "."
    ;;
    stop)
    echo -n "Stopping $DESC: $NAME"
    do_stop
    echo "."
    ;;
    reload|graceful)
    echo -n "Reloading $DESC configuration..."
    do_reload
    echo "."
    ;;
    restart)
    echo -n "Restarting $DESC: $NAME"
    do_stop
    do_start
    echo "."
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
    exit 3
    ;;
    esac

    exit 0

     

    2016.08.30 / 暂无评论 / 1,415 次点击 / 分类: 所谓技术

  • Zabbix安装简记

    安装zabbix:

    wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz
    tar zxf zabbix-2.2.6.tar.gz
    cd zabbix-2.2.6
    ./configure --prefix=/usr/local/zabbix --enable-server --with-mysql=/usr/local/mysql/bin/mysql_config --with-libcurl --enable-proxy --enable-agent
    make
    make install

    配置zabbix:

    编辑/usr/local/zabbix/conf/zabbix_server.conf。按照自己的需求对照编辑即可。

    配置开机自动启动服务:

    cd zabbix-2.2.6/misc/init.d/fedora
    cp core5/zabbix_server /etc/init.d/

    编辑/etc/init.d/zabbix_server其中的ZABBIX_BIN的值为"/usr/local/zabbix/sbin/zabbix_server"

    增加用户组及用户:

    groupadd -g 601 zabbix
    useradd -u 601 -s /sbin/nologin -d /dev/null -M -g zabbix zabbix

    导入初始数据库:

    cd zabbix-2.2.6/database/mysql
    mysql -ucreke -p
    > use creke_zabbix;
    > source schema.sql;
    > source images.sql;
    > source data.sql;
    > quit;

    复制php前端:

    cp -r zabbix-2.2.6/frontends/php /home/wwwroot/default/zabbix
    cd /home/wwwroot/default/zabbix
    cp conf/zabbix.conf.php.example conf/zabbix.conf.php
    编辑conf/zabbix.conf.php的数据库配置

    默认帐号:admin,密码:zabbix

    Zabbix简要安装说明,也只是装着玩玩,并没有深究。一般情况下,个人的服务器监控需求,还是使用监控宝、360网站监控之类的服务,会比自己搭建维护成本低。

     

    2016.08.29 / 暂无评论 / 1,059 次点击 / 分类: 所谓技术

  • CentOS VPS安装PPTP VPN(适用于XEN和OpenVZ)

    开始安装PPTP前,有一些基本前提需要知道,比如VPS是否支持PPP啦,是否支持MPPE啦等等。怎么知道呢?最简单的办法,就是直接咨询VPS提供商。

    安装ppp

    yum install ppp

    安装PPTPd,这个有两种办法安装,一种在RPM二进制包的安装,一种是从源码编译安装。一般而言我都会推荐自己编译源码,但是PPTPd的源码编译略坑,所以还是推荐安装RPM包。

    rpm版安装:

    前往http://poptop.sourceforge.net/yum/stable/packages/或 https://code.google.com/p/acelnmp/downloads/list,下载rpm后,执行

    rpm -ivh pptpd-1.3.4-2.rhel5.i386.rpm

    编译安装pptpd,不建议

    wget http://nchc.dl.sourceforge.net/project/poptop/pptpd/pptpd-1.3.4/pptpd-1.3.4.tar.gz

    tar zxf pptpd-1.3.4.tar.gz

    cd  pptpd-1.3.4

    rpm -ivh pptpd-1.3.4-2.rhel5.i386.rpm

    查看/usr/lib/pptpd是否存在,如果不存在,则执行:

    mkdir /usr/lib/pptpd

    ln -s /usr/local/lib/pptpd/pptpd-logwtmp.so /usr/lib/pptpd/pptpd-logwtmp.so

    配置文件/etc/pptpd.conf:

    option /etc/ppp/options.pptpd
    logwtmp
    localip 192.168.2.1
    remoteip 192.168.2.2-250

    配置文件/etc/ppp/options.pptpd:

    name pptpd

    refuse-pap
    refuse-chap
    refuse-mschap
    # Require the peer to authenticate itself using MS-CHAPv2 [Microsoft
    # Challenge Handshake Authentication Protocol, Version 2] authentication.
    require-mschap-v2
    # Require MPPE 128-bit encryption
    # (note that MPPE requires the use of MSCHAP-V2 during authentication)
    require-mppe-128
    # }}}

    ms-dns 8.8.8.8
    ms-dns 8.8.4.4

    proxyarp

    lock

    nologfd

    设置自动启动脚本/etc/init.d/pptpd:

    #!/bin/sh
    #
    # Startup script for pptpd
    #
    # chkconfig: - 85 15
    # description: PPTP server
    # processname: pptpd
    # config: /etc/pptpd.conf

    # Source function library.
    . /etc/rc.d/init.d/functions
    # See how we were called.
    case "$1" in
    start)
    echo 1 > /proc/sys/net/ipv4/ip_forward
    echo 0 > /proc/sys/net/ipv4/tcp_syncookies

    iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE
    iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT

    echo -n "Starting pptpd: "
    if [ -f /var/lock/subsys/pptpd ] ; then
    echo
    exit 1
    fi
    daemon /usr/sbin/pptpd
    echo
    touch /var/lock/subsys/pptpd
    ;;
    stop)
    iptables -t nat -D POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE
    iptables -D INPUT -p udp -m udp --dport 53 -j ACCEPT

    echo -n "Shutting down pptpd: "
    killproc pptpd
    echo
    rm -f /var/lock/subsys/pptpd
    ;;
    status)
    status pptpd
    ;;
    condrestart)
    if [ -f /var/lock/subsys/pptpd ]; then
    $0 stop
    $0 start
    fi
    ;;
    reload|restart)
    $0 stop
    $0 start
    echo "Warning: a pptpd restart does not terminate existing "
    echo "connections, so new connections may be assigned the same IP "
    echo "address and cause unexpected results.  Use restart-kill to "
    echo "destroy existing connections during a restart."
    ;;
    restart-kill)
    $0 stop
    ps -ef | grep pptpd | grep -v grep | grep -v rc.d | awk '{print $2}' | uniq | xargs kill 1> /dev/null 2>&1
    $0 start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart|restart-kill|status}"
    exit 1
    esac

    exit 0

    最后让脚步开机启动:

    chmod +x /etc/init.d/pptpd

    chkconfig --level 345 pptpd on

    service pptpd start

    如果你的VPS是OpenVZ,应该把上面的“iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE”改为:

    iptables -t nat -A POSTROUTING -s  192.168.2.0/24 -j SNAT --to-source 你的VPS的IP

    同时把上面的“iptables -t nat -D POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE”改为:

    iptables -t nat -D POSTROUTING -s  192.168.2.0/24 -j SNAT --to-source 你的VPS的IP

    设置pptp的密码:

    vi /etc/ppp/chap-secrets
    格式为“用户名 pptpd 密码 *”

    常见问题:

    1:如果连接的时候,出现619错误,则运行:

    rm -r /dev/ppp
    mknod /dev/ppp c 108 0

    然后重新启动你的VPS。

    2:如果连接的时候,出现800错误,这是因为虚拟机内核不支持MPPE,这时候PPTP也没意义了,因为已经是明文的了。

    3:如果还有其他错误或上述错误一直存在,请使用

    tail /var/log/messages

    查看系统日志解决

    2013.09.09 / 1 条评论 / 1,715 次点击 / 分类: 所谓技术

  • CentOS编译安装ffmpeg以及相关编码解码器

    CentOS编译安装ffmpeg是一件很痛苦的过程,因为各种编码器、解码器什么的很繁杂,而且相互依赖关系更复杂。

    编译了一天终于把它搞定并基本测试无问题,以下是步骤。

    安装yasm

    wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
    tar zxf yasm-1.2.0.tar.gz
    cd yasm-1.2.0
    ./configure
    make
    make install

    安装frei0r(先安装新版autoconf,这会覆盖掉系统中的旧版本哦)

    wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
    tar zxf autoconf-2.69.tar.gz
    cd autoconf-2.69
    ./configure --prefix=/usr
    make
    make install

    wget http://files.dyne.org/frei0r/releases/frei0r-plugins-1.4.tar.gz
    tar zxf frei0r-plugins-1.4.tar.gz
    cd frei0r-plugins-1.4
    ./configure
    make
    make install

    安装gnutls

    参考:http://blog.creke.net/800.html

    安装mp3lame

    wget http://iweb.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
    tar zxf lame-3.99.5.tar.gz
    cd lame-3.99.5
    make
    make install

    安装opencore-amr

    wget http://iweb.dl.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz
    tar zxf opencore-amr-0.1.3.tar.gz
    ./configure --enable-shared
    make
    make install

    安装opus

    wget http://downloads.xiph.org/releases/opus/opus-1.0.2.tar.gz
    tar zxf opus-1.0.2.tar.gz
    cd opus-1.0.2
    make
    make install

    安装rtmpdump

    wget http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz
    tar zxf rtmpdump-2.3.tgz
    cd rtmpdump-2.3
    make
    make install

    安装schroedinger(先安装好orc库)

    wget http://code.entropywave.com/download/orc/orc-0.4.17.tar.gz
    tar zxf orc-0.4.17.tar.gz
    cd orc-0.4.17
    ./configure
    make
    make install
    /sbin/ldconfig

    wget http://diracvideo.org/download/schroedinger/schroedinger-1.0.11.tar.gz
    tar zxf schroedinger-1.0.11.tar.gz
    cd schroedinger-1.0.11
    PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig ./configure
    make
    make install

    安装soxr(注:新版libsoxr貌似与当前ffmpeg不兼容,用旧版)

    yum install -y xz
    wget http://hivelocity.dl.sourceforge.net/project/soxr/soxr-0.1.0-Source.tar.xz
    xz -d soxr-0.1.0-Source.tar.xz
    tar xf soxr-0.1.0-Source.tar
    cd soxr-0.1.0-Source
    ./go
    cd Release/
    make
    make install
    /sbin/ldconfig

    安装speex(先安装libogg库)

    wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
    tar zxf libogg-1.3.0.tar.gz
    ./configure
    make
    make install
    /sbin/ldconfig

    wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
    tar zxf speex-1.2rc1.tar.gz
    cd speex-1.2rc1
    ./configure
    make
    make install

    安装theora(先安装好libvorbis库和libsdl库)

    wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
    tar zxf libvorbis-1.3.3.tar.gz
    ./configure
    make
    make install

    wget http://www.libsdl.org/release/SDL-1.2.15.tar.gz
    tar zxf SDL-1.2.15.tar.gz
    cd SDL-1.2.15
    ./configure
    make
    make install
    /sbin/ldconfig

    wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
    tar zjf libtheora-1.1.1.tar.bz2
    ./configure
    make
    make install

    安装twolame

    wget http://downloads.sourceforge.net/twolame/twolame-0.3.13.tar.gz
    tar zxf twolame-0.3.13
    .tar.gz
    cd twolame-0.3.13
    ./configure
    make
    make install
    /sbin/ldconfig

    安装VisualOn AAC(注:github的tag和master版均无法autoconf,用zeranoe版代替)

    wget wget http://ffmpeg.zeranoe.com/builds/source/external_libraries/vo-aacenc-0.1.2.tar.xz
    xz -d vo-aacenc-0.1.2.tar.xz
    tar xf vo-aacenc-0.1.2.tar
    cd vo-aacenc-0.1.2
    ./configure
    make
    make install

    安装VisualOn AMR-WB(注:github的tag和master版均无法autoconf,用zeranoe版代替)

    wget http://ffmpeg.zeranoe.com/builds/source/external_libraries/vo-amrwbenc-0.1.2.tar.xz
    xz -d vo-amrwbenc-0.1.2.tar.xz
    tar xf vo-amrwbenc-0.1.2.tar
    cd vo-amrwbenc-0.1.2
    ./configure

    安装libvpx(注:新版libvpx貌似与当前ffmpeg不兼容,用旧版)

    wget http://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2
    tar jxf libvpx-v1.1.0.tar.bz2
    cd libvpx-v1.1.0
    ./configure
    make
    make install

    安装x264

    wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
    tar jxf last_x264.tar.bz2
    cd x264-snapshot-20130311-2245/
    ./configure --enable-shared
    make
    make install

    安装xvid

    wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
    tar zxf xvidcore-1.3.2.tar.gz
    cd xvidcore
    cd build/generic
    ./configure
    make
    make install

    最重要的一步——编译安装ffmpeg!

    wget http://ffmpeg.org/releases/ffmpeg-1.1.3.tar.gz
    tar zxf ffmpeg-1.1.3.tar.gz
    cd ffmpeg-1.1.3
    PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig ./configure --disable-static --enable-shared --enable-gpl --enable-version3 --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-zlib
    make
    make install

    注1:

    我在编译安装时参考Windows Build:http://ffmpeg.zeranoe.com/builds/。

    注2:

    与Windows Build相比,以下没有选项开启:

    --enable-libgsm --enable-libilbc -enable-libass --enable-libbluray --enable-libcaca --enable-libopenjpeg --disable-w32threads --enable-avisynth --enable-libxavs

    2013.03.12 / 1 条评论 / 4,540 次点击 / 分类: 所谓技术

  • CentOS编译安装新版gnutls

    在Linux中,gnutls应用很常见,最近编译ffmpeg时也用到,不过应该是自带的gnutls太旧了,所以编译错误,要新编译一个。下面是编译安装过程。

    注意:/etc/ld.so.conf要加上lib64。并且不要使用yum remove gnutls gnutls-devel,不信?你会后悔的!

    首先安装nettle:

    wget http://www.lysator.liu.se/~nisse/archive/nettle-2.5.tar.gz
    tar zxf nettle-2.5.tar.gz
    cd nettle-2.5
    ./configure --enable-shared
    make
    make install

    然后安装gnutls新版:

    wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.9.1.tar.xz
    xz -d gnutls-3.1.9.1.tar.xz
    tar xf gnutls-3.1.9.1.tar
    cd gnutls-3.1.9.1
    PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig ./configure --enable-shared
    make
    make install

    就是这样。

    2013.03.12 / 1 条评论 / 2,966 次点击 / 分类: 所谓技术

  • 在Linux中安装plowshare

    使用git将项目clone到机器上并安装。如果没有git,可以参考《CentOS安装git》安装。

    使用以下命令进行安装plowshare

    git clone https://code.google.com/p/plowshare/

    cd plowshare

    然后,由于新版的plowshare默认是支持bash4以上,而大多数Linux都还是bash3,如果运行,会出现“plowshare/src/core.sh: line 2592: local: -u: invalid option”的错误提示,所以正在用bash3的用户要改成支持bash3的分支。

    git branch -a #看到有两个分支,一个master,一个bash3,HEAD则是头分支

    git checkout bash3 #切换到bash3分支,并自动track远程的同名分支

    最后安装(如果用了bash4的版本则将“plowshare3”改为“plowshare4”):

    make install PREFIX=/usr/local/plowshare

    ln -sf /usr/local/plowshare/share/plowshare3/download.sh /usr/local/bin/plowdown

    ln -sf /usr/local/plowshare/share/plowshare3/upload.sh   /usr/local/bin/plowup

    ln -sf /usr/local/plowshare/share/plowshare3/delete.sh   /usr/local/bin/plowdel

    ln -sf /usr/local/plowshare/share/plowshare3/list.sh     /usr/local/bin/plowlist

    安装完毕好,就可以直接使用:

    plowdown 网址

    即可将网络硬盘上面的内容下载到本地了。如果有验证码,则要根据提示找到验证码,并将验证码输入即可,或者加上“--captchamethod=imgur”参数,把验证码传到imgur网址,就可以直接通过浏览器访问验证码啦。

    更新也很简单,先进入plowshare的git版本目录,运行:

    git pull --all

    rm -rf /usr/local/plowshare/

    make install PREFIX=/usr/local/plowshare

    2012.10.28 / 暂无评论 / 907 次点击 / 分类: 所谓技术

  • CentOS安装Ruby

    安装依赖

    yum install zlib-devel curl-devel openssl-devel apr-devel apr-util-devel expat-devel gettext-devel readline-devel gdbm-devel tcl-devel tk-devel

    手动安装libyaml否则会提示“yaml.h is missing. Please install libyaml. Failed to configure psych. It will not be installed.”

    wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz

    tar zxf yaml-0.1.4.tar.gz

    cd yaml-0.1.4

    ./configure --prefix=你的目录

    make

    make install

    手动安装libffi否则会提示“ffi.h is missing”

    wget ftp://sourceware.org/pub/libffi/libffi-3.0.11.tar.gz

    tar zxf libffi-3.0.11.tar.gz

    cd libffi-3.0.11

    ./configure --prefix=你的目录

    make

    make install

    ln 安装目录/lib/libffi-3.0.11/include/ffi.h /usr/local/include/ffi.h

    安装ruby 1.8(1.9的digest有问题,不知道何故)

    wget http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz

    tar zxf ruby-1.8.7.tar.gz

    cd ruby-1.8.7

    ./configure --prefix=你的目录 --enable-shared --enable-pthread

    make

    make install

    1.9内含rubygem,但1.8要手动安装:

    wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz

    tar zxf rubygems-1.8.24.tgz

    cd rubygems-1.8.24

    ruby setup.rb

    就是这样。搞定。

    2012.09.10 / 1 条评论 / 1,745 次点击 / 分类: 所谓技术

  • CentOS安装git

    CentOS默认源是没有git的,所以希望通过yum install来安装的童鞋们,不要在错误的道路上越走越远……

    所以,要从源安装,对应的命令:

    yum -y install zlib-devel openssl-devel perl cpio expat-devel gettext-devel

    wget http://git-core.googlecode.com/files/git-1.7.7.5.tar.gz

    ./configure --prefix=/usr/local/git

    make

    make install

    然后对执行文件进行链接,当然,如果安装在/usr/local目录的话,就不用这步了。

    ln -s /usr/local/git/bin/git /usr/local/bin/git

    ln -s /usr/local/git/bin/gitk /usr/local/bin/gitk

    ln -s /usr/local/git/bin/git-shell /usr/local/bin/git-shell

    ln -s /usr/local/git/bin/git-upload-pack /usr/local/bin/git-upload-pack

    ln -s /usr/local/git/bin/git-cvsserver /usr/local/bin/git-cvsserver

    ln -s /usr/local/git/bin/git-receive-pack /usr/local/bin/git-receive-pack

    ln -s /usr/local/git/bin/git-upload-archive /usr/local/bin/git-upload-archive

    常见问题

    1、如果出现“git: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory”

    在确认已经安装iconv库的情况下,执行以下命令:

    echo "/usr/local/lib" > /etc/ld.so.conf.d/git.conf

    /sbin/ldconfig

    2、如果在“git clone https://***”时出现“error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing”

    在使用git前加上“GIT_SSL_NO_VERIFY=true”的环境变量,即:

    env GIT_SSL_NO_VERIFY=true git clone https://***

    2012.01.09 / 2 条评论 / 2,936 次点击 / 分类: 所谓技术

  • CentOS下安装使用start-stop-daemon

    CentOS是没有start-stop-daemon的,因为start-stop-daemon在debian的dpkg包里。要安装的话,需要自己折腾。

    相关命令如下:

    wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz

    tar zxf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz

    mv apps/sys-utils/start-stop-daemon-IR1_9_18-2/ ./

    rm -rf apps

    cd start-stop-daemon-IR1_9_18-2/

    cc start-stop-daemon.c -o start-stop-daemon

    cp start-stop-daemon /usr/local/bin/start-stop-daemon

    至此安装完成。可以看到:

    [root@localhost ~]# start-stop-daemon --help
    start-stop-daemon 1.9.18 for Debian - small and fast C version written by
    Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.

    Usage:
      start-stop-daemon -S|--start options ... -- arguments ...
      start-stop-daemon -K|--stop options ...
      start-stop-daemon -H|--help
      start-stop-daemon -V|--version

    Options (at least one of --exec|--pidfile|--user is required):
      -x|--exec <executable>        program to start/check if it is running
      -p|--pidfile <pid-file>       pid file to check
      -c|--chuid <name|uid[:group|gid]>
                    change to this user/group before starting process
      -u|--user <username>|<uid>    stop processes owned by this user
      -n|--name <process-name>      stop processes with this name
      -s|--signal <signal>          signal to send (default TERM)
      -a|--startas <pathname>       program to start (default is <executable>)
      -N|--nicelevel <incr>         add incr to the process's nice level
      -b|--background               force the process to detach
      -m|--make-pidfile             create the pidfile before starting
      -R|--retry <schedule>         check whether processes die, and retry
      -t|--test                     test mode, don't do anything
      -o|--oknodo                   exit status 0 (not 1) if nothing done
      -q|--quiet                    be more quiet
      -v|--verbose                  be more verbose
    Retry <schedule> is <item>|/<item>/... where <item> is one of
    -<signal-num>|[-]<signal-name>  send that signal
    <timeout>                       wait that many seconds
    forever                         repeat remainder forever
    or <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout>

    Exit status:  0 = done      1 = nothing done (=> 0 if --oknodo)
                  3 = trouble   2 = with --retry, processes wouldn't die

    本文参考了此文档

    2011.12.20 / 3 条评论 / 5,399 次点击 / 分类: 梦溪笔记

  • Windows下编译安装Privoxy

    首先,要安装MingW。在此不赘述。当然,用cygwin也可以,但是这样编译出来的Privoxy没有GUI图形界面。PS:Privoxy在jcc.c那里已经自动识别了MingW,并且嵌入了Windows GUI的API,因此编译出来就可以自己采用图形界面了。

    然后,在这里下载Privoxy的源代码,本文以privoxy-3.0.18-stable为例。

    进入privoxy-3.0.18-stable源码目录,执行以下命令,进入bash:

    bash

    执行以下命令,进行配置:

    autoheader
    autoconf
    ./configure --prefix=/r/privoxy --enable-mingw32 --disable-pthread

    稍微解释以下configure的各个参数。--prefix参数指明privoxy的安装目录,/r/privoxy是mingw表示windows文件系统的方式,即R盘的privoxy文件夹。--enable-mingw32指明了为mingw环境配置,其实不指明配置程序也会自动检测得到。--disable-pthread是禁用POSIX的pthread,privoxy会自动使用windows API的thread来实现线程,具体参照errlog.c的部分代码:

    /*********************************************************************
     *
     * Function    :  get_thread_id
     *
     * Description :  Returns a number that is different for each thread.
     *
     *                XXX: Should be moved elsewhere (miscutil.c?)
     *
     * Parameters  :  None
     *
     * Returns     :  thread_id
     *
     *********************************************************************/
    static long get_thread_id(void)
    {
       long this_thread = 1;  /* was: pthread_t this_thread;*/
    
    #ifdef __OS2__
       PTIB     ptib;
       APIRET   ulrc; /* XXX: I have no clue what this does */
    #endif /* __OS2__ */
    
       /* FIXME get current thread id */
    #ifdef FEATURE_PTHREAD
       this_thread = (long)pthread_self();
    #ifdef __MACH__
       /*
        * Mac OSX (and perhaps other Mach instances) doesn't have a debuggable
        * value at the first 4 bytes of pthread_self()'s return value, a pthread_t.
        * pthread_t is supposed to be opaque... but it's fairly random, though, so
        * we make it mostly presentable.
        */
       this_thread = abs(this_thread % 1000);
    #endif /* def __MACH__ */
    #elif defined(_WIN32)
       this_thread = GetCurrentThreadId();
    #elif defined(__OS2__)
       ulrc = DosGetInfoBlocks(&ptib, NULL);
       if (ulrc == 0)
         this_thread = ptib -> tib_ptib2 -> tib2_ultid;
    #endif /* def FEATURE_PTHREAD */
    
       return this_thread;
    }

    配置成功后,编译安装:

    make

    make install

    其实,make后已经有privoxy.exe,可以下载官方的Win32版本的ZIP包,替换里面的privoxy.exe即可使用,无需再make install。

     

    一些注意的问题:

    1、编译时提示未定义“NI_MAXSERV”

    编译时出现如下错误:

    jbsockets.c: In function 'get_host_information':

    jbsockets.c:979:22: error: 'NI_MAXSERV' undeclared (first use in this function)

    jbsockets.c:979:22: note: each undeclared identifier is reported only once for e

    ach function it appears in

    make: *** [jbsockets.o] Error 1

    修改jbsockets.c,在

    const char jbsockets_h_rcs[] = JBSOCKETS_H_VERSION;

    前面加上:

    /* MOD BY Creke START */

    #ifndef NI_MAXSERV

    #define NI_MAXSERV    32

    #endif

    /* MOD BY Creke END */

    说实话,这是configure没有识别getnameinfo和getaddrinfo,因此config.h中没有定义HAVE_RFC2553所致。这些依赖于官方修复,再次仅拷贝ws2tcpip.h中的相关值进来,作临时修补。

    2、MingW默认安装的话,需要额外的库吗?

    需要zlib库,在mingw中又称为libz,可以在这里下载。当然,如果需要将privoxy拷贝到其它电脑运行,需要将libz-1.dll拷贝到privoxy程序目录中。

    3、额外的DLL?

    libgcc_s_dw2-1.dll

    4、编译好如何发行和安装?

    推荐下载官方发行的win32的zip包,将编译好的privoxy.exe覆盖。同时别忘记拷贝依赖的dll。

    2011.12.07 / 15 条评论 / 3,104 次点击 / 分类: 所谓技术