歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> Unix基礎知識 >> 基於UNIX平台FTP服務器的建立(上)

基於UNIX平台FTP服務器的建立(上)

日期:2017/2/25 10:13:17   编辑:Unix基礎知識
  目前很多企業單位正在構架自己的Intranet,FTP服務器是其中的一個服務支持,有很多單位購置了基於UNIX平台的計算機,為了在網上能夠提供FTP服務支持,專門購置基於UNIX平台的FTP Server軟件,其實在基於UNIX平台的計算機系統中,采取一定的技術方法,就可以建立自己的FTP Server,實現網上文件上下載服務,無須再購置專門的軟件,和樂而不為之呢?下面就其建立過程闡述如下:
  1.確定FTP Server的共享目錄
  為FTP Server建立一個FTP工作目錄,在此設定為/home/ftp
  2.編寫FTP Server初始設置的Shell程序(setup)
  用編輯工具(如vi)編寫一個Shell程序,用於對系統進行設置。
  #!/bin/sh
  case $# in
  0) ftphome="`grep '^ftp:' /etc/passwd cut -d: -f6`"
  ;;
  1) if [ "$1" = "start" ]; then
  ftphome="`grep '^ftp:' /etc/passwd cut -d: -f6`"
  else
  ftphome=$1
  fi
  ;;
  *) echo "Usage: $0 [anon-ftp-root]"
  exit 1
  ;;
  esac
  if [ -z "${ftphome}" ]; then
  echo "$0: ftphome must be non-null"
  exit 2
  fi
  if [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then
  echo "$0: ftphome must not be / or /usr"
  exit 2
  fi
  if [ ! -d ${ftphome} ]; then
  mkdir ${ftphome}
  fi
  if [ ! -d ${ftphome}/usr/bin ]; then
  mkdir -p ${ftphome}/usr/bin
  fi
  cp /usr/bin/ls ${ftphome}/usr/bin
  chmod 111 ${ftphome}/usr/bin/ls
  chown root ${ftphome}/usr/bin
  chmod 555 ${ftphome}/usr/bin
  if [ -r ${ftphome}/bin ]; then
  mv -f ${ftphome}/bin ${ftphome}/Obin
  fi
  ln -s usr/bin ${ftphome}
  if [ ! -d ${ftphome}/usr/lib ]; then
  mkdir -p ${ftphome}/usr/lib
  fi
  if [ ! -d ${ftphome}/etc ]; then
  mkdir -p ${ftphome}/etc
  fi
  cp /usr/lib/ld.so /usr/lib/ld.so.1 ${ftphome}/usr/lib
  for lib in libc libdl libintl libw libnsl libsocket \
  nss_nis nss_nisplus nss_dns nss_files
  do
  cp /usr/lib/${lib}.so.1 ${ftphome}/usr/lib
  rm -f ${ftphome}/usr/lib/${lib}.so
  ln -s ./${lib}.so.1 ${ftphome}/usr/lib/${lib}.so
Copyright © Linux教程網 All Rights Reserved