apache、php、mysql源码安装

这里,我选择了CentOS来作为我的安装系统,当然也可以选择其它的发行版。

最小化安装系统

需要额外软件包

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编译没有总是,否则重新编译

添加php文件后缀支持

AddType application/x-httpd-php .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/

机器人 2008-4-13  18:27 于 北京

此条目发表在 linux/server 分类目录,贴了 , , , , 标签。将固定链接加入收藏夹。

apache、php、mysql源码安装》有 7 条评论

  1. 小黑 说:

    哇 学到好东西啦~ 嘎嘎~

    还有你好久都没更新博客了哦

  2. 机器人 说:

    会的,等忙我了这阵了,一定多写写。。

  3. I’m still learning from you, but I’m trying to achieve my goals. I certainly love reading all that is written on your site.Keep the information coming. I loved it

  4. The next time I read a blog, I hope that it doesnt disappoint me as much as this 1. I mean, I know it was my selection to read, but I really believed youd have some thing interesting to say. All I hear is a bunch of whining about some thing that you simply could fix in case you werent too busy on the lookout for attention.

  5. I am 69 years old and I was searching for this and final i find here. This is just awesome site and article based or true handwork. Thanks for sharing with us.

  6. olympic london 说:

    Fascinating look at Arceon and the whole Alien 3 concept: looking forward to the rest of the story. The Alien Quadrilogy DVD was interesting, but this provides a whole new insight.

  7. Pingback 引用通告: 韩国时尚女装购物

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>