freebsd+apache+mysql+php+phpmyadmin+zend+discuz傻瓜式教程

http://www.chinaunix.net/jh/88/136638.html

Freebsd5.1release+httpd-2.0.47+mysql-4.0.14+php-4.3.2+phpMyAdmin-2.5.1+ZendOptimizer-2.1.0b-FreeBSD4.0-i386+discuz2.0-gb2312详细安装之傻瓜式教程

作者:tahaomei

主页:www.dragonson.org

邮箱:tahaomei@163.com

QQ:4831404

完成时间:2003.8.9

(如果您想转载这篇文章,请不要去掉以上的版权信息,欢迎分享)

刚接触linux是今年4月的事情,装过不少linux发行版本,最终还是选择了unix中的freebsd,喜欢它的简洁。不过我也是初学者,将这10多天学freebsd的经验总结给大家分享,希望大家能够少走当初我的一些弯路。感谢www.chinaunix.net和www.linuxsir.com众多热心的朋友。这两个地方丰富宝贵的资料足够学一辈子。参考了两个论坛的若干帖子,都不记得帖子来源了,以下内容如果没提到作者以及来源,请见谅。

本文档chm格式下载地址:http://www.dragonson.org/jiaocheng/apache/apache.chm

本文档pdf格式下载地址:http://www.dragonson.org/jiaocheng/apache/apache.pdf

本文档网络在线阅读地址:http://www.dragonson.org/jiaocheng/apache/index.html

1. 安装freebsd5.1-minidisk

因为我有两台电脑,打算将实验室那台配置成FREEBSD服务器,然后在宿舍通过SSH远程登陆管理,所以FREEBSD服务器不装X-WINDOWS,选择最小安装盘安装,可以从

http://community.freebsdchina.or ... c=3273&forum=45

下载5.1-RELEASE-i386-miniinst.iso刻录后进行安装,详细安装步骤请参考如下文档

http://community.freebsdchina.or ... c=1772&forum=34

最好买几本书来参考。推荐如下教材:

(1) FREEBSD使用大全,王波编著,机械工业出版社,75元(附光盘一张)

(2) FREEBSD技术内幕,(美)Michael Urban Brian Tiemann著,机械工业出版社,88元(附光盘两张)

(3) FREEBSD中文手册

其中(2),(3)在北京图书大厦有销售,(1)建议你去北京海淀图书城买,还能打折。

当然,如果想免费,可以从网上下载以上电子书籍,以下是我提供的一些相关资料下载地址(服务器有时候切换到WINDOWS下进行科研,但是晚上一般还是能下载的),以下软件或书籍如果是rar格式,请先下载winrar软件进行解压。

Winrar软件:

http://www.dragonson.org/soft/Ha_wrar32b2_zmb.exe

FREEBSD使用大全:

http://www.dragonson.org/soft/freebsd.chm

FREEBSD中文手册

http://www.dragonson.org/soft/freebsd handbook.pdf

网管应用文萃

http://www.dragonson.org/soft/wgyy.chm

introduction to unix

http://www.dragonson.org/soft/introduction to unix.pdf

网管通鉴

http://www.dragonson.org/soft/wgtj.chm

The_Complete_FreeBSD

http://www.dragonson.org/soft/The_Complete_FreeBSD.zip

Absolute BSD. The Ultimate Guide to FreeBSD

http://www.dragonson.org/soft/Absolute BSD.pdf

这些资料,你要是啃透的话,就不用我在这里罗嗦了。

安装完FREEBSD5.1以后,我就让实验室的机器开着,回宿舍拉。呵呵,以下所有的工作都是通过SSH远程控制来实现。

2.安装windows下客户端ssh登陆软件

我的步骤如下:

现在我不在实验室服务器的旁边进行操作了,而是在宿舍机器的windows xp系统下进行远程SSH控制。可以通过

http://www.dragonson.org/soft/o-ssh230.rar

来下载我用的SSH登陆软件,用winrar3.0以上版本解压缩后,执行SSHWin-2.3.0.exe进行安装,安装完后,桌面多了两个图标,一个是SSH Secure File Transfer Client,此软件用来进行文件传输的,很方便,另一个是SSH Secure Shell Client,远程shell登陆用的。此软件为商业软件,有期限限制,所以安装完了后,我们运行以上两个软件后,都要点窗口菜单里的help-----import license file 来导入我们刚才解压后文件夹里的license.dat,进行软件期限的破解。破解后,现在可以登陆SSH拉。

SSH Secure Shell Client登陆界面如下:

SSH Secure File Transfer Client的登陆界面如下:

以上两者登陆方式相似,输入主机名称和用户名后,就会弹出一个输入密码的小窗口,输入密码后,就分别进入如下图的内容:

SSH Secure Shell Client登陆后界面如下:

SSH Secure File Transfer Client的登陆界面如下:

不过我觉得文件传输还是用cuteftp比较好,也可以进行SSH2的安全传输,还能支持断点续传,推荐使用。你可以从以下地址来下载http://www.dragonson.org/soft/CuteFTP Pro 3.2 Build 7.01.1.rar,配置cuteftp可以参考下图

