简介:
  从上次发表的一篇在Windows下安装Discuz论坛的文章到现在差不多快一个月了,一直想把在Linux下安装的过程也写出来,毕竟Linux下运行PHP性能要比Windows好.其实安装编译软件不是很麻烦,难的是要将各个组件组合起来.在安装过程中遇到了很多困难,也尝试了不少的方法,最终成就这篇文章.文中软件下载后存放的位置如果没有特殊说明,都存入在 /tmp下.以下是安装的过程:
  a:先检查系统中是否安装有旧版本的相关软件
[root@redhat ~]# rpm -qa |grep mysql
[root@redhat ~]# rpm -qa |grep httpd
[root@redhat ~]# rpm -qa |grep php
  b:解压并安装Apache
[root@redhat ~]# cd /tmp
[root@redhat tmp]# tar zxvf httpd-2.2.4.tar.gz
[root@redhat httpd-2.2.4]# ./configure --prefix=/usr/local/httpd \
--enable-isapi --enable-file-cache \
--enable-echo --disable-charset-lite \
--enable-charset-lite --enable-cache --enable-disk-cache --enable-mem-cache \
--enable-example --enable-case-filter --enable-case-filter-in --enable-dumpio \
--enable-ext-filter --enable-deflate --enable-log-forensic \
--enable-logio --enable-mime-magic --enable-headers --enable-proxy --enable-proxy-connect \
--enable-proxy-ftp --enable-proxy-http --enable-ssl --enable-optional-hook-export \
--enable-optional-hook-import --enable-optional-fn-import --enable-http --enable-cgi \
--enable-cgid --enable-speling --enable-rewrite --enable-so --with-suexec-uidmin \
--with-suexec-gidmin --with-suexec-logfile --with-suexec-safepath --enable-static-htpasswd \
--enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve
[root@redhat httpd-2.2.4]# make
[root@redhat httpd-2.2.4]# make install
[root@redhat tmp]# tar zxvf mysql-5.0.41-linux-i686.tar.gz
[root@redhat tmp]# mv mysql-5.0.41-linux-i686 /usr/local/mysql
[root@redhat mysql]# pwd
/usr/local/mysql
[root@redhat mysql]# groupadd mysql
[root@redhat mysql]# useradd mysql -g mysql
[root@redhat mysql]# chown -R root .
[root@redhat mysql]# chown -R mysql data
[root@redhat mysql]# chown -R mysql data/mysql/.
[root@redhat mysql]# chgrp -R mysql .
[root@redhat mysql]# cp ./support-files/my-medium.cnf /etc/my.cnf
[root@redhat mysql]# ./scripts/mysql_install_db --user=mysql
[root@redhat mysql]# bin/mysqld_safe --user=mysql &
[root@redhat tmp]# /usr/local/mysql/bin/mysqlshow -p
三:安装GD库[url]http://www.boutell.com/gd/[/url]
  a:解压并安装libpng[url]http://www.libpng.org/pub/png/libpng.html[/url]
