2013-10-01 12:14:01
来 源
kejihao
Apache
这里分享一下Apache2.2.15+PHP5.2.17+MySQL-5.5.8的整合安装配置,希望对于初学Apache服务器相关的朋友有帮助,更多Apache安装、配置、报错处理等资源请本站内搜索。

Apache 2.2.15 整合php 5.2.17

需要的包:

Apache:

httpd-2.2.15.tar.gz

mysql:

mysql-5.5.8-linux2.6-i686.tar.gz

图片格式支持包:

freetype-2.3.10.tar.bz2

jpegsrc.v8c.tar.gz

libpng-1.2.44.tar.gz

gd-2.0.35.tar.gz

php:

php-5.2.17.tar.gz

论坛源码:

wordpress-3.0.4-zh_CN.tar.gz

-----------------

1、创建httpd.sed和test.php文件放置于apache源码目录下。

vim httpd.sed

/application/x-compress .Z/a

    Addtype application/x-httpd-php .php

-----------------

vim test.php

<?

phpinfo();

?>

-----------------

2、编译安装apache 2.2.15

 cd httpd-2.2.15/

 ./configure

--prefix=/usr/local/apache

--enable-so

--enable-rewrite

--with-mpm=worker

make

make install

cp test.php /usr/local/apache/htdocs/

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

-----------------

3、编译安装mysql

PS:这里我装的时候就绕远了,因为一开始安装的时候都是安装的带configure文件的源码包,这次下载的最新版本的却是不带configure的,当时也在发愁怎么安装,后来发现了里面有个INSTALL-BINARY,打开看了看,就找到了正确的安装方法。不过安装完了还是有一些小问题,比如运行mysql_safe的时候,总是报错,就是什么pid啦,什么mysql.sock,就是什么找不到mysql.sock啦,什么没能找到那个localhost.pid啦,这些我总结为你的mysql.server中的设置项是不对的,所以后边有那个mysql.server的修改的地方。而那个无法更新localhost.pid的问题,是因为没有copy my.cnf所致,拷贝了my.cnf到etc下后,启动mysql成功。

tar zxvf mysql-5.5.8-linux2.6-i686.tar.gz -C /usr/local/lamp

mv mysql-5.5.8-linux2.6-i686/ /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db

--basedir=/usr/local/mysql

--builddir=/usr/local/mysql/share

--datadir=/usr/local/mysql/data

--user=mysql

--skip-name-resolve

chown -R mysql:mysql /usr/local/mysql/data/

cp support-files/my-small.cnf /etc/my.cnf

vim /usr/local/mysql/support-files/mysql.server

    basedir=/usr/local/mysql

    datadir=/usr/local/mysql/data

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

service mysqld start

-----------------

4、编译安装freetype

cd freetype-2.3.10/

./configure --prefix=/usr/local/freetype

make

make install

cd ..

-----------------

5、编译安装jpeg

cd jpeg-8c/

./configure --prefix=/usr/local/jpeg

make

make install

cd ..

-----------------

6、编译安装libpng

cd libpng-1.2.44

./configure --prefix=/usr/local/libpng

make

make install

cd ..

-----------------

7、编译安装gd2

ln -s /usr/local/libpng/include/pngconf.h /usr/include

ln -s /usr/local/libpng/include/png.h /usr/include

cd gd-2.0.35

./configure

--prefix=/usr/local/gd2

--with-freetype-dir=/usr/local/freetype

--with-png=/usr/local/libpng

--with-jpeg=/usr/local/jpeg

make

make install

cd ..

备注:如果在make的时候,出现以下报错。只要添加下边的那条选项便可成功make

configure.ac:64: error: possibly undefined macro: AM_ICONV

If this token and others are legitimate, please use m4_pattern_allow.

See the Autoconf documentation.

make: *** [configure] Error 1

--enable-m4_pattern_allow

-----------------

8、编译安装php

cd php-5.2.17

./configure

--prefix=/usr/local/php

--with-gd=/usr/local/gd2

--with-apxs2=/usr/local/apache/bin/apxs

--enable-mbregex

--enable-bcmath

--with-mysql=/usr/local/mysql

--with-zlib-dir

--enable-mbstring=all

--with-freetype-dir=/usr/local/freetype

--with-pdo-mysql

make

make install

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

cd ..

-----------------

9、最后配置

sed -f httpd.sed /usr/local/apache/conf/httpd.conf > /usr/local/apache/conf/httpd.conf.tmp

mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.old

mv /usr/local/apache/conf/httpd.conf.tmp /usr/local/apache/conf/httpd.conf

-----------------

10、测试

elinks http://127.0.0.1/test.php

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。