3.我要一个彩色的ls世界 [ 可以跳过此步骤到第4步骤 ]

FreeBSD的ls真是沉闷,为什么不能带点彩色呢?

参考文献:

http://www.huangdong.com/freebsd/tips/colorls.html

注意事项:千万别装完APACHE服务器后再进行这个步骤,否则服务器目录消失了别怪我。(我的悲惨经历)

进行如下步骤:

www#cd /usr/ports/misc/gnuls

www#make;make install;make clean

[ 说明:要保证系统与外网连接,系统会自动从网络上下载该源代码进行安装。]

安装好后,执行命令 vi /etc/profile

添加如下一行内容

alias ls="gnuls --color"

保存退出。

通过shutdown –r now命令远程启动机器,过几分钟后,机器的SSH服务会自动执行,我们可以用ssh客户端软件进行远程登陆。

4.定制系统内核

系统启动后自动运行的进程有sendmail,鉴于sendmail漏洞太多,且已经有了安全性更好的postfix和qmail替代品,我们执行如下命令来取消sendmail的自动运行进程。

www#vi /etc/rc.conf

找到sendmail_enable="YES"那行,更改为sendmail_enable="NONE",执行:wq!命令保存退出。

定制系统内核的好处,不用我多说了吧?

可以参考FREEBSD使用大全和FREEBSD中文手册两本电子教程,里面有详细的描述。

我的服务器配置如下:

CPU: AMD Athlon(tm) processor (1135.23-MHz 686-class CPU)

Hardisk: IBM 40G 7200转

Ram: HY 256M DDR

Softdriver: sonny1.44”

Cdrom: Benq 50x

Netcard: DLink DFE-530TX(买错了哦,当初自己天真了一回,以下是别人对该网卡的评价)

评价一:

两台机器:

P4-2.2G/512M/RealTek 8139/Win2000 server

P2-233/256M/DLink DFE-530TX/FreeBSD 4.6.2

从Win ftp upload文件到FreeBSD,平均2xx-5xx KBytes/sec

把DLink DFE-530TX换成3C905,ftp速度提高到6xxx-9xxx KBytes/sec !!!

评价二:

有什么办法,它便宜啊!

一样都是100M的网卡,价钱却差很多,无法比较!!!

说句老实话,我觉得国人的产品和台湾的产品,都属于一个档次,用一个字形容:烂!!

评价三:

别不服输,我也想用国人的东西,但没办法!!

便宜与性能差是两回事。那张8139比Dlink还便宜,才40多元,是它和3com905连接在一起跑到6-9Mbytes/sec的

现在开始定制我的系统内核,每台机器配置不一样,我的配置文件仅供参考。

执行命令如下:

www#cd /usr/src/sys/i386/conf

www#cp GENERIC DRAGONSON [ 说明:DRAGONSON是我的配置文件名,您可以另外取自己喜欢的名字]

www#vi DRAGONSON

以下是我的DRAGONSON配置文件内容,其中红色为我注销或添加的地方。

#

# 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 ... lconfig-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 http://www.cnblogs.com/conf/NOTES and NOTES files.

# If you are in doubt as to the purpose or necessity of a line, check first

# in NOTES.

#

# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.384.2.2 2003/05/31 15:18:41 scottl Exp $

machine i386

#cpu I486_CPU

#cpu I586_CPU

cpu I686_CPU

ident DRAGONSON #说明:此处要与你的新内核名一致

maxusers 64

#To statically compile in device wiring instead of /boot/device.hints

#hints "GENERIC.hints" #Default places to look for devices.

#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols

options SCHED_4BSD #4BSD scheduler

options INET #InterNETworking

#options INET6 #IPv6 communications protocols

options FFS #Berkeley Fast Filesystem

options SOFTUPDATES #Enable FFS soft updates support

options UFS_ACL #Support for access control lists

options UFS_DIRHASH #Improve performance on big directories

options MD_ROOT #MD is a potential root device

#options NFSCLIENT #Network Filesystem Client

#options NFSSERVER #Network Filesystem Server

#options NFS_ROOT #NFS usable as root device, requires NFSCLIENT

#options MSDOSFS #MSDOS Filesystem

#options CD9660 #ISO 9660 Filesystem

options PROCFS #Process filesystem (requires PSEUDOFS)

options PSEUDOFS #Pseudo-filesystem framework

options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]

options COMPAT_FREEBSD4 #Compatible with FreeBSD4

#options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI

#options KTRACE #ktrace(1) support

options SYSVSHM #SYSV-style shared memory

options SYSVMSG #SYSV-style message queues

options SYSVSEM #SYSV-style semaphores

options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions

#options KBD_INSTALL_CDEV # install a CDEV entry in /dev

#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.

# Debugging for use in -current

#options DDB #Enable the kernel debugger

#options INVARIANTS #Enable calls of extra sanity checking

#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS

#options WITNESS #Enable checks to detect deadlocks and cycles

#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed

# 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

# Floppy drives

#device fdc #我不使用软驱

# ATA and ATAPI devices

device ata

device atadisk # ATA disk drives

#device atapicd # ATAPI CDROM drives #不使用光驱

