FreeBSD Lighttpd PHP MySQL

来自开放百科 - 灰狐
2010年8月21日 (六) 00:46Allen (讨论 | 贡献)的版本

跳转到: 导航, 搜索

在 FreeBSD 5.5, 6.1 上安装 Lightttpd,PHP,MySQL

FreeBSD 5.5

今天在一台跑 FreeBSD 5.5 的 Intel 至强服务器上成功安装 MySQL,PHP,Lighttpd等软件包, 现整理如下与大家分享. 随后还有在FreeBSD 上 Java 系统的安装等. (注意: 在FreeBSD下有 Packages , Ports 两种安装软件包的方式供用户选择)

1. install mysql 4.1 mysql41-client // version is 4.1.18

pkg_add -r mysql41-server

pkg_add -r mysql41-client

/usr/local/bin/mysql_install_db

chown -R mysql /var/db/mysql/

chgrp -R mysql /var/db/mysql/

/usr/local/bin/mysqld_safe -user=mysql &

/usr/local/bin/mysqladmin -u root password ‘newpassword’

2. install php4,并support fastcgi

cd /usr/ports/distfiles

fetch ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/php-4.4.2.tar.bz2

or http://download.freelamp.com/LAMP/

bunzip2 php-4.4.2.tar.bz2

tar xvf php-4.4.2.tar

./configure –enable-fastcgi –enable-force-cgi-redirect \
--with-mysql=/usr/local/mysql \
make
make install

— php -v

PHP 4.4.2 (cgi-fcgi) (built: Jun 23 2006 01:26:36) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

3. bind php4 and mysql (这步有问题,mysql的库总加载不上)

cd /usr/ports/databases/php4-mysql

make

make install

The following line has been added to your /usr/local/etc/php/extensions.ini

configuration file to automatically load the installed extension:

extension=mysql.so

4. install lighttpd

pkg_add -r lighttpd

touch /var/log/lighttpd.error.log

touch /var/log/lighttpd.access.log

chown www:www /var/log/lighttpd.*

config php.ini, lighttpd.conf

cd /usr/local/etc/

cp lighttpd.conf.sample lighttpd.conf

cp php.ini-recommended php.ini

修改 lighttpd.conf

server.modules = (

“mod_access”,

“mod_fastcgi”,

“mod_accesslog” )

server.document-root = “/usr/local/www/demo/”

fastcgi.server = ( “.php” =>

( “localhost” =>

(

“socket” => “/tmp/php-fastcgi.socket”,

“bin-path” => “/usr/local/bin” )))

测试:

touch test.php

phpinfo();

?>

  1. /usr/local/sbin/lighttpd -f /usr/local/etc/lighttpd.conf

或者

Usage: /usr/local/etc/rc.d/lighttpd [fast|force|one](start|stop|restart|rcvar|status|poll)

http://localhost/test.php

OK :)

————————————

FreeBSD 6.1

在 FreeBSD 6.1 上安装 Lightttpd,PHP, MySQL 过程异常简单

1. install mysql 5

tar zxvf mysql-5.5.5-m3.tar.gz

cd mysql-5.5.5-m3/

./configure --prefix=/usr/local/mysql-5.5.5-m3 --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg --with-charset=utf8 --localstatedir=/usr/local/mysql-5.5.5-m3/data --with-collation=utf8_general_ci

make && make install

出现的错误:

rm: libtoolT: No such file or directory

安装 libtool, autoconf, automake, bison 包, OK :)

cd /usr/ports/databases/mysql50-server

make install

后面步骤同上

2. install php5

需要的包以 prefix=/usr 的方式 configure, 可有效防止出现找不到包的问题.

tar zxvf php-5.2.14.tar.gz

gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1

cd php-5.2.14/

./configure --prefix=/usr/local/php-5.2.14 --with-config-file-path=/usr/local/php-5.2.14/etc --with-mysql=/usr/local/mysql-5.5.5-m3 --with-mysqli=/usr/local/mysql-5.5.5-m3/bin/mysql_config --with-iconv-dir=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap

make install

/libexec/ld-elf.so.1: Shared object "libmysqlclient.so.16" not found, required by "php"

ln /usr/local/mysql-5.5.5-m3/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

下载ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/php-5.1.2.tar.bz2

 ./configure –enable-fastcgi –enable-force-cgi-redirect --with-gd --with-zlib-dir=/usr/local\
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/bin/mysql_config 
make
make install

注意: 这时系统就支持图像验证码了,但要记着重新启动 Lighttpd

3. bind php5 and mysql (mysql的库加载成功)

cd /usr/ports/databases/php5-mysql

make

make install

cd /usr/ports/databases/php5-mysqli

make

make install

more /usr/local/etc/php/extensions.ini

extension=mysql.so
extension=mysqli.so

4. install lighttpd (同上)[[Category:Lighttpd]]

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