• apache、php、mysql源码安装
    时间:2008-12-26   作者:佚名   出处:互联网

    libjpeg-devel-6b-33

    freetype-devel-2.1.9-6.el4

    zlib-devel-1.2.1.2-1.2

    libpng-devel-1.2.7-3.el4_5.1

    gd-devel-2.0.28-5.4E

    gd-2.0.28-5.4E

    glibc-devel-2.3.4-2.39

    gcc-3.4.6-9

    glibc-kernheaders-2.4-9.1.100.EL

    glibc-headers-2.3.4-2.39

    以前软件最好去linux镜像中去找,这样就不需要为版本的不兼容麻烦了。

    首先下载我们所需要的安装包

    1. httpd-2.2.8.tar.gz

    2. php-5.2.5.tar.gz

    3. mysql-5.1.23-rc.tar.gz

    将其放在/etc/local/src目录中。

    1.安装apache服务器。

    [root@localhost ~]# cd /usr/local/src
    [root@localhost ~]# tar zxvf httpd-2.2.8.tar.gz
    [root@localhost ~]# cd httpd-2.2.8
    [root@localhost ~]# ./configure \
    --prefix=/usr/local/apache \
    --enable-mpm-worker \
    --enable-so \
    --enable-rewrite \
    --enable-cache \
    --enable-disk-cache \
    --enable-mem-cache \
    --enable-file-cache
    [root@localhost ~]# make
    [root@localhost ~]# make install

    选项说明

    –prefix=/usr/local/apache

    将apache安装到/usr/local/apache,方便管理

    –enable-mpm-worker

    设置apache多任务处理,默认为–enable-mpm-prefork

    其中prefork为,每建立一个连接,就建立一个进程,即,多进程并行处理,

    而worker则为多线程并行处理,对于高流量的服务器来说,worker将比prefork节省更多的内存

    更多请参见手册 http://httpd.apache.org/docs/2.0/mpm.html

    –enable-so

    so模块用来提供DSO支持的apache核心模块。

    –enable-rewrite

    打开URL重写模块

    –enable-cache

    –enable-disk-cache

    –enable-mem-cache

    –enable-file-cache

    详细说明请参见    http://httpd.apache.org/docs/2.2/caching.html

    2. mysql安装

    [root@localhost ~]# cd /usr/local/src
    [root@localhost ~]# tar mysql-5.1.23-rc.tar.gz
    [root@localhost ~]# cd mysql-5.1.23-rc
    [root@localhost ~]# ./configure \
    --prefix=/usr/local/mysql \
    --localstatedir=/usr/local/mysql/data \
    --disable-maintainer-mode \
    --with-mysqld-user=mysql \
    --with-unix-socket-path=/tmp/mysql.sock \
    --without-comment \
    --without-debug \
    --with-bench
    [root@localhost ~]# make
    [root@localhost ~]# make install

    接下来为专门为MYSQL创建一个用户和一个用户组

    [root@localhost ~]# groupadd mysql
    [root@localhost ~]# useradd mysql -g mysql

    mysql的用户在上面的配置中已经指定。

    接下来安装系统数据库。

    [root@localhost ~]# cd scripts/
    [root@localhost ~]# ./mysql_install_db

    设置相应目录权限

    [root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
    [root@localhost ~]# chown -R mysql:mysql /usr/local/mysql/data

    拷贝配置文件到/etc目录下

    [root@localhost ~]# cd support-files/
    [root@localhost ~]# cp my-medium.cnf /etc/my.cnf

    后台启动mysql

    [root@localhost ~]# cd /usr/local/mysql/bin
    [root@localhost ~]# ./mysqld_safe &

    如果要查看当前状态,启动服务器,可以通过如下方法

    [root@localhost ~]# cd /usr/local/mysql/share/mysql
    [root@localhost ~]# ./mysql.server [status|stop|start|restart]

    3. php安装

    [root@localhost ~]# cd /usr/local/src
    [root@localhost ~]# tar zxvf php-5.2.5.tar.gz
    [root@localhost ~]# cd php-5.2.5
    [root@localhost ~]# ./configure \
    --prefix=/usr/local/php \
    --with-apxs2=/usr/local/apache/bin/apxs \
    --enable-safe-mode \
    --with-mysql=/usr/local/mysql \
    --with-pdo-mysql=/usr/local/mysql/ \
    --with-gd \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr \
    --without-pear
    [root@localhost ~]# make
    [root@localhost ~]# make install

    拷贝php配置文件

    cp php-ini-dest /usr/local/php/lib/php.ini

    打开apache配置文件

    vi /usr/loca/apache/conf/httpd.conf

    查看libphp5.so

    如果能找到,则说明php编译没有总是,否则重新编译

    4.后续工作

    把apache和mysql加到启动启动文件中

    [root@localhost ~] vi /etc/rc.d/rc.local
    /usr/local/apache/bin/apachectl start
    /usr/local/mysql/bin/mysqld_safe --user=mysql &

    5.安装时可能出现的总是及解决方法

    Q. checking for termcap functions library… configure: error: No curses/termcap library

    A. Fid it by doing: yum install ncurses-devel

    Q. error: redeclaration of C++ built-in type ‘bool’

    A.make clean make distclean 清空编译缓存,重新编译

    安装MYSQL时出现总是

    Q :Error: Unknown character set: ‘gbk’ Errno.: 1115

    A:这个是由于在编译MSYQL的时候没有 –with-xcharset=all –with-extra-charsets=gb2312,gbk

    安装PHP再现的总是

    Q:configure: error: Cannot find MySQL header files under yes.

    A:编译的时候指定mysql的路径 /usr/local/mysql

    //重新编译

    Q If configure fails try –with-jpeg-dir=<DIR>

    configure: error: libpng.(a|so) not found.

    If configure fails try –with-jpeg-dir=<DIR>

    configure: error: libpng.(a|so) not found.

    A 。安装libjpeg库

    rpm -ivh libjpeg-devel-1.2.10-7.0.2.i386.rpm

    Q. If configure fails try –with-jpeg-dir=<DIR>

    configure: error: libpng.(a|so) not found.

    A. 安装 libpng库

    rpm -ivh libpng-devel-1.2.10-7.0.2.i386.rpm

    Q. libtool: link: `ext/pdo_mysql/mysql_driver.lo’ is not a valid libtool object

    A. 重新编译便可解决

    Q. The mysql driver is not currently installed

    A. 解决是没有安装pdo-mysql这个扩展了,重新配置,加上–with-pdo-mysql=/usr/local/mysql/

    网友留言/评论

    我要留言/评论