#device atapifd # ATAPI floppy drives #不使用软驱

#device atapist # ATAPI tape drives

#options ATA_STATIC_ID #Static device numbering

# SCSI Controllers

#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 + those of `ncr')

#device trm # Tekram DC395U/UW/F DC315U adapters

#device adv # Advansys SCSI adapters

#device adw # Advansys wide SCSI adapters

#device aha # Adaptec 154x SCSI adapters

#device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60.

#device bt # Buslogic/Mylex MultiMaster SCSI adapters

#device ncv # NCR 53C500

#device nsp # Workbit Ninja SCSI-3

#device stg # TMC 18C30/18C50

# RAID controllers interfaced to the SCSI subsystem

#device asr # DPT SmartRAID V, VI and Adaptec SCSI RAID

#device ciss # Compaq Smart RAID 5*

#device dpt # DPT Smartcache III, IV - See NOTES for options!

#device iir # Intel Integrated RAID

#device mly # Mylex AcceleRAID/eXtremeRAID

# SCSI peripherals

#device scbus # SCSI bus (required)

#device ch # SCSI media changers

#device da # Direct Access (disks)

#device sa # Sequential Access (tape etc)

#device cd # CD

#device pass # Passthrough device (direct SCSI access)

#device ses # SCSI Environmental Services (and SAF-TE)

# RAID controllers

#device aac # Adaptec FSA RAID

#device aacp # SCSI passthrough for aac (requires CAM)

#device amr # AMI MegaRAID

#device ida # Compaq Smart RAID

#device ips # IBM (Adaptec) ServeRAID

#device mlx # Mylex DAC960 family

#device pst # Promise Supertrak SX6000

#device twe # 3ware ATA RAID

# atkbdc0 controls both the keyboard and the PS/2 mouse

device atkbdc # AT keyboard controller

device atkbd # AT keyboard

#device psm # PS/2 mouse #反正是远程登陆,不使用鼠标

device vga # VGA video card driver

device splash # Splash screen and screen saver support

# syscons is the default console driver, resembling an SCO console

device sc

options MAXCONS=4 #虚拟控制台数量为4个,已经够用了

options SC_DISABLE_REBOOT #禁止按ctrl+alt+del来进行重新启动

options SC_NO_SYSMOUSE #不使用鼠标

# Enable this for the pcvt (VT220 compatible) console driver

#device vt

#options XSERVER # support for X server on a vt console

#options FAT_CURSOR # start with block cursor

device agp # support several AGP chipsets

# Floating point support - do not disable.

device npx

# Power management support (see NOTES for more options)

#device apm

# Add suspend/resume support for the i8254.

#device pmtimer

# PCCARD (PCMCIA) support

# Pcmcia and cardbus bridge support

#device cbb # cardbus (yenta) bridge

#device pcic # ExCA ISA and PCI bridges

#device pccard # PC Card (16-bit) bus

#device cardbus # CardBus (32-bit) bus

# Serial (COM) ports

#device sio # 8250, 16[45]50 based serial ports

# Parallel port

#device ppc

#device ppbus # Parallel port bus (required)

#device lpt # Printer

#device plip # TCP/IP over parallel

#device ppi # Parallel port interface device

#device vpo # Requires scbus and da

# PCI Ethernet NICs.

#device de # DEC/Intel DC21x4x (``Tulip'')

#device em # Intel PRO/1000 adapter Gigabit Ethernet Card

#device txp # 3Com 3cR990 (``Typhoon'')

#device vx # 3Com 3c590, 3c595 (``Vortex'')

# 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 dc # DEC/Intel 21143 and various workalikes

#device fxp # Intel EtherExpress PRO/100B (82557, 82558)

#device pcn # AMD Am79C97x PCI 10/100 (precedence over 'lnc')

#device rl # RealTek 8129/8139

#device sf # Adaptec AIC-6915 (``Starfire'')

#device sis # Silicon Integrated Systems SiS 900/SiS 7016

#device sk # SysKonnect SK-984x and SK-982x gigabit ethernet

#device ste # Sundance ST201 (D-Link DFE-550TX)

#device ti # Alteon Networks Tigon I/II gigabit ethernet

#device tl # Texas Instruments ThunderLAN

#device tx # SMC EtherPower II (83c170 ``EPIC'')

device vr # VIA Rhine, Rhine II

#device wb # Winbond W89C840F

#device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')

#device bge # Broadcom BCM570xx Gigabit Ethernet

# ISA Ethernet NICs. pccard nics included.

#device cs # Crystal Semiconductor CS89x0 NIC

# 'device ed' requires 'device miibus'

#device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards

#device ex # Intel EtherExpress Pro/10 and Pro/10+

#device ep # Etherlink III based cards

#device fe # Fujitsu MB8696x based cards

#device ie # EtherExpress 8/16, 3C507, StarLAN 10 etc.

#device lnc # NE2100, NE32-VL Lance Ethernet cards

#device sn # SMC's 9000 series of ethernet chips

#device xe # Xircom pccard ethernet

# ISA devices that use the old ISA shims

#device le

# Wireless NIC cards

#device wlan # 802.11 support

#device an # Aironet 4500/4800 802.11 wireless NICs.

#device awi # BayStack 660 and others

#device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs.

#device wl # Older non 802.11 Wavelan wireless NIC.

# Pseudo devices - the number indicates how many units to allocate.

device random # Entropy device

device loop # Network loopback

device ether # Ethernet support

#device sl # Kernel SLIP

#device ppp # Kernel PPP

#device tun # Packet tunnel.

device pty # Pseudo-ttys (telnet etc)

device md # Memory "disks"

#device gif # IPv6 and IPv4 tunneling

#device faith # IPv6-to-IPv4 relaying (translation)

# The `bpf' device enables the Berkeley Packet Filter.

# Be aware of the administrative consequences of enabling this!

device bpf # Berkeley packet filter

# USB support

#device uhci # UHCI PCI->;USB interface

#device ohci # OHCI PCI->;USB interface

#device usb # USB Bus (required)

#device udbp # USB Double Bulk Pipe devices

#device ugen # Generic

#device uhid # "Human Interface Devices"

#device ukbd # Keyboard

#device ulpt # Printer

#device umass # Disks/Mass storage - Requires scbus and da

#device ums # Mouse

#device urio # Diamond Rio 500 MP3 player

#device uscanner # Scanners

# USB Ethernet, requires mii

#device aue # ADMtek USB ethernet

#device axe # ASIX Electronics USB ethernet

#device cue # CATC USB ethernet

#device kue # Kawasaki LSI USB ethernet

# FireWire support

#device firewire # FireWire bus code

#device sbp # SCSI over FireWire (Requires scbus and da)

#device fwe # Ethernet over FireWire (non-standard!)

修改配置完新内核配置文件DRAGONSON后,保存退出,并执行命令如下:

www#cd /usr/src

www#make kernel KERNCONF=DRAGONSON

接下来,屏幕就哗哗哗出现编译的过程,感觉很爽,这个时候,你可以上趟厕所放松放松了。过个10分钟左右,再回来继续我们的过程。若编译错误,自己到www.chinaunix.net和www.linuxsir.com求助,若编译成功,继续我们的旅行。

现在重新启动机器,让我们的新内核生效。执行命令如下:

www#shutdown –r now

启动机器后,继续ssh登陆到服务器上,执行命令

www#dmesg

屏幕会出现如下内容:

Copyright (c) 1992-2003 The FreeBSD Project.

Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994

The Regents of the University of California. All rights reserved.

FreeBSD 5.1-RELEASE #0: Tue Aug 5 22:15:55 CST 2003

peng@www.dragonson.org:/usr/obj/usr/src/sys/DRAGONSON

Preloaded elf kernel "/boot/kernel/kernel" at 0xc03b1000.

Preloaded elf module "/boot/kernel/acpi.ko" at 0xc03b11f4.

Timecounter "i8254" frequency 1193182 Hz

Timecounter "TSC" frequency 1135232213 Hz

CPU: AMD Athlon(tm) processor (1135.23-MHz 686-class CPU)

Origin = "AuthenticAMD" Id = 0x644 Stepping = 4

Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>;

AMD Features=0xc0440000<RSVD,AMIE,DSP,3DNow!>;

real memory = 268369920 (255 MB)

avail memory = 256720896 (244 MB)

Pentium Pro MTRR support enabled

npx0: <math processor>; on motherboard

npx0: INT 16 interface

acpi0: <VIA694 AWRDACPI>; on motherboard

pcibios: BIOS version 2.10

Using $PIR table, 6 entries at 0xc00fdf10

acpi0: power button is handled as a fixed feature programming model.

Timecounter "ACPI-fast" frequency 3579545 Hz

acpi_timer0: <24-bit timer at 3.579545MHz>; port 0x4008-0x400b on acpi0

acpi_cpu0: <CPU>; on acpi0

acpi_button0: <Power Button>; on acpi0

acpi_button1: <Sleep Button>; on acpi0

pcib0: <ACPI Host-PCI bridge>; port 0x5000-0x500f,0x4080-0x40ff,0x4000-0x407f,0xcf8-0xcff on acpi0

pci0: <ACPI PCI bus>; on pcib0

agp0: <VIA Generic host to PCI bridge>; mem 0xe8000000-0xebffffff at device 0.0 on pci0

pcib1: <PCI-PCI bridge>; at device 1.0 on pci0

pci1: <PCI bus>; on pcib1

pci1: <display, VGA>; at device 0.0 (no driver attached)

vr0: <VIA VT6102 Rhine II 10/100BaseTX>; port 0xd000-0xd0ff mem 0xef000000-0xef0000ff irq 11 at device 10.0 on pci0

vr0: Ethernet address: 00:05:5d:a5:3e:21

miibus0: <MII bus>; on vr0

ukphy0: <Generic IEEE 802.3u media interface>; on miibus0

ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto

pci0: <simple comms>; at device 11.0 (no driver attached)

isab0: <PCI-ISA bridge>; at device 17.0 on pci0

isa0: <ISA bus>; on isab0

atapci0: <VIA 8233 UDMA100 controller>; port 0xd800-0xd80f at device 17.1 on pci0

