星期日, 四月 06, 2008

The Perfect Setup - Debian Etch

软件包列表:
  • Web Server: Apache 2.2
  • Database Server: MySQL 5.0
  • DNS Server: BIND9
  • FTP Server: proftpd
下载debian的系统安装镜像:http://ftp.de.debian.org/debian-cd/4.0_r3/i386/iso-cd/debian-40r3-i386-netinst.iso
本机ip为192.168.0.100.gateway=192.168.0.1,hostname:server1.example.com
刻盘安装,或者是硬盘安装之类。选择语言,分区,安装系统。不再赘述。
安装完毕后重新启动系统。root用户登陆,配置网络。
nano /etc/network/interfaces
auto eth0
#iface eth0 inet dhcp
iface eht0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
配置DNS
nano /etc/resolv.conf
nameserver 202.102.128.68
之后重起网络脚本
/etc/init.d/networking restart
编辑/etc/hosts
nano /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.0.100 server1.example.com server1
#The following lines are desirable for IPv6 capbale hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
编辑/etc/hostname
echo server1.example.com > /etc/hostname
安装sshServer
apt-get install ssh openssh-server //之后可以用ssh来登陆了,把服务器的键盘和显示器都给摘掉。
之后重启系统
reboot

更新源,这里用cn99的源比较快。
deb http://debian.cn99.com/debian etch main contrib non-free
deb-src http://debian.cn99.com/debian etch main contrib non-free
deb http://debian.cn99.com/debian-security etch/updates main contrib non-free
apt-get update
apt-get dist-upgrade

安装一些基本的编译之类的包以备后面用到。
apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev linux-kernel-headers lynx m4 make ncftp nmap openssl perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++
安装DNSserver
apt-get isntall bind9
/etc/init.d/bind9 stop //停止服务
编辑/etc/default/bind9,使用自定义的路径和配置文件
vi /etc/default/bind9
OPTIONS="-u bind -t /var/lib/named"
# Set RESOLVCONF=no to not run resolvconf
RESOLVCONF=yes
之后创建自己的目录
mkdir -p /var/lib/named/etc
mkdir /var/lib/named/dev
mkdir -p /var/lib/named/var/cache/bind
mkdir -p /var/lib/named/var/run/bind/run
移动bind的配置文件夹到自定义的目录
mv /etc/bind /varlib/name/etc
创建连接到/etc/bind
ln -s /var/lib/named/etc/bind /etc/bind
创建null和random设备,修改权限
mknod /var/lib/named/dev/null c 1 3
mknod /var/lib/named/dev/random c 1 8
chmod 666 /var/lib/named/dev/null /var/lib/named/dev/random
chown -R bind:bind /var/lib/named/var/*
chown -R bind:bind /var/lib/named/etc/bind
添加修改日志目录
nano /etc/default/syslogd
#
# Top configuration file for syslogd
#

#
# Full documentation of possible arguments are found in the manpage
# syslogd(8).
#

#
# For remote UDP logging use SYSLOGD="-r"
#
SYSLOGD="-a /var/lib/named/dev/log"
重新启动日志服务和bind服务
/etc/init.d/syskolgd restart
/etc/init.d/bind9 start

安装MySQL
apt-get install mysql-server mysql-client libmysqlclient15-dev
去掉localhost的监听
nano /etc/mysql/my.cnf
注释掉
#bind-address = 127.0.0.1
重启mysql服务
/etc/init.d/mysql restart
查看网络状态
netstat -tap
出现如下状态提示
tcp 0 0 *:mysql *:* LISTEN 3281/mysqld

之后设置密码
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
去掉邮件服务安装步骤,偶的服务器不需要。
安装apache和php5
apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
之后安装php5
apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
之后会出现如下提示
Continue installing libc-client without Maildir support? <-- Yes

编辑/etc/apache2/mods-available/dir.conf
<IfModule mod_dir.c>

DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml

</IfModule>
修改监听端口,添加443端口。
nano /etc/apache2/ports.conf
Listen 80
Listen 443
启动一些必要的apache模块
a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include
重启apache服务
/etc/init.d/apache2 force-reload

去掉ISP配置

安装FTP服务器
apt-get install proftpd ucf
之后出现如下提示
Run proftpd from inetd or standalone? <-- standalone
修改配置文件,去掉IPv6支持。
nano /etc/proftpd/proftpd.conf
[...]
UseIPv6 off
[...]
具体的proftpd不赘述
重启proftpd服务
/etc/initd./proftpd restart

基本的apache,php,mysql,ftp就安装完毕。
原文连接:The Perfect Setup - Debian Etch

没有评论: