FreeBSD学习笔记:让FreeBSD8.0运行在Dell PowerEdge T100上
1、下载FB8并安装
1.1分区规则如下:
挂载点 容量
/ 1G
swap 2G
/var 5G
/tmp 2G
/usr 10G
/home 40G
/data …
1.2安装类型:
Choose Distributions页面选择A Minimal
进入B Custom,在其中选择 man,src,ports,其中src选项要选择All全部安装。
SSH Login选择yes
添加一个用户到wheel组,其login shell为/bin/tcsh
2、采用PuTTY访问主机
暂略。
3、安装axel多线程下载工具
# cd /usr/ports/ftp/axel
# make install clean
# rehash
# ee /etc/make.conf(vi /etc/make.conf)
加入:
FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes
4、升级port系统
4.1设置一个比较快的portsnap服务器
#vi /etc/portsnap.conf
设置SERVERNAME=portsnap.cn.freebsd.org ,你可以设置相对你速度快点的服务器的地址。
4.2下载portsnap快照并解压
#portsnap fetch extract
4.3设置最快的ports镜像
修改 /etc/make.conf 加入以下代码:
MASTER_SITE_OVERRIDE=\
ftp://ftp.freebsdchina.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}\
ftp://ftp.cn.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}
5、编译内核
编译内核时,建议从服务器本机登录。
cp /usr/src/sys/i386/conf/GENERIC /etc/FB8
cd /usr/src/sys/i386/conf/
ln -s /etc/FB8 /usr/src/sys/i386/conf/
vi /usr/src/sys/i386/conf/FB8
cd /usr/src
make buildworld
make buildkernel KERNCONF=FB8
make installkernel KERNCONF=FB8
reboot
重新启动后进入单人模式
mount -u
mount -a
cd /usr/src
mergemaster -p
make installworld
mergemaster
内核编译失败的应急
重启机器到10秒读秒时按enter以外的任意键
unload
boot kernel.old 或其他可以启动的内核
6、安装并设置apache+mysql+php+FTP
6.1安装apache
whereis apache22
cd /usr/ports/www/apache22
make install clean
取消IPV6支持,其他保持默认选项。
rehash
vi /etc/rc.conf
添加以下内容:
#Apache22
apache22_enable=”YES”
保存退出并启动apache。
vi /usr/local/etc/apache22/httpd.conf
修改:ServerName 192.168.1.55:80
vi /etc/hosts
添加一行:
192.168.1.55 fb8.jthb.vicp.net fb8
/usr/local/etc/rc.d/apache22 start
6.2安装MySQL
whereis mysql50-server
cd /usr/ports/databases/mysql50-server/
make install clean
rehash
vi /etc/rc.conf
添加以下内容:
#MySQL5.0
mysql_enable=”YES”
保存退出并启动MySQL5.0
/usr/local/etc/rc.d/mysql-server start
检测MySQL是否正常运行
netstat -an | grep “3306″
ps -aux|grep mysql|grep -v grep
更改Mysql密码:
mysqladmin -u root password ‘123456′
(‘123456′)是你要设定的密码。
验证密码是否设定成功:
mysql -u root -p
Enter password:
6.3安装PHP5
whereis php5
cd /usr/ports/lang/php5/
make install clean
选项设定:
[X] APACHE Build Apache module
[X] MULTIBYTE Enable zend multibyte support
rehash
备份httpd.conf
cd /usr/local/etc/apache22/
cp httpd.conf httpd.conf.bak
编辑httpd.conf文件:
vi /usr/local/etc/apache22/httpd.conf
在AddType application/x-gzip .gz .tgz(大约354行)下面添加添加以下内容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
添加’index.php’ 到’DirectoryIndex’ 主目录索引:
DirectoryIndex index.php index.html index.htm
保存并退出。
6.4安装 PHP5-Extensions.
whereis php5-extensions
cd /usr/ports/lang/php5-extensions/
make install clean
选项设定:
[X] MYSQL MySQL database support
[X] PCRE Perl Compatible Regular Expression support
[X] POSIX POSIX-like functions
[X] SESSION session support
rehash
cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
/usr/local/etc/rc.d/apache22 restart
vi /usr/local/www/apache22/data/test.php
test.php内容如下:
<?
phpinfo();
?>
保存并退出,用浏览器打开http://yourip/test.php
6.5安装Pure-FTPd
whereis pure-ftpd
cd /usr/ports/ftp/pure-ftpd/
make with_language=simplified-chinese install
选项设定:
[X] MYSQL Support for users in MySQL database
[X] PRIVSEP Enable privilege separation
[X] PERUSERLIMITS Per-user concurrency limits
[X] THROTTLING Bandwidth throttling
[X] BANNER Show pure-ftpd welcome upon session start
[X] UTF8 Support for charset conversion (expreimental)
安装完成后刷新。
rehash
vi /etc/rc.conf
添加内容:
#Pure-FTPd
pureftpd_enable=”YES”
6.6为pure-ftpd创建一个MySQL数据库
cd /root/
fetch “http://machiel.generaal.net/files/pureftpd/v2.x/script.mysql”
vi /root/script.mysql
删除其中一行虚线————————
保存退出。
mysql -u root -p < /root/script.mysql
需要输入你的MySQL密码。
至此数据库创建完成。
数据内容:创建一个数据库Database:tpusers,Login = ftp Password = tmppasswd,管理权限用户名是:Administrator密码:tmppasswd(采用MD5加密)。
6.7配置Pure-FTPd
cd /usr/local/etc/
cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf
vi /usr/local/etc/pure-ftpd.conf
编辑pure-ftpd.conf文件,找到文件MySQLConfigFile位置和文件CreateHomeDir并修改如下:
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf
CreateHomeDir yes
保存后退出。
cd /usr/local/etc/
下载pureftpd-mysql.conf文件。
fetch http://machiel.generaal.net/files/pureftpd/v2.x/pureftpd-mysql.conf
/usr/local/etc/rc.d/pure-ftpd start
6.8安装 PureFTPd管理程序
whereis usermanager
cd /usr/ports/www/usermanager/
make install clean
rehash
cp /usr/local/etc/apache22/httpd.conf /usr/local/etc/apache22/httpd.conf.bak
vi /usr/local/etc/apache22/httpd.conf
添加以下内容:
Alias /ftp “/usr/local/www/data/UserManager/”
<Directory “/usr/local/www/data/UserManager”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
保存退出。
使用浏览器打开http://youripadderss/ftp/install.php
根据向导进行安装设定,语言选择中文,并且更改管理员密码。最后记得删除install.php文件。
完成后打开http://youripadderss/ftp/index.php登陆录后台设置页面,进行新增用户操作。
6.9为Pure-FTPd创建用户和查看用户状态
创建用户时需要手动指定FTP用户主目录。所以建立FTP用户时,需要先建立用户的FTP目录,并设置目录属性为nobody:guest
例如:建立一个用户名为sunny的用户,主目录为/home/ftp/demo
Shell:
mkdir -p /home/ftp/demo
chown nobody:guest demo
查看用户在线状态
通过’pure-ftpwho命令,查看在线用户状态。在/usr/local/www/apache22/cgi-bin目录下建立一个ftpstatus.c文件
Shell:
vi /usr/local/www/apache22/cgi-bin/ftpstatus.c
内容如下:
#include <stdlib.h>
int main(int argc, char *argv[])
{
system(“/usr/local/sbin/pure-ftpwho -H -w”);
return 0;
}
进行编译
Shell:
cc -Wall -o ftpstatus ftpstatus.c
chmod 755 ftpstatus
chmod ug+s ftpstatus
使用浏览器访问http://youripaddress.com/cgi-bin/ftpstatus查看在线FTP用户状
7、架设传真服务器
详见《FreeBSD学习笔记:搭建传真服务器》
8、架设mail send邮件服务器
详见《FreeBSD学习笔记:搭建邮件服务器》