ata0: at 0x1f0 irq 14 on atapci0

ata1: at 0x170 irq 15 on atapci0

pci0: <serial bus, USB>; at device 17.2 (no driver attached)

pci0: <serial bus, USB>; at device 17.3 (no driver attached)

pci0: <serial bus, USB>; at device 17.4 (no driver attached)

pci0: <multimedia, audio>; at device 17.5 (no driver attached)

atkbdc0: <Keyboard controller (i8042)>; port 0x64,0x60 irq 1 on acpi0

atkbd0: <AT Keyboard>; flags 0x1 irq 1 on atkbdc0

sc0: <System console>; on isa0

sc0: VGA <4 virtual consoles, flags=0x200>;

vga0: <Generic ISA VGA>; at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0

Timecounters tick every 10.000 msec

acpi_cpu: throttling enabled, 2 steps (100% to 50.0%), currently 100.0%

ad0: 39266MB <IC35L040AVVA07-0>; [79780/16/63] at ata0-master UDMA100

Mounting root from ufs:/dev/ad0s3a

uhci0: <VIA 83C572 USB controller>; port 0xdc00-0xdc1f irq 11 at device 17.2 on pci0

usb0: <VIA 83C572 USB controller>; on uhci0

usb0: USB revision 1.0

uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1

uhub0: 2 ports with 2 removable, self powered

uhci1: <VIA 83C572 USB controller>; port 0xe000-0xe01f irq 11 at device 17.3 on pci0

usb1: <VIA 83C572 USB controller>; on uhci1

usb1: USB revision 1.0

uhub1: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1

uhub1: 2 ports with 2 removable, self powered

uhci2: <VIA 83C572 USB controller>; port 0xe400-0xe41f irq 11 at device 17.4 on pci0

usb2: <VIA 83C572 USB controller>; on uhci2

usb2: USB revision 1.0

uhub2: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1

uhub2: 2 ports with 2 removable, self powered

www#

注意观察,屏幕第5行出现了usr/obj/usr/src/sys/DRAGONSON

其中DRAGONSON就是我们的新内核名,说明新内核装载成功。

5.安装mysql数据库

国内外很多著名的论坛程序,比如vbb,ipb,phpbb,discuz都需要mysql数据库的支持,php+apache+mysql的组合是免费建站的最佳搭档。我们可以去官方网站www.mysql.com下载源代码包进行编译安装。现在官方网站推荐的是mysql-4.0.14.tar.gz版本。

我的站点下载地址为http://www.dragonson.org/soft/mysql-4.0.14.tar.gz

官方下载地址为

http://www.mysql.com/downloads/d ... .gz&pick=mirror

我们先建立增加一个mysql的数据库用户和一个存放源代码包的目录,执行命令如下:

www#pw groupadd mysql

www#pw useradd mysql –g mysql –s /nonexistent

www#mkdir /usr/home/peng/src

下载后通过cuteftp上传到/usr/home/peng/src目录,继续执行如下命令:

www#cd /usr/home/peng/src

www#tar –zvxf mysql-4.0.14.tar.gz

www#cd mysql-4.0.14

继续执行如下命令:

www#./configure --prefix=/usr/local/mysql

www#make

www#make install

www#./scripts/mysql_install_db

修改如下文件以及文件夹权限,否则mysql不能正常启动

www#chown –R root /usr/loca/mysql

www#chgrp –R mysql /usr/local/mysql

www#chown –R root /usr/local/mysql/bin

www#chgrp –R mysql /usr/local/mysql/bin

www#chown –R root /usr/local/mysql/var

www#chgrp –R mysql /usr/local/mysql/var

www#chmod 777 /usr/local/mysql/var

www#chown –R root /usr/local/mysql/var/mysql

www#chgrp –R mysql /usr/local/mysql/var/mysql

www#chmod 777 /usr/local/mysql/var/mysql

www#chown –R root /usr/local/mysql/var/mysql/*

www#chgrp –R mysql /usr/local/mysql/var/mysql/*

www#chmod 777 /usr/local/mysql/var/mysql/*

www#chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a

www#/usr/local/mysql/bin/mysqld_safe --user=mysql &

6.安装apache服务器

去以下地址下载源代码包,并用cuteftp上传至/usr/home/peng/src目录下,apache官方网站为www.apache.org

官方网站下载地址:http://apache.te8.com/dist/httpd/httpd-2.0.47.tar.gz

我的站点下载地址:http://www.dragonson.org/soft/httpd-2.0.47.tar.gz

接着,执行如下命令:

www#cd /usr/home/peng/src

www#tar –zvxf httpd-2.0.47.tar.gz

www#cd httpd-2.0.47

www#./configure --prefix=/usr/local/apache --enable-so

www#make

www#make install

7.安装php脚本支持

去以下地址下载源代码包,并用cuteftp上传至/usr/home/peng/src目录下,php官方网站为www.php.net

官方网站下载地址:http://cn2.php.net/get/php-4.3.2.tar.bz2/from/a/mirror

我的站点下载地址:http://www.dragonson.org/soft/php-4.3.2.tar.bz2

接着,执行如下命令:

