/**********************************************
@desc:FreeBSD8.0+APACHE-2.2.15+MYSQL-5.1.45+PHP-5.3.2
@mail:unix1983@gmail.com 如果有遗漏请提示 3Q  ╮(╯3╰)╭       

@MSN:woody1983@live.cn
@Source 的获取:sf.net和官方网站 .tbz文件在BSD的安装盘里。    
/**********************************************

@note:安装前的准备    
@note:安装Perl 两种模式 两个版本 随意
Install perl5
(1) tbz files install mode
pkg_add perl-5.8.9_3.tbz

(2) Source Installation
tar zxvf perl-5.10.1.tar.bz2
cd perl-5.10.1
sh Configure -de
make
make test
make install
 
@note:gmake是安装freetype时需要的
Install gmake
pkg_add gmake-3.81_3.tbz
@两个依赖包和pkg的一个包放在同一个目录下
libiconv-1.13.1.tbz and gettext-0.17_1.tbz and pkg-config-0.23_1.tbz
 

Install MYSQL5.1.45-Source

@添加用户 Linux和UNIX的方式不一样 原理相通

@Linux 用户

shell> groupadd mysql
shell> useradd -g mysql mysql
+-------This is a FreeBSD8.0 add user'mode--------+
woody# adduser
Username: mysql
Full name: mysql
Uid (Leave empty for default):
Login group [mysql]:
Login group is mysql. Invite mysql5 into other groups? []:
Login class [default]:
Shell (sh csh tcsh nologin) [sh]: nologin
Home directory [/home/mysql]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]: yes
Lock out the account after creation? [no]:
Username   : mysql
Password   : <blank>
Full Name  : mysql
Uid        : 1003
Class      :
Groups     : mysql
Home       : /home/mysql
Home Mode  :
Shell      : /usr/sbin/nologin
Locked     : no
+--------------------------Step---------------------------+
shell> gunzip < mysql-5.1.45.tar.gz.tar.gz | tar -xvf -
shell> cd mysql-mysql-5.1.45
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> cp support-files/my-medium.cnf /etc/my.cnf
@note:my-medium.cnf 按需 copy
@change: 修改my.cnf文件 不修改也可以 这里只是修改数据库位置。
+my.cnf add a line ''+
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
.....略.....
datadir = /data/mysql
 
@Step:建数据库目录
shell> mkdir -p /data/mysql
+--------------------+
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql /data/mysql
@note:如果没有修改my.cnf的datadir位置 则执行:
@#shell> chown -R mysql var
@启动
shell> bin/mysqld_safe --user=mysql &
 
 
Step:Starting and Stopping MySQL Automatically
@note:开机自动启动
/etc/rc.local
/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'
 
 
 
Install APACHE2.2.15
 
Step 1
编译Apache的要求
  1. 磁盘空间
  2. ANSI- C编译器及编译环境
  3. 确保准确的时间
  4. Perl 5 [可选]
  5. apr/apr-util >= 1.2
apr和apr-util包含在Apache httpd的发行源代码中,并且在绝大多数情况下使用都不会出现问题。当然,如果apr或apr-util的1.0或1.1版本已经安装在你的系统中了, 则必须将你的apr/apr-util升级到1.2版本,或者将httpd单独分开编译。要使用发行源代码中自带的apr/apr-util源代码进行安 装,你必须手动完成:
@note: 编译和安装 apr 1.2
cd srclib/apr
./configure –prefix=/usr/local/apr/
make
make install
@note: 编译和安装 apr-util 1.2
cd ../apr-util
./configure –prefix=/usr/local/apr-util/ –with-apr=/usr/local/apr/
make
make install

Step2-1
tar zxvf httpd-2.2.15.tar.gz
ln -s httpd-2.2.15.tar.gz httpd
cd httpd

./configure --prefix=/usr/local/apache2 --enable-so \
--enable-mods-shared=most --with-mpm=worker
\
--with-mysql=/usr/local/mysql --enable-cache \
--enable-file-cache --enable-mem-cache 
\
--enable-disk-cache --enable-static-support
\
--disable-cgid --disable-cgi 
--with-apr=/usr/local/apr/  \
--with-apr-util=/usr/local/apr-util/
--with-perl \
--enable-module=rewrite

make
make install


PHP-support

@note:freetype的安装需 要gmake 先修改configure文件中的编译器
shell > tar zxvf freetype-2.2.1
shell > cd freetype-2.2.1

vi configure

if test "x$GNUMAKE" = x; then
  GNUMAKE= gmake
fi
./configure
gmake
gmake install

@note:其余的就容易了 该make的 该install的就那啥了...( ̄︶ ̄)↗

/usr/local/libjpeg
./configure --prefix=/usr/local/libjpeg

/usr/local/libpng
./configure --prefix=/usr/local/libpng

/usr/local/libxml2
./configure --prefix=/usr/local/libxml2

/usr/local/zlib
./configure --prefix=/usr/local/zlib


GD2
@note:make时如果出错的话 copy两个文件到gd当前目录下
@Error:
gd_png.c:16:53: error: png.h: No such file or directory
png.h:395:21: error: pngconf.h: No such file or directory
woody# cp /usr/local/libpng/include/png.h /usr/local/src/gd-2.0.35/
woody# cp /usr/local/libpng/include/pngconf.h /usr/local/src/gd-2.0.35/

tar zxvf gd-2.0.35.tar.gz

cd gd-2.0.35

./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg8 --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
make
make install
 
Install PHP-5.3.2 Released.
@note:5.3.2这个版本里貌似没有 --enable-so和--with-ttf 这两个选项了
 

./configure --prefix=/usr/local/php5  \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-gd=/usr/local/gd2 \
--enable-gd-native-ttf  \
--enable-gd-jis-conv \
--with-freetype-dir=/usr/local/freetype \
--with-jpeg-dir=/usr/local/jpeg8 \
--with-png-dir=/usr/local/libpng  \
--with-libxml-dir=/usr/local/libxml \
--with-zlib-dir=/usr/local/zlib \
--with-kerberos  --enable-xml \
--enable-mbstring --enable-sockets \
--enable-calendar 
 
make
make test #执行到这一步可以去看 看电影 泡杯茶之类的 (^。^)y-~~
make install
 
woody# cp /usr/local/src/php-5.3.2/ php.ini-production /usr/local/php5/lib/php.ini
@edit apache's httpd.conf
@checking:LoadModule php5_module        modules/libphp5.so
@Add:
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
 
 
炮 灰!!! ( ̄︶ ̄)↗ 涨
woody# du -h -d 1 /usr/local/src/
 52M    /usr/local/src/httpd-2.2.15
272M    /usr/local/src/mysql-5.1.45
106M    /usr/local/src/perl-5.10.1
 18M    /usr/local/src/freetype-2.2.1
9.6M    /usr/local/src/jpeg-8a
3.2M    /usr/local/src/zlib-1.2.4
6.3M    /usr/local/src/libpng-1.4.1
 59M    /usr/local/src/libxml2-2.7.2
217M    /usr/local/src/php-5.3.2
7.5M    /usr/local/src/gd2
 82M    /usr/local/src/ImageMagick-6.6.1-0
7.5M    /usr/local/src/gd-2.0.35
918M    /usr/local/src/

woody# du -h -d 1 /usr/local/
918M    /usr/local/src
138M    /usr/local/mysql
2.2M    /usr/local/apr
2.0M    /usr/local/apr-util
 17M    /usr/local/apache2
2.7M    /usr/local/bin
 74M    /usr/local/lib
 18M    /usr/local/man
6.7M    /usr/local/share
6.0K    /usr/local/etc
1.1M    /usr/local/include
1.2M    /usr/local/info
 50K    /usr/local/libdata
2.0K    /usr/local/libexec
2.0K    /usr/local/sbin
2.0K    /usr/local/www
2.5M    /usr/local/jpeg8
4.8M    /usr/local/freetype
306K    /usr/local/zlib
1.4M    /usr/local/libpng
 14M    /usr/local/libxml
1.3M    /usr/local/gd2
 24M    /usr/local/php5
 36M    /usr/local/apache
1.2G    /usr/local/