服务器 频道

用slackware架设虚拟主机管理系统

  【IT168 服务器学院】虚拟主机介绍

  虚拟主机是指采用特殊的软硬件技术,把一台真正的主机分为若干台主机对外提供服务,每一台虚拟主机都可以具有独立的域名和地址,具有完整的互联网服务器(WWW、FTP、Email)等功能。虚拟主机之间完全独立,并可由用户自行管理,可以大大地缓解互联网上IP及服务器等资源的不足,同时降低用户的硬件费用、网络维护费用和通讯服务费用。
 
  我们这里架设的虚拟主机是利用一台Slackware Linux作为服务器,然后通过Apache的virtual host功能来实现的,当然还要有DNS、FTP的配合。这样服务器只要有一个IP地址,就可以同时对多个域名提供web服务了。管理程序我们使用的web-cp,这样用户可以管理自己的域名和站点。

  架设环境

  因为是实验,所以使用的是VMware虚拟出来的环境。

  服务器系统:
slackware 10.1
  硬件配置:基本一台标准pc就可以了。
  网络要求:只要可以访问互联网就可以。
  网络环境:安装vmware的机器ip:20.20.20.15
                              子网掩码:255.255.255.0
                               网关:20.20.20.252
                               DNS:202.106.0.20

  安装Slackware系统

  只要按照默认安装就可以。可以参考下面的文章

  http://www.slack.cn/uploads/wordpress/slackware10install.pdf

  
注意:安装的使用,最好给/home一个单独的分区或者硬盘。因为我这里用的是Vmware虚拟的机器,所以就单独给/home分了一个硬盘。在实际情况中,可以给/home一个单独分区。

  安装后对网络设置

  1、设置ip和网关

  编辑/etc/rc.d/rc.inet1.conf文件。如果你使用putty远程登到slackware上的话,可以直接将下面内容用右键粘贴到终端来执行。下面文件的作用是将slackware服务器的ip设置为20.20.20.28 网关设置为20.20.20.252

cat > /etc/rc.d/rc.inet1.conf << “EOF”
#
# This file contains the configuration settings for network interfaces.
# If USE_DHCP[interface] is set to “yes”, this overrides any other settings.
# If you don’t have an interface, leave the settings null ("").

# Config information for eth0:
IPADDR[0]=“20.20.20.28”
NETMASK[0]=“255.255.255.0”
USE_DHCP[0]=“”
DHCP_HOSTNAME[0] =“”

# Config information for eth1:
IPADDR[1]=“”
NETMASK[1]=“”
USE_DHCP[1]=“”
DHCP_HOSTNAME[1]=“”

# Config information for eth2:
IPADDR[2]=“”
NETMASK[2]=“”
USE_DHCP[2]=“”
DHCP_HOSTNAME[2]=“”

# Config information for eth3:
IPADDR[3]=“”
NETMASK[3]=“”
USE_DHCP[3]=“”
DHCP_HOSTNAME[3]=“”

# Default gateway IP address:
GATEWAY=“20.20.20.252”

# Change this to “yes” for debugging output to stdout.  Unfortunately,
# /sbin/hotplug seems to disable stdout so you’ll only see debugging output
# when rc.inet1 is called directly.
DEBUG_ETH_UP=“no”
EOF

  2、设置主机名

  我用的主机名是www.test.com

cat > /etc/HOSTNAME < < "EOF"
www.test.com
EOF

chmod 644 /etc/HOSTNAME

  3、设置host文件

cat > /etc/hosts < < "EOF"
127.0.0.1        localhost
20.20.20.28     serv1.test.com serv1
20.20.20.28     test.com

EOF

chmod 644 /etc/hosts

  4、设置DNS

 cat > /etc/resolv.conf << “EOF”
nameserver 202.106.0.20
EOF

  通过上面这些设置,重启系统后,我的slackware linux系统就可以访问互联网了。这个很重要,因为后面要下载一些软件。

  设置inetd

  slackware默认通过inetd来起动proftp等进程。但这些并不适合我们作虚拟主机服务。我们需要通过下面的设置,关掉inetd起动的进程。

mv /etc/inetd.conf /etc/inetd.conf.old

cat > /etc/inetd.conf << “EOF”
# pop3    stream  tcp     nowait  root    /usr/sbin/tcpd  /usr/sbin/popa3d
# auth   stream   tcp   wait   root   /usr/sbin/in.identd   in.identd
#
# ftp     stream  tcp     nowait  root    /usr/sbin/tcpd proftpd
# echo    stream tcp nowait root internal
# echo    dgram udp wait root internal
# discard stream tcp nowait root internal
# discard dgram udp wait root internal
# daytime stream tcp nowait root internal
# daytime dgram udp wait root internal
# chargen stream tcp nowait root internal
# chargen dgram udp wait root internal
# time  stream tcp nowait root internal
# time  dgram udp wait root internal
# telnet stream  tcp     nowait  root    /usr/sbin/tcpd in.telnetd
# comsat        dgram   udp     wait    root    /usr/sbin/tcpd  in.comsat
# imap2   stream  tcp     nowait  root    /usr/sbin/tcpd  imapd
# finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd -u
# systat stream tcp nowait nobody /usr/sbin/tcpd /bin/ps -auwwx
# netstat stream tcp nowait root /usr/sbin/tcpd /bin/netstat -a
EOF

chmod 644 /etc/inetd.conf

  重启inetd

/etc/rc.d/rc.inetd stop
chmod 444 /etc/rc.d/rc.inetd

0
相关文章