www#cd /usr/home/peng/src

www#tar –jvxf php-4.3.2.tar.bz2

www#cd php-4.3.2

www#./configure --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --enable-pic --enable-inline-optimiation --enable-memory-limit --enable-bcmath --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal --with-config-file-path=/usr/local/apache/conf

www#make

www#make install

www#cp php.ini-dist /usr/local/apache/conf/php.ini

8.修改apache以及php的配置文件

首先配置apache服务器,这里有两种配置方式。

第一种是基于IP的配置方式,假如我的服务器IP为202.4.142.209。执行如下命令:

www#vi /usr/local/apache/conf/httpd.conf

(1)查找 #Listen 12.34.56.78:80 行,将该行下面的内容修改为

Listen 202.4.142.209:80 #此处为您服务器的IP地址

#Listen []:80

(2)查找LoadModule php4_module modules/libphp4.so 行,在下面添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php .php3

AddType application/x-httpd-php .phtml

AddType application/x-httpd-php-source .phps

这样就可以支持php脚本

(3)查找ServerAdmin you@your.address,将那行内容更改为ServerAdmin tahaomei@163.com #您的邮箱地址。

(4)查找DocumentRoot "/usr/local/apache/htdocs",将那行内容更改为DocumentRoot "/usr/home/peng/web" #您放网页内容的地址。

(5)查找DirectoryIndex index.html index.html.var,将那行内容更改为DirectoryIndex index.html index.html.var index.php index.php3 index.phtml index.htm

(6)查找AddDefaultCharset ISO-8859-1,将那行内容更改为AddDefaultCharset gb2312

保存后退出,至此第一种配置apache的方法完毕,你以后可以通过IP来访问你的网站地址,也可以申请一个国际域名,比如我申请的是万网www.net.cn的域名www.dragonson.org,使用万网提供的DNS服务器来将域名www.dragonson.org 解析到我的IP 202.4.142.209上来,就可以通过www.dragonson.org来访问我的网站了。

下面我们来介绍第二种配置方法,现在我想让www.dragonson.org这个域名来指向我的网站首页,而用bbs.dragonson.org这个域名来指向我的discuz论坛,就要执行如下命令:

www#vi /usr/local/apache/conf/httpd.conf

(1)查找 #Listen 12.34.56.78:80 行,将该行下面的内容修改为

Listen 202.4.142.209:80 #此处为您服务器的IP地址

#Listen []:80

(2)查找LoadModule php4_module modules/libphp4.so 行,在下面添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php .php3

AddType application/x-httpd-php .phtml

AddType application/x-httpd-php-source .phps

这样就可以支持php脚本

(3)查找ServerAdmin you@your.address,在该行最前面添加#,注销该行内容

(4)查找DocumentRoot "/usr/local/apache/htdocs",在该行最前面添加#,注销该行内容

(5)查找DirectoryIndex index.html index.html.var,将那行内容更改为DirectoryIndex index.html index.html.var index.php index.php3 index.phtml index.htm

(6)查找AddDefaultCharset ISO-8859-1,将那行内容更改为AddDefaultCharset gb2312

(7)查找#NameVirtualHost *,将那行内容更改为NameVirtualHost 202.4.142.209 #我的服务器IP地址

(8)查找

#<VirtualHost *>;

# ServerAdmin webmaster@dummy-host.example.com

# DocumentRoot /www/docs/dummy-host.example.com

# ServerName dummy-host.example.com

# ErrorLog logs/dummy-host.example.com-error_log

# CustomLog logs/dummy-host.example.com-access_log common

#</VirtualHost>;

在下面添加如下内容:

<VirtualHost 202.4.142.209>; #<>;内的IP为服务器IP

ServerAdmin tahaomei@163.com #管理员信箱

DocumentRoot /usr/home/peng/web #网站首页的地址

ServerName www.dragonson.org #网站首页的域名

ErrorLog logs/www.dragonson.org-error_log #网站的错误日志

CustomLog logs/www.dragonson.org-access_log common

</VirtualHost>;

<VirtualHost 202.4.142.209>; #<>;内的IP为服务器IP

ServerAdmin tahaomei@163.com #管理员信箱

DocumentRoot /usr/home/peng/web/discuz #discuz论坛的地址

ServerName bbs.dragonson.org #discuz论坛的域名

ErrorLog logs/bbs.dragonson.org-error_log #discuz论坛的错误日志

CustomLog logs/bbs.dragonson.org-access_log common

</VirtualHost>;

保存后退出,至此第二种配置apache的方法完毕,你以后可以通过IP来访问你的网站地址,也可以申请一个国际域名,比如我申请的是万网www.net.cn的域名www.dragonson.org,使用万网提供的DNS服务器来将www.dragonson.org和bbs.dragonson.org两个域名都解析到我的IP 202.4.142.209上来,就可以通过www.dragonson.org来访问我的网站首页,也可以通过bbs.dragonson.org来访问我的discuz论坛了。

接下来,我们继续进行php.ini文件的配置工作,执行如下命令:

www#vi /usr/local/apache/conf/php.ini

(1)查找max_execution_time = 30,更改为max_execution_time = 600

