FreeBSD+Apache+PHP+Mysql快速安装
在FreeBSD5.4上进行快速安装。基本主旨是重要程序手工安装,插件和扩展等使用ports安装。
(可以先在本地下载,然后通过ssh上传到FreeBSD上;如果是直接在服务器上下载软件,必须先安装wget,可以使用ports安装,另外,建议安
装上lsof、m4、perl、automake、autoconf、bash、cvsup、vim、sudo等工具,便于后续安装)
下载基本核心包
apache_1.3.34.tar.gz
mysql-4.1.18.tar.gz
php-4.4.2.tar.gz
每个包都解包:
tar zxvf xxxx.tar.gz
安装Apache
apache默认进程无法满足我们高负荷的要求,修改同时开启进程数最大为2048,也可以自己手动修改
cd ./apache_1.3.34
mv src/include/httpd.h src/include/httpd.h.orig
sed -e "s/256/2048/" src/include/httpd.h.orig > src/include/httpd.h
./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite
make
make install
Apache其他设置:访问权限、日志、虚拟目录、虚拟主机、phpMyadmin等等
安装Mysql
cd ./mysql-4.1.18
./configure --prefix=/usr/local/mysql
useradd mysql
chsh -s /sbin/nologin mysql
scripts/mysql_install_db
cd /usr/local/mysql
chgrp -R mysql ./*
cd ./var
chgrp -R mysql ./*
chown -R mysql ./*
/usr/local/mysql/bin/mysqld_safe --user=mysql &
如果没有无错应该启动,有错误去看 /usr/loval/mysql/var/xxxx.err
另外,如果可能以后数据会比较多的话,那么建议把数据库放到一个空间比较大的分区,然后ln一个软链接过去。
比如我们的分区 /data 是个有40G空间的分区,那么我们想把Mysql的数据库放里面,那么我们就可以先关闭mysql:
/usr/local/mysql/bin/mysqladmin shutdown
mv /usr/local/mysql/var /data
ln -s /data/var /usr/local/mysql/var
然后启动mysql,发现运行正常,但是我们实际的数据已经在 /data/var 下面了。
mysql默认的配置文件是在数据库目录 /usr/local/mysql/var下面滴,所以我们复制一个配置文件过去:
cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql/var/my.cnf
重启生效果,以后修改配置直接修改/usr/local/mysql/var/my.cnf
Mysql其他设置:打开日志、数据同步、监控SQL执行速度、其他高负载设置
安装PHP
安装php模块支持的包
手工安装的扩展模块:
libiconv-1.10.tar.gz <iconv>
zlib-1.2.3.tar.gz <zlib>
上面两个包请自行google下载,或者任何途径,版本不应该低于上面所列。
以两包都执行:
tar zxvf xxxxx.tar.gz
编译:
./configure --prefix=/usr/local
make
make install
使用Ports安装的扩展模块:(如何使用Ports,请自行参考FreeBSD手册)
gettext-0.14.5.tar.gz <getText>
expat-2005-12-23.tar.gz <xml>
libxml2-2.6.22.tar.gz <dom/xml>
jpegsrc.v6b.tar.gz <gd>
libpng-1.2.8-config.tar.gz <gd>
freetype-2.1.10.tar.gz <gd>
curl-7.15.1.tar.gz <curl>
编译php
./configure --prefix=/usr/local/php --with-apxs=/usr/local/apache/bin/apxs \
--with-iconv --enable-mbstring --with-gd --with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local --with-freetype-dir=/usr/local --with-ttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib --with-dom=/usr/local --with-mysql=/usr/local/mysql \
--with-curl=/usr/local
make
make install
无误则成功,否则检查过程或包是否装全
修改 /usr/local/apache/conf/httpd.conf,添加:AddType application/x-httpd-php .php
写一文件 /usr/local/apachen/htdocs/phpinfo.php,里面加入:
<?phpinfo();?>
启动apachen: /usr/local/apachen/bin/apachectl start
无误则安装完成。
后续配置,请自行设定。
============================================
附:以上包介绍
curl-7.13.1_1 Non-interactive tool to get files from FTP, GOPHER, HTTP(S)
expat-1.95.8 XML 1.0 parser written in C
libxml Libxml2 is the XML C parser and toolkit developed for the Gnome project
gettext-0.14.1 GNU gettext package
jpeg-6b_3 IJG's jpeg compression utilities
libjpeg libjpeg 软件包包含 jpeg 库. 这些库使图形文件在联合图象专家组的标准上压缩.
libpng libpng is the official PNG reference library.
libiconv-1.9.2_1 A character set conversion library
libtool-1.5.10_1 Generic shared library support script (version 1.5)
m4-1.4.1 GNU m4
openldap-client-2.2.23 Open source LDAP client implementation
png-1.2.8_1 Library for manipulating PNG images
autoconf-2.59_2 Automatically configure source code on many Un*x platforms
automake-1.9.5 GNU Standards-compliant Makefile generator (version 1.9)
bash-3.0.16_1 The GNU Project's Bourne Again SHellcvsup-without-gui-16.1h_2 General network file distribution system optimized for CVS
libtool-1.5.10_1 Generic shared library support script (version 1.5)
lsof-4.74.2 Lists information about open files (similar to fstat(1))
m4-1.4.1 GNU m4
openldap-client-2.2.23 Open source LDAP client implementation
perl-5.8.6_2 Practical Extraction and Report Language
sudo-1.6.8.7 Allow others to run commands as root
vim-lite-6.3.62 Vi "workalike", with many additional features (Lite package
wget-1.8.2_7 Retrieve files from the Net via HTTP and FTP
//本文可能有误差,如果配置不成功,请仔细检查。
如果要了解在LAMP的配置,请参考:《Linux+Apache+PHP+Mysql快速安装》