前言
在家搭建网站作电子商务、FTP、论坛。。。
轻松实现心中梦想。。。。。。
本攻略以简洁为原则,不明白的可以,以此为线索继续学习。
第一章:最简安装FreeBSD6 RELEASE 第一张盘
第二章:默认安装sshd
第三章:升级到Stable
第四章:安装mysql
第五章:安装apache
第六章:安装PHP
第七章:安装openssl
第八章:申请LAN包年服务
第九章:申请DDNS服务、安装DDNS客户端软件
================
第一章:最简安装FreeBSD6 RELEASE 第一张盘
硬件要求只有一个:找一块intel 的服务器网卡
(其他略)
第二章:默认安装sshd
(略)
=====================================
第三章:升级到Stable
FreeBSD版本发展顺序:BETE-->RELEASE-->STABLE,CURRENT-->STABLE.
Shell> uname -a
FreeBSD
www.freeBSD.com 6.0-RELEASE FreeBSD 6.0-RELEASE #
0: Thu Nov 3 09:36:13 UTC 2005
root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386
STABLE是最稳定最适合生产的机器
1.port 安装 cvsup
Shell> cd /usr/ports/net/cvsup
Shell> make install clean
2.更新ports:
Shell> cp /usr/share/examples/cvsup/ports-supfile /root
Shell> vi /root/ports-supfile
*default host=cvsup2.FreeBSDchina.org
Shell> /usr/local/bin/cvsup -g -L 2 /root/ports-supfile
3.更新stable源代码:
Shell> cp /usr/share/examples/cvsup/stable-supfile /root
Shell> vi /root/stable-supfile
*default host=cvsup2.FreeBSDchina.org
*default release=cvs tag=RELENG_6
Shell> /usr/local/bin/cvsup -g -L 2 /root/stable-supfile
4.查看版本信息
Shell> uname -a
FreeBSD
www.freeBSD.com 6.0-RELEASE FreeBSD 6.0-RELEASE #
0: Thu Nov 3 09:36:13 UTC 2005
root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386
5.备份旧内核
Shell> cp -R /boot/kernel /boot/kernel.generic
Shell> cp -R /boot/modules /boot/modules.generic
6.编译内核
Shell> cd /usr/src/sys/i386/conf
Shell> cp GENERIC MYKERNEL
Shell> vi MYKERNEL
详见7
Shell> cd /usr/src
Shell> make buildkernel KERNCONF=MYKERNEL
Shell> make installkernel KERNCONF=MYKERNEL
Shell> reboot
Shell> uname -a
FreeBSD
www.freeBSD.com 6.0-STABLE FreeBSD 6.0-STABLE
#4: Tue Jan 17 00:41:24 CST 2006
root@
www.freeBSD.com:/usr/obj/usr/src/sys/MYKERNEL i386
7.内核配置
a.构架
machine i386 # 体系模型为i386
cpu I686_CPU # 支持Pentium Pro以及更高
ident MYKERNEL # 内核文件的名字
b.多处理器
#options SMP #对称多处理器内核
#options APIC_IO #对称(APIC) I/O
c.大内存
options MAXDSIZ="(512*1024*1024)" #最大内存
options MAXSSIZ="(512*1024*1024)" #最大堆栈
options DFLDSIZ="(512*1024*1024)" #默认内存
options NMBCLUSTERS="(500*64)" #网络缓冲 (并发数×64)这里32M
保留
device scbus # SCSI 总线(如果使用SCSI设备,必须有)
device da # Direct Access (硬盘)
屏蔽一下内容
makeoptions DEBUG=-g
SCSI控制器
SCSI外设
通过SCSI子系统接口的RAID控制器
RAID控制器
ISA以太网适配器
USB 以太网
IPv6
///////
启动信息
Shell> dmesg
===============================
第四章:安装mysql
a.编译安装
Shell> cd /usr/ports/databases/mysql50-server
Shell> make WITH_CHARSET=gbk WITH_XCHARSET=all SKIP_DNS_CHECK=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes
Shell> make install
Shell> make clean
Shell> make rmconfig
b.启动设置
Shell> cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
Shell> vi /etc/rc.conf
mysql_enable="YES"
Shell> /usr/local/share/mysql/mysql.server start
Shell> /usr/local/etc/rc.d/mysql-server.sh start
Shell> /usr/local/bin/mysqladmin -u root password 'password'
Shell> /usr/local/bin/mysql -u root -ppassword
Shell> /usr/local/bin/mysqladmin -u root shutdown -p
==============================
第五章:安装apache
Shell> cd /usr/ports/www/apache22
Shell> vi Makefile
WITH_MPM?= worker
Shell> make WITHOUT_IPV6=yes WITH_STATIC_SUPPORT=yes WITH_THREADS=yes
Shell> make install
Shell> vi /etc/rc.conf
apache22_enable="YES"
Shell> /usr/local/etc/rc.d/apache22.sh start
Shell> httpd -l
core.c
worker.c
http_core.c
mod_so.c
Shell> vi /usr/local/etc/apache22/httpd.conf
DocumentRoot "/app/www"
<Directory "/app/www">
#增加虚拟主机
Listen 8080
NameVirtualHost 192.168.0.8:8080
<VirtualHost 192.168.0.8:8080>
ServerAdmin
webmaster@dummy-host.example.com
DocumentRoot /app/www/admin
ServerName 10.0.0.2
ErrorLog logs/2-error_log
CustomLog logs/2-access_log common
</VirtualHost>
<Directory "/app/admin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
==================================
第六章:安装PHP
a.基本安装
Shell> cd /usr/ports/lang/php5
Shell> make install
Shell> vi /usr/local/etc/apache22/httpd.conf
AddType text/html .shtml #打开
AddOutputFilter INCLUDES .shtml #打开
Include etc/apache22/extra/httpd-mpm.conf #打开
AddType application/x-httpd-php .php #加入
AddType application/x-httpd-php-source .phps #加入
Shell> /usr/local/etc/rc.d/apache22.sh restart
Shell> echo "<? phpinfo(); ?>" >> /usr/local/www/data/info.php
Shell>ab -c 100 -n 3000
http://localhost/info.php
b.扩展安装
Shell> cd /usr/ports/lang/php5-extensions
Shell> make
Shell> make install FORCE_PKG_REGISTER=yes
=====================================
第七章: openssl
下载一个ssl.ca-1.0 辅助你生成证书
Shell> cd ssl.ca-1.0
ssl.ca-1.0: No such file or directory.
Shell> cd ssl.ca-0.1
Shell> new-root-ca.sh
No Root CA key round. Generating one
Generating RSA private key, 1024 bit long modulus
....................................................++++++
................................................++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:
Verifying - Enter pass phrase for ca.key:
Self-sign the root CA...
Enter pass phrase for ca.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:BJ
Locality Name (eg, city) [Sitiawan]:BJ
Organization Name (eg, company) [My Directory Sdn Bhd]:freeBSD.com
Organizational Unit Name (eg, section) [Certification Services Division]:www
Common Name (eg, MD Root CA) []:CEO
Email Address []:
www.freeBSD@gmail.com
Shell> new-server-cert.sh server
No server.key round. Generating one
Generating RSA private key, 1024 bit long modulus
...........................................++++++
.....++++++
e is 65537 (0x10001)
Fill in certificate data
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:BJ
Locality Name (eg, city) [Sitiawan]:BJ
Organization Name (eg, company) [My Directory Sdn Bhd]:freeBSD.com
Organizational Unit Name (eg, section) [Secure Web Server]:
www.freeBSD.com
Common Name (eg,
www.domain.com) []:CEO
Email Address []:
www.freeBSD@gmail.com
You may now run ./sign-server-cert.sh to get it signed
Shell> sign-server-cert.sh server
CA signing: server.csr -> server.crt:
Using configuration from ca.config
Enter pass phrase for ./ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName

RINTABLE:'CN'
stateOrProvinceName

RINTABLE:'BJ'
localityName

RINTABLE:'BJ'
organizationName :PRINTABLE:'freeBSD.com'
organizationalUnitName:PRINTABLE:'www.freeBSD.com'
commonName :PRINTABLE:'CEO'
emailAddress :IA5STRING:'
www.freeBSD@gmail.com'
Certificate is to be certified until Jan 18 10:32:17 2007 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
CA verifying: server.crt <-> CA cert
server.crt: OK
Shell> cp server.key /usr/local/etc/apache22/server.key
Shell> cp server.crt /usr/local/etc/apache22/server.crt
Shell> chmod 0400 /usr/local/etc/apache22/server.key
Shell> chmod 0400 /usr/local/etc/apache22/server.crt
Shell> vi /usr/local/etc/apache22/httpd.conf
Include etc/apache22/extra/httpd-ssl.conf #打开
Shell> vi usr/local/etc/apache22/extra/httpd-ssl.conf
#SSLPassPhraseDialog #屏蔽
<VirtualHost _default_:443>
DocumentRoot "/app/www" #修改
ServerName
www.example.com:443 #修改
ServerAdmin
you@example.com #修改
Shell> /usr/local/etc/rc.d/apache22.sh stop
Shell> /usr/local/etc/rc.d/apache22.sh start
第八章:申请LAN包年服务
(略)
第九章:申请DDNS服务、安装DDNS客户端软件
(略)
购买一个家用路由器