歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> Unix教程 >> FreeBSD網站平台建設全過程

FreeBSD網站平台建設全過程

日期:2017/2/27 17:43:38   编辑:Unix教程
FreeBSD
  試驗環境如下:
  硬件環境:普通pc機,雙網卡。配制不需要高,主要是穩定,並能適應長時間開機。聽前輩介紹AMD k6的cpu運行FreeBSD好像有點問題。不過我沒有試驗。建議用intel的。
  軟件環境:操作系統:FreeBSD4.7(4.8)
  web服務器:Apache 1.3.27+modssl +mod_php4+mod_gzip+mod_fastcgi +mod_perl +mysql3.23
  ftp服務器:Proftpd1.2.7+proftpd-mod-quotatab-1.2.4+mysql
  mail服務器: iceblood前輩制作的qmail安裝包(經過修改)+vqregister-2.5
  proxy服務器:使用FreeBSD內置的NAT和PPP撥號+squid
  視頻點播服務器:Helix Universal Servevr (realserver9.01)
  網絡環境:我用的是adsl動態撥號方式,因為動態ip所存在的一些問題,我把所有的服務都裝在一台機器上,且這台機器要直接與外網相連。靜態ip更方便一些。(本文兩種方式都會討論)
  
  第一步:安裝系統
  關於安裝過程網上有很多文章,這裡不作詳述。僅提出幾點建議供大家參考:
  1、 采用最小化安裝。
  2、 安裝時啟用inetd,並在編輯inetd.conf文件時,把帶有“ftp”的行前面的“#”號去掉。這樣作是為了以後安裝軟件時可以用ftp上傳文件。
  3、 添加一個wheel組的用戶,這樣在系統工作正常後可以在windows系統上通過終端登錄軟件(如SecureCRT)進行所有操作。FreeBSD4.7在最小安裝時支持SSH終端登錄,所以我們需要使用支持SSH協議的終端軟件,如SecureCRT。例如我添加的用戶名是ylf,隸屬wheel系統組。系統產生一個用戶目錄/home/ylf。我可以通過SecureCRT以ylf身份登錄到系統,然後通過su命令切換到root用戶。同時我也可以在IE浏覽器內鍵入ftp://192.168.0.1 ,並輸入ylf用戶名和密碼登錄ftp將需要的文件上傳到自己的用戶目錄裡。(192.168.0.1是我的服務器連接內網的網卡ip地址)。以下除系統安裝部分,我都是采用終端方式操作。
  4、 分區時將/home、/usr和/var劃的大一些,因為/usr為程序目錄,/var要存放日志,/home是用戶主目錄,我的用戶文件如網頁、ftp上傳文件等都放在這裡。還有最好保留一部分空間留作以後需要的時候用。我的機器上有2塊硬盤,一快18.2G SCSI硬盤,一塊40G IDE硬盤。我是這樣劃分的。
  128M    /
  20G    /home
  2G     /ftp
  256M    /tmp
  6G     /usr
  5G    /var
  其中/ftp是為匿名ftp用戶訪問專用。剩余空間留作備用。當然如果硬盤空間少的話,做我們的試驗也是夠用的。
  關於安裝方面的文章,大家也可以參考delphij寫的《FreeBSD服務器的安裝與優化》。[url]http://community.freebsdchina.org/catalog.php?forum=34[/url] 一文。
  安裝完系統後,要重新編譯內核。目的是要系統支持Firrwall和提高運行效率。
  首先確認系統是否安裝了FreeBSD的內核支持。如果是最小安裝,則需要運行/stand/sysinstall命令安裝內核支持。方法如下:
  # /stand/sysinstall
  選Configure—Distributions—src—sys,內核文件將被安裝在/usr/src/sys目錄中。
  注意:這之後的過程在終端上操作要方便許多。SecureCRT支持在終端界面上直接拷貝和粘貼文本內容。
  轉到內核文件目錄
  # cd /usr/src/sys/i386/conf
  編輯內核文件
  # vi kernel_wwwx   # kernel_wwwx為我的內核文件名
  我的內核文件如下:
  #
  # GENERIC -- Generic kernel configuration file for FreeBSD/i386
  #
  # For more information on this file, please read the handbook section on
  # Kernel Configuration Files:
  #
  #http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
  #
  # The handbook is also available locally in /usr/share/doc/handbook
  # if you've installed the doc distribution, otherwise always see the
  # FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
  # latest information.
  #
  # An exhaustive list of options and more detailed explanations of the
  # device lines is also present in the ./LINT configuration file. If you are
  # in doubt as to the purpose or necessity of a line, check first in LINT.
  #
  # $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.48 2002/08/31 20:28:26 obrien Exp $
  
  machine i386
  cpu I586_CPU
  cpu I686_CPU
  ident kernel_wwwx        #內核文件名,這個要和你的內核文件名一致
  maxusers 0
  
  options INET #InterNETworking
  options FFS #Berkeley Fast Filesystem
  options FFS_ROOT #FFS usable as root device [keep this!]
  options SOFTUPDATES #Enable FFS soft updates support
  options UFS_DIRHASH #Improve performance on big directories
  options PROCFS #Process filesystem
  options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
  options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
  options SYSVSHM #SYSV-style shared memory
  options SYSVMSG #SYSV-style message queues
  options SYSVSEM #SYSV-style semaphores
  options P1003_1B #Posix P1003_1B real-time extensions
  options _KPOSIX_PRIORITY_SCHEDULING
  options ICMP_BANDLIM #Rate limit bad replies
  options AHC_REG_PRETTY_PRINT # Print register bitfields in debug
  # output. Adds ~128k to driver.
  options AHD_REG_PRETTY_PRINT # Print register bitfields in debug
  # output. Adds ~215k to driver.
  
  device tun 1
  options     IPFIREWALL       #防火牆
  options     IPFIREWALL_FORWARD   #允許透明代理
  options     IPFIREWALL_VERBOSE   #允許防火牆日志
  options     IPFIREWALL_VERBOSE_LIMIT=100   #限制日志
  options     IPFIREWALL_DEFAULT_TO_ACCEPT   #默認允許所有IP包
  options     IPDIVERT        #啟用由ipfw divert使用的轉向IP套接字
  
  # To make an SMP kernel, the next two are needed
  #options SMP # Symmetric MultiProcessor Kernel
  #options APIC_IO # Symmetric (APIC) I/O
  
  device isa
  device eisa
  device pci
  
  
  # ATA and ATAPI devices
  device ata
  device atadisk # ATA disk drives
  
  
  # SCSI Controllers   #沒有SCSI設備不需要這段
  device ahb # EISA AHA1742 family
  device ahc # AHA2940 and onboard AIC7xxx devices
  device ahd # AHA39320/29320 and onboard AIC79xx devices
  device amd # AMD 53C974 (Tekram DC-390(T))
  device isp # Qlogic family
  device mpt # LSI-Logic MPT/Fusion
  device ncr # NCR/Symbios Logic
  device sym # NCR/Symbios Logic (newer chipsets)
  options SYM_SETUP_LP_PROBE_MAP=0x40
  # Allow ncr to attach legacy NCR devices when
  # both sym and ncr are configured
  
  device adv0 at isa?
  device adw
  device bt0 at isa?
  device aha0 at isa?
  device aic0 at isa?
  
  device ncv # NCR 53C500
  device nsp # Workbit Ninja SCSI-3
  device stg # TMC 18C30/18C50
  
  # SCSI peripherals     #沒有SCSI設備不需要這段
  device scbus # SCSI bus (required)
  device da # Direct Access (disks)
  device sa # Sequential Access (tape etc)
  device cd # CD
  device pass # Passthrough device (direct SCSI access)
  
  
  
  # atkbdc0 controls both the keyboard and the PS/2 mouse
  device atkbdc0 at isa? port IO_KBD
  device atkbd0 at atkbdc? irq 1 flags 0x1
  
  device vga0 at isa?
  
  
  # syscons is the default console driver, resembling an SCO console
  device sc0 at isa? flags 0x100
  
  
  # Floating point support - do not disable.
  device npx0 at nexus? port IO_NPX irq 13
  
  
  # Serial (COM) ports
  device sio0 at isa? port IO_COM1 flags 0x10 irq 4
  
  # 我用的是8139和Dlink DFE-530TX網卡,大家可根據自己的網卡型號保留或刪除
  # 使用公共的MII總線控制器代碼的PCI以太網適配器
  # 注意:一定要保留'device miibus'以確保可用
  # PCI Ethernet NICs that use the common MII bus controller code.
  # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
  device miibus # MII bus support
  device fxp # Intel EtherExpress PRO/100B (82557, 8255
  device rl # RealTek 8129/8139
  device vr # VIA Rhine, Rhine II
  device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
  
  # Pseudo devices - the number indicates how many units t
Copyright © Linux教程網 All Rights Reserved