[root@redhat libpng-1.2.16]# ./configure --prefix=/usr/local/png
[root@redhat libpng-1.2.16]# make
[root@redhat libpng-1.2.16]# make install
  b:解压并安装jpeg[url]ftp://ftp.uu.net/graphics/jpeg/[/url]
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/bin
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/lib
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/include
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/man
[root@redhat jpeg-6b]# mkdir /usr/local/jpeg/man/man1
[root@redhat jpeg-6b]# ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
[root@redhat jpeg-6b]# make
[root@redhat jpeg-6b]# make install
  c:解压并安装freetype ([url]http://www.fretype.org[/url]
[root@redhat freetype-2.3.2]# ./configure --prefix=/usr/local/freetype2
[root@redhat freetype-2.3.2]# make
[root@redhat freetype-2.3.2]# make install
  d:解压并安装fontconfig ([url]http://www.fontconfig.org[/url]
[root@redhat fontconfig-2.4.0]# ./configure --prefix=/usr/local/fontconfig \
--with-freetype-config=/usr/local/freetype2/bin/freetype-config
[root@redhat fontconfig-2.4.0]# make
[root@redhat fontconfig-2.4.0]# make install
  e:安装xmkmf工具
  在安装xpm时,会提示有找不到xmkmf这个命令.这时需要安装xorg-devel包,在系统盘的第三张光盘上找到并安装它.
[root@redhat tmp]# rpm -ivh freetype-devel-2.1.9-1.i386.rpm
[root@redhat tmp]# rpm -ivh fontconfig-devel-2.2.3-7.i386.rpm
[root@redhat tmp]# rpm -ivh /tmp/xorg-x11-devel-6.8.1-23.EL.i386.rpm
  f:解压并安装xpm ([url]http://koala.ilog.fr/ftp/pub/xpm/[/url]
[root@redhat xpm-3.4k]# xmkmf -a
[root@redhat xpm-3.4k]# make
[root@redhat xpm-3.4k]# make install
  g:解压并安装GD
[root@redhat tmp]# tar zxvf gd-2.0.34.tar.gz
[root@redhat gd-2.0.34]# ./configure --prefix=/usr/local/gd --with-png=/usr/local/png/ \
--with-jpeg=/usr/local/jpeg/ --with-freetyp=/usr/local/freetype2/ \
--with-fontconfig =/usr/local/fontconfig/--with-xpm
[root@redhat gd-2.0.34]# cp /usr/local/png/include/png.h ./
[root@redhat gd-2.0.34]# cp /usr/local/png/include/pngconf.h ./
[root@redhat gd-2.0.34]# make
[root@redhat gd-2.0.34]# make install
四:解压并安装php[url]http://www.php.net[/url]
[root@redhat tmp]# tar zxvf php-5.2.3.tar.gz
[root@redhat php-5.2.3]# ./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql --with-apxs2=/usr/local/httpd/bin/apxs \
--with-libxml-dir=/usr/include/libxml2/libxml --with-gd=/usr/local/gd/ \
--with-png=/usr/local/png/ --with-jpeg=/usr/local/jpeg/ --with-xpm \
--with-zlib --enable-debug --enable-magic-quotes --enable-libgcc \
--enable-ftp --enable-mbstring --enable-sockets --with-gnu-ld
[root@redhat php-5.2.3]# make
[root@redhat php-5.2.3]# make install
[root@redhat php-5.2.3]# cp php.ini-recommended /usr/local/php/etc/php.ini

五:设置http.conf来支持PHP
[root@redhat php-5.2.3]# vi /usr/local/httpd/conf/httpd.conf
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.html.var index.htm index.php
六:解压并设置phpmyadmin
[root@redhat tmp]# tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz
[root@redhat tmp]# mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin
[root@redhat tmp]# cd /usr/local/httpd/htdocs/phpmyadmin
[root@redhat phpmyadmin]# cp ./libraries/config.default.php ./config.inc.php
[root@redhat phpmyadmin]vi config.inc.php
$cfg['PmaAbsoluteUri'] = '[url]http://localhost/phpmyadmin';[/url]
$cfg['Servers'][$i]['auth_type'] = 'http';
七:建立php测试文件,启动apache
[root@redhat tmp]#vi /usrc/local/httpd/htdocs/phpinfo.php
----------------------------
<?php phpinfo(); ?>
----------------------------
[root@redhat tmp]# /usr/local/httpd/bin/apachectl start
 
  此时,在浏览器中输入:[url]http://ip/phpinfo.php[/url],会出现以下画面,图中显示GD库已正确安装
  再测试phpmyadmin,同样在浏览器中输入:[url]http://ip/phpmyadmin[/url]

八:安装Zend
[root@redhat tmp]# tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
[root@redhat tmp]# cd ZendOptimizer-3.2.2-linux-glibc21
[root@redhat ZendOptimizer-3.2.2-linux-glibc21 ]# ./install.sh
至此,LAMP已完全安装成功,而且全面基于源码的方式安装完成,所用的系统及已安装的相关组件可以点这里查看.