之前按着网上的教程学着做过,但很久没玩之后现在已经记不太清楚了,得在找相关资料看着在学着做一次,然后决定用文字记录一下自己做的过程。
下载好FreeBSD 7.0的安装文件在VMware中安装完进入系统,接下来我要做的几件事情:
1.调试好系统的网络可以连能局域网同时能连通外网方便下载。
2.安装web server软件,考虑安装apache2.2.9。
3.安装php运行环境,并与apache2.2.9组合运行php.4.4.9程序。
1.调试网络
在命令模式下做如下设置:
# ifconfig em0 inet 192.168.0.212 netmask 255.255.255.0 up
# route add default 192.168.0.1
# vi /etc/rc.conf
defaultrouter="192.168.0.1" gateway_enable="YES" ifconfig_em0="inet 192.168.0.212 netmask 255.255.255.0"
# vi /etc/resolv.conf
nameserver 202.96.128.166 nameserver 61.144.56.101
也可以使用sysinstall命令进入到图形界面设置
2.安装apache
# tar -zxvf httpd-2.2.4.tar.gz
# cd httpd-2.2.4
# ./configure --prefix=/usr/local/apache2 --enable-shared=max --enable-module=rewrite --enable-module=so #配置Apache以共享后安装的模块
# make
# make install
开机自动启动httpd:
在/usr/local/etc/rc.d目录中编辑文件 apache_start.sh
#! /bin/sh
/usr/local/apache2/bin/httpd -k start
设置文件权限
# chmod +x apache_start.sh
在启动的时候报了一个错误:
httpd: Could not determine the server’s fully qualified domain name, using 192.168.0.212 for ServerName
google了一下解决办法是:
修改httpd.conf文件找到ServerName去掉前面的#注释,格式为是你的服务器的IP地址:端口号。
修改后为 ServerName 192.168.0.212:80 保存文件重启apache就不会报错了。
3.安装php.4.4.9
在官方:http://www.php.net下载php.4.4.9源代码包php-4.4.9.tar.gz
# tar -zxvf php-4.4.9.tar.gz
# cd php-4.4.9
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --disable-debug --disable-debug
# make
# make install
# vi /usr/local/apache2/conf/httpd.conf
在文件的最后添加
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps LoadModule php4_module modules/libphp4.so
# vi /usr/local/apache2/htdocs/phpinfo.php
<?php phpinfo(); ?>
在重启apache用浏览器打开http://192.168.0.212/phpinfo.php就可以解析php了。

0 Comments on “一次自学FreeBSD的过程”
Leave a Comment