首页 > 网站 > Apache > 正文

FreeBSD下Mysql5+Apache2+PHP5的安装

2024-08-27 18:22:37
字体:
来源:转载
供稿:网友
■ MySQL5 的安装
源代码:mysql-5.0.18.tar.gz
下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.18.tar.gz/from/http://mirror.vmmatrix.net/mysql/

安装
# tar -zxvf mysql-5.0.18.tar.gz
# cd mysql-5.0.18.tar.gz
# ./configure --prefix=/usr/local/mysql
# make
# make install

建立用户
# pw group add mysql
# pw user add mysql -g mysql

初始化表
# ./scripts/mysql_install_db --user=mysql

设置目录访问权限
# cd /usr/local/mysql
# chown -R root . (设定root可以访问/usr/local/mysql目录)
# chown -R mysql var (设定mysql用户能访问/usr/local/mysql/var目录,该目录中存放mysql的数据库文件)
# chown -R mysql var/. (设定mysql用户能访问/usr/local/mysql/var目录下的所有文件)
# chown -R mysql var/mysql/. (设定mysql用户能访问/usr/local/mysql/var/mysql目录下的所有文件)
# chgrp -R mysql . (设定mysql组能访问/usr/local/mysql目录)

运行
使用命令 # /usr/local/mysql/bin/mysqld_safe --user=mysql & 测试安装是否成功
如果显示
[1]
# Starting mysqld daemon with database from /usr/local/mysql/var
表示安装成功

操控命令
启动mysql #/usr/local/mysql/libexec/mysqld start
停止mysql #/usr/local/mysql/libexec/mysqld stop
重启mysql #/usr/local/mysql/libexec/mysqld restart

开机自动加载mysql服务
在/usr/local/etc/rc.d目录中编辑文件 mysql_start.sh ,内容如下
#! /bin/sh
/usr/local/mysql/bin/mysqld_safe &
设置文件权限为可执行
# chmod +x mysql_start.sh


■ Apache2 的安装
源代码:httpd-2.0.55.tar.gz
下载地址:http://cn2.php.net/get/php-5.1.2.tar.gz/from/cn.php.net/mirror

安装
# tar -zxvf httpd-2.0.55.tar.gz
# cd httpd-2.0.55
# ./configure  
? --prefix=/usr/local/apache2
? --enable-shared=max
? --enable-module=rewrite
? --enable-module=so
# make
# make install

操控命令
启动apache #/usr/local/apache/bin/httpd -k start
停止apache #/usr/local/apache/bin/httpd -k stop
重启apache #/usr/local/apache/bin/httpd -k restart

开机自动加载apache服务
在/usr/local/etc/rc.d目录中编辑文件 apache_start.sh
#! /bin/sh
/usr/local/apache/bin/httpd -k start
设置文件权限
# chmod +x apache_start.sh


■ PHP5 的安装
PHP5安装前需要先安装好需要使用的各类模块

libxml2安装
源代码:libxml2-2.6.22.tar.gz
安装
# tar -zxvf libxml2-2.6.22.tar.gz
# cd libxml2-2.6.22
# ./configure
# make
# make install

zlib安装
源代码:zlib-1.2.2.tar.gz
安装
# tar -zxvf zlib-1.2.2.tar.gz
# cd zlib-1.2.2
# ./configure
# make
# make install

libpng安装
源代码:libpng-1.2.8.tar.gz
安装
# tar -zxvf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
编辑 makefile 将 prefix 改为 prefix=/usr/local/libpng2
# make
# mkdir /usr/local/libpng2
# make install

jpeg安装
源代码:jpegsrc.v6b.tar.gz
安装
# tar -zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6 --enable-shared
# make
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# make install-lib
# make install

GD安装
源代码:gd-2.0.33.tar.gz
安装
# tar -zxvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure  
? --prefix=/usr/local/gd2
? --with-zlib
? --with-png=/usr/local/libpng2
? --with-jpeg=/usr/local/jpeg6
编辑 Makefile 231行左右 将
CPPFLAGS = -I/usr/local/jpeg6/include
改为
CPPFLAGS = -I/usr/local/jpeg6/include -I/usr/local/libpng2/include
# make
# make install

libiconv安装
源代码:libiconv-1.10.tar.gz http://ftp.gnu.org/pub/gnu...
安装
# tar -zxvf libiconv-1.10.tar.gz
# cd libiconv-1.10
# ./configure --prefix=/usr/local/libiconv
# make
# make install

将iconv.h连接到php的安装源程序中,否则会php make会出错,不知道为什么
# cd /usr/src/php-5.1.2/ext/iconv/
# link /usr/local/libiconv/include/iconv.h iconv.h


开始安装PHP5
源代码:php-5.1.2.tar.gz

安装
# tar -zxvf php-5.1.2.tar.gz
# cd php-5.1.2
# ./configure
? --prefix=/usr/local/php
? --with-apxs2=/usr/local/apache2/bin/apxs
? --with-xml
? --with-mysql=/usr/local/mysql
? --with-gd=/usr/local/gd2
? --with-zlib
? --with-jpeg-dir=/usr/local/jpeg6
? --with-png-dir=/usr/local/libpng2
? --with-iconv=/usr/local/libiconv
? --with-config-file-path=/usr/local/lib
? --disable-debug
? --enable-safe-mode
? --enable-trans-sid
? --enable-memory-limit
? --enable-short-tags
? --disable-posix
? --enable-exif
? --enable-ftp
? --enable-sockets

# make
# make install
# cp /usr/src/php-5.1.2/php.ini-dist /usr/local/lib/php.ini

整合apache与php
# vi /usr/local/apache2/conf/httpd.conf

添加
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php


虽然FreeBSD的ports很棒,可是自己编译一下,感觉比较好,呵呵,个人喜好。
 
来源:http://v5.jiayuan.org/blog/read.php?1
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表