从上次发表的一篇在Windows下安装Discuz论坛的文章到现在差不多快一个月了,一直想把在Linux下安装的过程也写出来,毕竟 Linux下运行PHP性能要比Windows好.其实安装编译软件不是很麻烦,难的是要将各个组件组合起来.在安装过程中遇到了很多困难,也尝试了不少 的方法,最终成就这篇文章.文中软件下载后存放的位置如果没有特殊说明,都存入在 /tmp下.以下是安装的过程:
一:安装Apache([url]http://archive.apache.org/dist/httpd/binaries/[/url])
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
![](http://www.ylmf.net/uploads/allimg/101126/1042131939-0.jpg)
![](http://www.ylmf.net/uploads/allimg/101126/1042131639-1.jpg)
![](http://www.ylmf.net/uploads/allimg/101126/10421311a-2.jpg)
二:安装MySQL([url]http://downloads.mysql.com/archives.php?p=mysql-4.1[/url])
[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(ftp://ftp.uu.net/graphics/jpeg/ )
[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
![](http://www.ylmf.net/uploads/allimg/101126/1042131563-3.jpg)
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
![](http://www.ylmf.net/uploads/allimg/101126/10421313H-4.jpg)
四:解压并安装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://www.ylmf.net/uploads/allimg/101126/1042133107-5.jpg)
五:设置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'] = 'http://localhost/phpmyadmin';
$cfg['Servers'][$i]['auth_type'] = 'http';
七:建立php测试文件,启动apache
[root@redhat tmp]#vi /usrc/local/httpd/htdocs/phpinfo.php
----------------------------
----------------------------
[root@redhat tmp]# /usr/local/httpd/bin/apachectl start
此时,在浏览器中输入:[url]http://ip/phpinfo.php[/url],会出现以下画面,图中显示GD库已正确安装
![](http://www.ylmf.net/uploads/allimg/101126/1042133Y6-6.jpg)
再测试phpmyadmin,同样在浏览器中输入:[url]http://ip/phpmyadmin[/url]