再次记录主机大换血之路

还是Debian 7 x86版

这次从新建用户开始
以root权限开始


#-------------------基本篇-----------------------
#为了那些看不见的星星,选en_US.UTF-8
dpkg-reconfigure locales

#新建用户
useradd -d /home/jhpx -s /bin/bash -c "Mengfeng Jiang" jhpx
mkdir /home/jhpx && chown jhpx /home/jhpx && passwd jhpx

#手动恢复相关文件~/.profile与~/.bashrc
#sudo必不可少,一般已装
#apt-get install sudo
#确认sudo组名,一般是wheel或sudo
cat /etc/sudoers
#添加当前用户jhpx至sudo组,加完需重新登录
sudo usermod -a -G sudo jhpx

##bash-completion已安装
#apt-get install bash-completion

#-------------------编辑器篇-----------------------
#编辑器 emacs源 使用24版
echo -e "deb http://londo.ganneff.de/ stable main\ndeb-src http://londo.ganneff.de/ stable main" |sudo tee /etc/apt/sources.list.d/emacs.list

以下进入用户权限
#公钥错误
sudo apt-get update
#生成公钥配置文件,用户权限即可
gpg --export
#导入公钥,用户权限即可
gpg --recv-keys AD287B4E92138B93
gpg --armor --export 92138B93| sudo apt-key add -
sudo apt-get update

#然后安装编辑器 emacs24
sudo apt-get install emacs-snapshot

#安装git,手动恢复相关文件~/.gitconfig
sudo apt-get install git

#编辑源,添加contrib与non-free
#-------------------服务器篇-----------------------
#改ssh端口,可忽略
sudo emacs /etc/ssh/sshd_config

##apache2已安装
#apt-get install apache2

#编辑文件/etc/apache2/apache2.cnf,略修改

#(1G内存的机器):
<IfModule mpm_prefork_module>
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         10
    MaxClients              50
    MaxRequestsPerChild   1000
</IfModule>

#装mysql并配置
sudo apt-get install mysql-server
sudo mysql_secure_installation

#编辑文件/etc/mysql/my.cnf,略修改
no-auto-rehash #禁用此物提高效率 

#装phpmyadmin并配置
sudo apt-get install phpmyadmin

#装php5
sudo apt-get install php5

#添加rewrite模块
sudo a2enmod rewrite

#添加donneryst.com,手动复制到/etc/apache2/sites-available/donneryst.com
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/donneryst.com .

#让www-data能够登录
passwd www-data

#真正让邮件好使
sudo apt-get install postfix

#迁移wordpress,略过不表

#-------------------代理篇-----------------------
#shadowsocks源,用户权限下使用tee绕开重定向权限错误
echo "deb http://shadowsocks.org/debian wheezy main" |sudo tee /etc/apt/sources.list.d/shadowsocks.list
sudo apt-get update

#公钥问题
gpg --recv-keys 1939D14B1D27208A
gpg --armor --export 1D27208A| sudo apt-key add -
sudo apt-get update

#安装shadowsocks
sudo apt-get install shadowsocks-libev
#配置shadowsocks,必须填入公网ip
sudo emacs /etc/shadowsocks-libev/config.json
#重启服务
sudo service shadowsocks-libev restart

#-------------------Seafile篇-----------------------
mkdir seafile
cd seafile
#区分x64还是x32,从官网下载稳定版
http://download-cn.seafile.com/seafile-server_4.1.2_x86-64.tar.gz
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed

apt-get install python2.7 python-setuptools python-imaging python-mysqldb

cd seafile-server-*
./setup-seafile-mysql.sh  #运行安装脚本并回答预设问题

#apache2下部署Seahub
sudo apt-get install python-flup

#添加fastcgi模块
sudo apt-get install libapache2-mod-fastcgi
sudo a2enmod fastcgi
sudo a2enmod proxy_http

#在ccnet/ccnet.conf的SERVICE_URL字段中自定义URL。
SERVICE_URL = http://donneryst.com/seafile

#在seahub_settings.py新增几行
FILE_SERVER_ROOT = 'http://donneryst.com/seafhttp'
SERVE_STATIC = False
MEDIA_URL = '/seafmedia/'
SITE_ROOT = '/seafile/'

#恢复/etc/init.d/seafile-server
sudo update-rc.d seafile-server defaults

#apache2中的seafile其它配置手工对比恢复

#-------------------Deluge篇-----------------------
#迁移/etc/apt/add-apt-repository

#准备add-apt-repository执行依赖
sudo apt-get install python-software-properties

#增加PPA源
sudo add-apt-repository 'deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu precise main'
sudo apt-get update

#安装deluge
sudo apt-get install -t precise deluge-common deluged deluge-web deluge-console
#参考官网迁移配置
http://dev.deluge-torrent.org/wiki/UserGuide/Service/DebianUbuntuInitd
#没事多重启几次service deluge-daemon,建全~/.config/deluge/文件目录下文件

#-------------------mldonkey篇-----------------------
#直接安装
sudo apt-get install mldonkey

#配置略复杂,参考官网
http://mldonkey.sourceforge.net/Quickstart_guide