(2)查找max_input_time = 60,更改为max_input_time = 600

(3)查找memory_limit = 8M ,更改为memory_limit = 20M

(4)查找display_errors = On,更改为display_errors = Off

(5)查找register_globals = Off,更改为register_globals = On

(6)查找post_max_size = 8M,更改为post_max_size = 20M

(7)查找upload_max_filesize = 2M,更改为upload_max_filesize = 20M

(8)查找session.auto_start = 0,更改为session.auto_start = 1

执行:wq!命令保存后退出,从而完成了php.ini文件的配置工作。

9.让apache+mysql开机后自动运行

服务器总是有重新启动的时候,为了避免每次开机后手动启动apache、mysql服务的麻烦,我们最好让apache、mysql服务开机后自动启动。执行如下命令:

首先,产生apache服务启动脚本:

www#cd /usr/local/etc/rc.d

www#vi apache.sh

添加如下内容:

/usr/local/apache/bin/apachectl start &

执行:wq!命令保存后退出,并执行如下命令:

www#chmod 777 apache.sh

接着,产生mysql服务启动脚本:

www#vi mysql.sh

添加如下内容:

/usr/local/mysql/bin/mysqld_safe &

执行:wq!命令保存后退出,并执行如下命令:

www#chmod 777 mysql.sh

现在该重新启动机器让apache、mysql服务自动启动了,执行命令如下

www#shutdown –r now

过几分钟,机器重新启动后,继续通过ssh客户端软件远程登陆到服务器上。这个时候,apache、mysql应该是启动了的,我们先别管这些,继续进行ZendOptimizer的安装过程。

10. ZendOptimizer的安装

ZendOptimizer通过优化php代码来提高php程序的执行速度,一般情况下,执行使用ZendOptimizer的php程序比不使用的要快40%到100%。ZendOptimizer程序是免费的,大家可以到官方网站www.zend.com下载。下面是我提供的两个下载地址。

官方网站下载:http://www.zend.com/store/getfreefile.php?pid=13&zbid=547

我的站点下载:http://www.dragonson.org/soft/ZendOptimizer-2[1].1.0b-FreeBSD4.0-i386.tar.gz

下载后通过cuteftp上传到/usr/home/peng/src目录下,执行如下命令,出现下面安装界面:

www#cd /usr/home/peng/src

www#tar –zvxf ZendOptimizer-2[1].1.0b-FreeBSD4.0-i386.tar.gz

www#cd ZendOptimizer-2.1.0b-FreeBSD4.0-i386

www#sh ./install.sh

选择OK,接下来会出现接受协议的窗口,照要求做就可以了,然后会出现如下的窗口,

选择Zend的安装路径,填写为/usr/local/Zend,按Tab键选择OK继续,会出现如下窗口:

确定php.ini文件位置,填入/usr/local/apache/conf,按Tab键选择OK继续,见下图:

问我们是不是apache服务器,选择YES,会出现如下窗口:

叫我们指定apache的bin目录,输入/usr/local/apache/bin,按Tab键选择OK,以后一路OK,OK,很顺利,安装过程结束的时候会重新启动apache服务。现在我们来查看一下我们服务器的配置到底是如何的?执行如下命令:

www#cd /usr/home/peng/web

www#vi info.php

输入如下内容:

<?php

phpinfo();

?>;

按:wq!保存退出。

在IE浏览器里输入http://www.dragonson.org/info.php,则可以看到服务器的详细配置信息,其中就有Zend安装成功的标志。见下图:

11. phpMyAdmin的安装

phpMyAdmin是比较好的通过web访问方式来管理数据库的免费程序,我们可以通过以下地址来下载。

国外网站下载:

http://prdownloads.sourceforge.n ... php.tar.gz?download

我的站点下载:http://www.dragonson.org/soft/phpMyAdmin-2.5.1-php.tar.gz

下载该程序后,通过cuteftp上传到/usr/home/peng/src目录下,执行如下命令:

www#cd /usr/home/peng/src

www#cp phpMyAdmin-2.5.1-php.tar.gz /usr/home/peng/web

www#cd /usr/home/peng/web

www#tar –zvxf phpMyAdmin-2.5.1-php.tar.gz

www#mv –fi phpMyAdmin-2.5.1 phpmyadmin

www# cd phpmyadmin

www#vi config.inc.php

修改config.inc.php文件如下:

(1)查找$cfg['PmaAbsoluteUri'] = ''; ,将该行内容更改为$cfg['PmaAbsoluteUri'] = 'http://202.4.142.209/phpmyadmin/';

执行:wq!命令保存退出,在IE浏览器里输入http://202.4.142.209/phpmyadmin/,会出现如下图:

请注意阅读上图中的红色文字,默认的mysql数据库用户名root是没有密码的,这是一个安全漏洞,所以我们要修改数据库的密码,请执行如下步骤:

(2)点上图中的“权限”,进入如下图

在上图中,勾选三个用户,只剩下一个用户名为root,主机为localhost的,然后点“执行”来删除那三个勾选的用户,删除后的图如下:

只剩下一个root用户了,勾选它,点“编辑”,进入下图

