一、最小化安装FreeBSD
略之。
二、设置ROOT用户密码,设置IP,并设置时区,系统时间
2.1 设置ROOT用户密码
sysinstall->Configure->Root Password[我设置了一个十四位的密码]
2.2 设置IP地址
sysinstall->Configure->Networking->Interface[选中后单击空格键],一般情况下选择第一个,例如:VM中为le0。按空格键继续。此时会出现一系列的对话框:
(1)是否使用IPv6地址 现在选择“No”;
(2)是否配置DHCP,如果你的电脑为自动被分派IP的就Y,否就N。一般选择N。
(3)开始配置IP::
Host:ftp.shenzhi.com Domain:shenzhi.com
IPv4 Address:192.168.0.205
选择OK,其余项有系统自动填充有不用填的。之后有一个对话框,问是否现在激活网卡。选Y。
重启生效。
2.3 设置时区
sysinstall->Configure->Time Zone->No[对话框]->5 Asia->9 China->1 east China...->Yes
2.4 设置系统时间
比如现在时间为:14:06 2009-10-12,则在命令行中输入:date 0910121406[年月日时分,均占用2位数字]
三、开通SSH服务
3.1 修改/etc/inetd.conf文件,把SSH服务打开,保存退出编辑/etc/rc.conf 最后加入:sshd_enable="yes"即可激活sshd服务。记得修改完配置文件后,重新启动sshd服务器(/etc/rc.d/sshd restart)即可。
3.2 备份将要修改的文件
#cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
3.3 编辑sshd_config文件
#vi /etc/ssh/sshd_config
,":set number"
对应行分别更改为:
42行:“#PermitRootLogin no” 改为:“PermitRootLogin yes” #允许root登录
43行:“#StrictModes yes” 改为:“StrictModes yes”
46行:“#RSAAuthentication yes” 改为:“RSAAuthentication yes”
56行:“#IgnoreUserKnownHosts no” 改为:“IgnoreUserKnownHosts yes”
58行:“#IgnoreRhosts yes” 改为:“IgnoreRhosts yes”
61行:“#PasswordAuthentication no” 改为:“PasswordAuthentication yes” # 设置是否使用口令验证。
62行:“#PermitEmptyPasswords no” 改为:“PermitEmptyPasswords no” #不允许空密码登录
93行:“#PrintMotd yes” 改为:“PrintMotd yes”
下面是我的配置文件:(/etc/ssh/sshd_config)
#/etc/rc.d/sshd start
四、LAMP服务环境安装
以famp4.0.2中所提供的软件和脚本为基础。
4.1 通过SSH工具将famp4.0.2.tar上传到/usr目录,因为此目录所在的分区较大。
4.2 解压缩:#tar zxvf famp4.0.2
4.3 安装perl
cd perl
./configure.gnu -de --prefix=/usr/local/perl -Dusedevel
make
make install clean
ln -s /usr/local/perl/bin/perl5.9.5 /usr/bin/perl
4.4 安装make->...->MySQL
cd ../make
./configure --prefix=/usr/local/make
make; make install clean
cd ../jpeg-6b
./configure --prefix=/usr/local/jpeg CFLAGS=' -O2 -I$(srcdir) -fPIC'
make
mkdir -p /usr/local/jpeg/lib
mkdir -p /usr/local/jpeg/bin
mkdir -p /usr/local/jpeg/include
mkdir -p /usr/local/jpeg/man/man1
make install
make install-lib
make clean
cd ../libpng
./configure --prefix=/usr/local/libpng
make
make install clean
cd ../libxml
./configure --prefix=/usr/local/libxml
make
make install clean
cd ../freetype
./configure --prefix=/usr/local/freetype
/usr/local/make/bin/make
/usr/local/make/bin/make install clean
cd ../gd
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
/usr/local/make/bin/make
/usr/local/make/bin/make install clean
cd ../mysql
./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=all --enable-thread-safe-client --without-debug --with-mysqld-ldflags=-all-static
make
make install clean
pw useradd mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root /usr/local/mysql/.
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp ../my-huge.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld_safe --user=mysql &
ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib/
cp ../mysql.sh /etc/rc.d/mysql.sh
ln -s /etc/rc.d/mysql.sh /mysql-start
cp ../mysql-stop /usr/local/mysql/
ln -s /usr/local/mysql/mysql-stop /mysql-stop
ln -s /usr/local/mysql/bin/mysql /bin/mysql
reboot
4.5 安装apache
没有使用原有的文件,而是下载了一个新版本的文件。因为原有的文件安装两次都是失败的,当我试图将网页的根目录由/root/wwwroot更改为/usr/local/www时,怀疑可以在编译时加入选项“--with-config-file-path=/usr/local/apache/conf”指定把apache的配制文件放在/usr/local/apache/conf中;比如httpd.conf配制文件就在这个目录中。
tar zxvf httpd-2.2.14.tar.gz
cd httpd-2.2.14
./configure --prefix=/usr/local/apache --enable-so --with-mpm=worker --enable-rewrite --enable-alias --enable-mods-shared=all
make
make install clean
mkdir -p /usr/local/www
chown -R root "/usr/local/www"
配置Apache:
修改/usr/local/apache/conf/httpd.conf
4.5.1
#ServerName www.example.com:80
ServerName 192.168.0.205:80
4.5.2ServerRoot "/usr/local/apache"[此处一般不修改]
4.5.3Listen 80[此处一般不修改]
4.5.4#ServerAdmin [email protected]
ServerAdmin [email protected]
4.5.5#DocumentRoot "/usr/local/apache/htdocs"
DocumentRoot "/usr/local/www"
4.5.6AddDefaultCharset utf8
保存退出。
添加虚拟目录[此处常用于phpMyAdmin的指向,当然也可用于其他,不过上述已经将phpMyAdmin放置于目录/usr/local/www中故不再设置]
如果你的phpMyAdmin位于/usr/local/下则设置:找到# Alias /webpath
/full/filesystem/path并在其下增添代码
注:以下代码是指向/usr/local/phpMyAdmin目录的,意思是在浏览器地址栏中输入:
http://localhost/phpMyAdmin即可访问服务器/usr/local/phpMyAdmin目录中的网页文件。
Alias /phpMyAdmin "/usr/local/phpMyAdmin"
<Directory "/usr/local/phpMyAdmin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
问题1:Apache启动时出现的:问题解决:
Starting httpd: (98)Address already in use: make_sock: could not bind
to address 0.0.0.0:80
no listening sockets available, shutting down
为什么apache不能重启
netstat -natup |grep 80 看看80端口是那个进程占用了
由于httpd 占有了80端口
kill
设置成开机自启动
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache/bin/apachectl start
这样每次重新启动系统以后,apache也会随系统一起启动
最后的手动修补操作:
#kldload accf_http
并将/boot/defaults/loader.conf中,以便下次启动自动装载模块
accf_data_load="YES"
accf_http_load="YES" 改了这一个就可以启动了。
否则在启动apache时会出现如下错误:[上述修补操作就是针对此的]
ftp# /usr/local/apache/bin/apachectl start
Warning: DocumentRoot [/home/wwwroot] does not exist
httpd not running, trying to start
[Mon Oct 12 09:08:25 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
4.6 安装PHP
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --disable-debug --with-libxml-dir=/usr/local/libxml --enable-mbstring --with-gd=/usr/local/gd --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-zlib --with-ttf --enable-gd-native-ttf --enable-ftp --without-iconv
make
make install clean
cp php.ini-recommended /usr/local/php/lib/php.ini
/usr/local/apache/bin/apachectl start
cd ..
cp -R phpmyadmin tz.php phpinfo.php /usr/local/www/
更改apache设置实现其对PHP的支持
# vi /usr/local/apache/conf/httpd.conf
找到 DirectoryIndex index.html
改为 DirectoryIndex index.html index.html.var index.htm index.php
找到 AddType application/x-gzip .gz .tgz
加 AddType application/x-httpd-php .php (注意空格)
AddType application/x-httpd-php-source .phps
[未操作]添加 AddDefaultCharset utf8 使apache默认支持utf8字符集
保存配置文件就重启apache 的守护进程。
/usr/local/apache/bin/apachectl restart(start/stop)
=================================================
重启apache
# /usr/local/apache/bin/apachectl restart
4.7 安装pure-ftpd
cd pure-ftpd
./configure --prefix=/usr/local/pureftpd --with-mysql --with-quotas --with-cookie --with-virtualhosts --with-virtualroot --with-diraliases --with-sysquotas --with-ratios --with-ftpwho --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=simplified-chinese
make
make install clean
pw groupadd ftpusers -g 2001
pw useradd ftp -u 2001 -g ftpusers -s /sbin/nologin
mkdir -p /usr/local/ftp
chown ftp /usr/local/ftp
chown -R root "/usr/local/ftp"
/usr/local/mysql/bin/mysql < ../pureftpd.sql
cp ../pureftpd.sh /etc/rc.d/
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
chmod 744 /usr/local/pureftpd/sbin/pure-config.pl
cp ../pureftpd-mysql.conf /usr/local/pureftpd/
cp ../pure-ftpd.conf /usr/local/pureftpd/
chmod 4711 /usr/local/pureftpd/sbin/pure-ftpwho
cp ../pureftpd.sh /usr/local/pureftpd/pureftpd-start
cp ../pureftpd-stop /usr/local/pureftpd/
cp ../pureftpd-restart /usr/local/pureftpd/
cp -R ../pureftpd_php_manager /usr/local/www/
/etc/rc.d/pureftpd.sh
ln -s /etc/rc.d/pureftpd.sh /pureftpd-start
ln -s /usr/local/pureftpd/pureftpd-stop /pureftpd-stop
ln -s /usr/local/pureftpd/pureftpd-restart /pureftpd-restart
更改:
/usr/local/www/pureftpd_php_manager/pureftp.config.php
改$DefaultDir = "/home/ftp/";为$DefaultDir = "/usr/local/ftp/";
4.8 在进入pureftpd_php_manager时出现以下错误:
Can't establish DB connection.
Access denied for user 'pureftpd'@'localhost' (using password: YES)
使用root用户,及MySQL密码登录到phpmyadmin后,Import ->选择pureftpd.sql导入数据库
[不对]更改一:
ftp# cp /usr/local/pureftpd/pureftpd-mysql.conf /usr/local/pureftpd/pureftpd-mysql.conf.bak
ftp# ee /usr/local/pureftpd/pureftpd-mysql.conf
改MYSQLPassword loveworking
为MYSQLPassword 850429
[不对]更改二:/usr/local/www/pureftpd_php_manager/pureftp.config.php
ftp# ee /usr/local/www/pureftpd_php_manager/pureftp.config.php
改$DefaultUser = "";为$DefaultUser = "pureftpd";
改$DefaultPass = "";为$DefaultPass = "850429";
改$DefaultDir = "/home/ftp/";为$DefaultDir = "/usr/local/ftp/";
4.9 zend安装编写脚本如下,设置成可执行属性,并放到famp4.0.2所在目录
######################################################################
cd FAMP
famp_hardware=`uname -m`
famp_version=`uname -r`
if [ $famp_hardware = "amd64" -a `echo $famp_version|cut -c1-1` = "6" ];then
cp -R ./zend_64 /usr/local/Zend
elif [ $famp_hardware = "amd64" -a `echo $famp_version|cut -c1-1` != "6" ];then
cp -R ./zend_64 /usr/local/Zend
cp -R ./famp_lib_files_64/* /lib/
echo 'compat6x_enable="YES"' >> /etc/rc.conf
elif [ $famp_hardware = "i386" -a `echo $famp_version|cut -c1-1` = "6" ];then
cp -R ./zend_32 /usr/local/Zend
else
cp -R ./zend_32 /usr/local/Zend
cp -R ./famp_lib_files_32/* /lib/
echo 'compat6x_enable="YES"' >> /etc/rc.conf
fi
######################################################################
ftp# ./install
The FAMP install completed, Thank you for use it!