一:下载软件
首先源码安装与yum
安装区别,在这就不详说了。源码安装的好处之一是可以定制软件功能,虽然编译速度慢点,不过也是可以接受的。
下面简单说下,安装完整版LAMP
所需的软件。其中Apache
,Mysql
,PHP
是必不可少的,其他功能性软件有APR
,APR-util
,zlib
,freetype
,libpng
,jpegsrc.v6b
,libxml2
,gd
库,
各软件的下载地址如下:
http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.23.tar.gz
http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.46.tar.gz
http://cn2.php.net/distributions/php-5.4.9.tar.gz
http://jaist.dl.sourceforge.net/project/libpng/libpng15/1.5.13/libpng-1.5.13.tar.gz
http://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.7/zlib-1.2.7.tar.gz
http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz
http://labs.mop.com/apache-mirror//apr/apr-util-1.5.1.tar.gz
http://mirror.yongbok.net/nongnu//freetype/freetype-2.4.10.tar.gz
http://down1.chinaunix.net/distfiles/jpegsrc.v6b.tar.gz
ftp://xmlsoft.org/libxml2/libxml2-2.7.7.tar.gz
http://down1.chinaunix.net/distfiles/gd-2.0.33.tar.gz
二:安装软件
1
:安装
Mysql
#tar zxvf mysql-5.1.46.tar.gz
#cd mysql-5.1.46
#./configure --prefix=/usr/local/mysql --without-debug --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --enable-assembler --enable-thread-safe-client --with-extra-charsets=all
#make
&&
make
install
#cp
support-files/my-medium.cnf
/etc/my.cnf
#cd
/usr/local/mysql
#bin/mysql_install_db
--user=mysql
#chown root . -R
#chgrp
mysql .
-R
#chown
mysql.root
/var
-R
#bin/mysqld_safe
--user=mysql &
2
:安装
Zlib
解压,进入到解压后zlib
目录
#./configure
--prefix=/usr/local/zlib
#make
&&
make
install
3
:安装
APR
,
APR-util
解压,进入到解压后apr
目录
#./configure
--prefix=/usr/local/apr
#make && make install
解压,进入到解压后apr-util
目录
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
&&
make
install
4
:安装
Apache
解压,进入到解压后apache
目录
#./configure --prefix=/usr/local/apache2
--enable-so
--with-mysql=/usr/local/mysql
--enable-cgi
--enable-mods-shared=all
--enable-cache
--enable-disk-cache
--enable-mem-cache
--enable-rewrite
--with-z-dir=/usr/local/zlib
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
#make
&&
make
install
5
:安装
libpng
,
freetype
,
jpegsrc.v6b
,
libxml2
,
gd
库
解压,进入到解压后libpng
目录
#./configure --prefix=/usr/local/libpng
#make
&&
make
install
解压,进入到解压后freetype
目录
#./configure --prefix=/usr/local/freetype
#make &&
make install
解压,进入到解压后jpegsrc.v6b
目录
#./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
#make && make install && make install-lib
解压,进入到解压后libxml2
目录
#./configure --prefix=/usr/local/libxml2
#make && make install
#cp /usr/local/src/libxml2-2.7.7/xml2-config /usr/bin
解压,进入到解压后gd
库目录
#./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/ --with-png=/usr/local/lib --with-zlib=/usr/local/zlib/
#make
&&
make
install
6
:安装
PHP
解压,进入到解压后php
目录
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local/gd/ --enable-gd-native-ttf --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/lib --with-zlib=/usr/local/zlib/ --with-freetype-dir=/usr/local/freetype/ --with-mysql=/usr/local/mysql/ --with-iconv --enable-mbstring --enable-ftp --with-config-file-path=/usr/local/apache2/conf/ --with-pear=/usr/local/php/pear --without-pear
#make
注意:在make
过程中,会提示如下错误
......
/usr/local/src/php-5.4.9/ext/gd/gd_ctx.c:153: error: 'gdIOCtx'has no member named 'data'
make: *** [ext/gd/gd.lo] Error 1
解决办法:进入到gd
库的目录文件/usr/local/gd/include/gd_io.h
,在typedef struct gdIOCtx
结尾添加
void (%data);
然后重新执行make
,很可能紧接着会出现另外一个错误
...error while loading shared libraries: libpng15.so.15: cannot open shared object file: No such file or directory
解决方法:输入命令 echo "/usr/local/lib" >> /etc/ld.so.conf
,再执行ldconfig
命令,然后再次重新执行make
#make
install
#cp /usr/local/src/php-5.4.9/php.ini-production /usr/local/php/lib/php.ini
三:信息配置
如果
PHP
和
apache
配合使用,则要修改
apache
的配置文件,
找到
AddType application/x-gzip .gz .tgz
这行,添加如下内容
#vi
/usr/local/apache2/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
测试方法如下:
#vi /usr/local/apache2/htdoc/phpinfo.php
<?php
phpinfo();
?>
此时在浏览器输入
http://IP/phpinfo.php
,即可看到
php
页面
四:将服务设置为开机启动
#chkconfig
httpd
on
#chkconfig
mysqld
on