点“更改密码”下面的“密码”前的圆圈,选择它,然后敲入你的mysql数据库密码(比如abc),再点“执行”。这样mysql的数据库密码就改变了。当然了,我们也可以通过phpmyadmin来创建新的mysql数据库名,用户名等等,这些功能就要你自己去探索了。我们再点IE浏览器里的“刷新”来刷新该页面,就会出现无法访问的情况,如下图所示:

出现上面的情况后,也不要着急,我们可以修改phpmyadmin的配置文件config.inc.php来解决这个问题,执行如下命令:

www#vi config.inc.php

更改内容如下:

(3)查找$cfg['Servers'][$i]['auth_type'] = 'config';

更改为$cfg['Servers'][$i]['auth_type'] = 'http';

然后重新在IE浏览器里输入http://202.4.142.209/phpmyadmin/ 访问,会出现如下的图:

敲入用户名“root”和密码后,点“确定”,就可以重新进入到phpmyadmin管理页面拉,见下图:

至此,phpmyadmin安装完毕。下面我们继续进行本文的最后一部分,discuz论坛的安装。

12.discuz论坛的安装

用过众多的php+mysql论坛程序,比如vbb,ipb,phpbb,discuz。毫无疑问,vbb是最好的php+mysql程序,人家老外做的商业程序,好象卖的价格是几百美金吧,如果咱们钱多的荒地话,尽管去买个,不过买的是外文版本,不符合中国人的国情,国内做vbb汉化最好的是www.cnvbb.com,以前最好的是www.chinavbb.com,不过由于众多原因不做汉化拉。

大家可以去www.cnvbb.com下载最新的vbb汉化版本来测试测试。

如果你真正想把论坛做大,要么你买个正式版本,要么推荐你使用非vbb论坛程序。落伍者论坛www.im286.com以前采用的是vbb论坛程序,结果等论坛人气上升到每天好几百人在线,老外的一封律师信就发到你手上了,现在落伍换成了discuz程序。

听说ipb是速度最快、安全性最高的国外免费论坛程序,不过感觉后台控制里面的模板管理没vbb方便,您也可以去官方网站http://www.invisionpower.com去下载,可以免费使用。

用phpbb很少,也是国外的免费程序之一,www.chinaunix.net用的就是phpbb程序,大家可以去官方网站http://www.phpbb.com下载。

我个人推荐使用国产货discuz论坛,大家都支持一下国货。其官方论坛地址为www.discuz.net,无须汉化,discuz2.0版本是free的,论坛程序执行速度快,功能基本够用。后台管理也不错,不过我更喜欢vbb后台模板管理功能,因为vbb的模板基本上是html代码,而discuz的模板里大部分是php代码,不适合php新手来修改模板内容。此外,我们建站所需要的源代码都是free的,我们要高唱“我宁愿免费到底,也不愿。。。”。

哈哈,还是废话少说,免得有打广告之嫌。你可以通过以下两个地址来下载discuz2.0-gb2312版本。

官方下载地址:(需注册)http://www.discuz.net/viewthread.php?tid=21660&fpage=1

我的下载地址:http://www.dragonson.org/soft/gb2312.rar 。

下载后,在windows系统下用winrar解压缩后,通过cuteftp上传解压后文件夹里面的Discuz!目录至/usr/home/peng/web目录下,并更名为discuz。现在在IE浏览器里,输入http://202.4.142.209/phpmyadmin/ 进入数据库管理页面,并创建一个新的数据库名discuz,见下图:

然后执行如下命令:

www#cd /usr/home/peng/web/discuz

www#vi config.php

修改内容如下:

(1) 查找$dbuser = 'dbuser'; ,更改为$dbuser = 'root';

(2) 查找$dbpw = 'dbpw'; ,更改为$dbpw = '您的数据库密码';

(3) 查找$adminemail = 'admin@domain.com'; ,更改为$adminemail = 'tahaomei@163.com';

(4) 查找$tablepre = 'cdb_'; ,更改为$tablepre = '';

按:wq!保存退出,执行如下命令:

www#chmod 777 config.php

www#chmod 777 ./templates

www#chmod 777 ./attachments

www#chmod 777 ./forumdata

www#chmod 777 ./forumdata/templates

www#chmod 777 ./forumdata/cache

在IE浏览器里输入http://202.4.142.209/discuz/install.php,出现如下安装图示:

点“我安全同意”,进入下图:

点“保存配置信息”,进入下图:

输入管理员用户名、Email地址、密码,点‘开始安装Discuz!’,会出现安装成功页面,刷新一下页面后,执行命令www#rm –rf install.php 来删除install.php文件

安装成功后的discuz论坛页面如下:

以下这个是discuz论坛的后台管理面板的摸板控制页面

如果你熟悉discuz的摸板,完全可以制作属于自己风格的discuz论坛,那就要看你的美工水准了。以下是我论坛www.dragonson.org的风格演示:

呵呵,至此我的教程全部完毕,罗嗦了点,但是如果您是一位从未接触过freebsd以及网站建设的新手,照着这个教程做就可以了,您很快就拥有属于自己的服务器和论坛。赶紧动手吧。

tahaomei

写于2003.8.9