今天去朋友BLOG转了转发现有更新,所以就转载了一份文章,以便于以后自己做的时候出现问题来查找一下原因,其实在上周我在虚拟机上做测试的时候就发现了这点问题,刚好在学习一下
环境 : linux 版本为 redhat as 4 apache : httpd-2.2.0 mysql : mysql-4.1.18 gd2 : gd-2.0.35

zlib: zlib-1.2.3 jpeg : jpeg -6b php : php 5.1.2 libpng : libpng-1.2.10

freetype : freetype-2.1.9 zd : ZendOptimizer-2.6.2

装好系统之后 里面最安装了软件开发工具 。 如果以前有 php 或者是 apahce 之类的 最好都卸载掉, 以免以后在编译的过程中出现一些奇怪的问题 。 ^_^

首先开始查看我们的服务器中是否有gcc ..
gcc -v

Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure –prefix=/usr –mandir=/usr/share/man –infodir=/usr/share/info –enable-shared –enable-threads=posix –disable-checking –with-system-zlib –enable-__cxa_atexit –disable-libunwind-exceptions –enable-java-awt=gtk –host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

===========================================================================

gcc 已经安装好了 那我开始软件安装之旅吧。

首先安装 mysql

shell> groupadd -g 500 mysql
shell> useradd -u500 -gmysql -M mysql

shell> tar -zxzf mysql.**.tar.gz
shell> cd mysql.**
shell> ./configure –prefix=/usr/local/mysql –localstatedir=/usr/local/mysql/data –with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
shell> make
shell> make install
shell> cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql //开机启动mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db –user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe –user=mysql &

注意直接执行后会出现下面错误:
Starting mysqld daemon with databases from /usr/local/mysql/data STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid 070514 19:15:13 mysqld ended
需执行 shell> chown -R mysql.mysql data

修改root密码:
use mysql
update user set Password=password("123456") where User="root";
delete from user where User="";

apache安装 :

shell> tar -xzvf httpd-2.2.4.tar.gz
shell> cd httpd-2.2.4
shell> ./configure –prefix=/usr/local/apache2 –enable-rewrite=shared –enable-speling=shared –enable-module=so
shell> make
shell> make install

gd部分安装 :

zlib包
shell> ./configure –prefix=/usr/local/zlib
shell> make check
shell> make install

libpng包(支持PNG)
shell> ./configure –prefix=/usr/local/libpng
shell> make
shell> make install

jpeg-6b包(支持jpg格式)
shell> ./configure –prefix=/usr/local/jpeg-6b –enable-share –enable-static
shell> make test
shell> make
shell> make install
shell> make install-lib

注:

1:在configure的时候会出现/usr/local/jpeg-6b/bin/djpeg 没有这个目录 我们手工的添加就可以了 mkdir –p /usr/local/jpeg-6a/bin/djpeg

2 : configure的时候也出现
/usr/local/jpeg-6b/man/man1/cjpeg.1 同样 我们 手工的建立一个 touch /usr/local/jpeg-6a/man/man1/cjpeg.1

freetype包(字体支持)
shell> ./configure –prefix=/usr/local/freetype
shell> make
shell> make install

最后安装gd包
shell> ./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg-6b –with-zlib-dir=/usr/local/zlib –with-png=/usr/local/libpng –with-freetype=/usr/local/freetype
shell> make
shell> make install

make时会出现
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/tmp/gd-2.0.26gif'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/gd-2.0.26gif'
make: *** [all] Error 2
需要复制/usr/local/libpng/include/目录下的cp /usr/local/libpng/include/pngconf.h /home/jong/tmp/gd-2.0.34
cp /usr/local/libpng/include/png.h /home/jong/tmp/gd-2.0.34
注 :
当make 时出现
configure.ac:64: error: possibly undefined macro: AM_ICONV
将第二张盘 中的 gettext 文件安装上去
Rpm –ihv gettext-0.14.1-13.i386.rpm 就可以解决这个问题。

php 的安装 :

shell> ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-gd=/usr/local/gd2 –with-jpeg-dir=/usr/local/jpeg-6b –with-zlib-dir=/usr/local/zlib –with-png-dir=/usr/local/libpng –with-freetype-dir=/usr/local/freetype –enable-trace-vars -with-mysql=/usr/local/mysql -with-iconv=/usr/local/iconv –enable-mbstring=all –with-curl –enable-track-vars –with-DBA –enable-mbstr-enc-trans –enable-mbregex –with-config-file-path=/usr/local/php –with-xml –with-gettext
shell> make
shell> make install
shell> cp php.ini-dist /usr/local/php/php.ini

注: 在make 的时候会出现 “configure: error: libjpeg.(a|so) not found”
在系统的盘的第二张光盘里面 rpm –ihv libjpeg-devel-6b-33.i386.rpm 把这个包安装上去就可以解决这个问题。

编辑apache配置档
shell> cd /usr/local/apache2/conf
shell> vi httpd.conf
在LoadModule php5_module modules/libphp5.so
添加AddType application/x-httpd-php .php

OK,基本的安装已经完成,如果重新起动:
APACHE出现:/usr/local/apache2/bin/apachectl start Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解决:

编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – SELinux is fully disabled.
SELINUX=enforcing

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。

zd的安装比较简单 直接运行 ./install.sh 然后出现图形的界面 选择安装路径 还有就是php.ini的位置 (/usr/local/php/) 然后重新启动apache 。

最后我们写一个 php的测试文件 来查看一下 。

phpinfo ();
?>

保存 ok 了 。

以上的软件下载均可以到 www.chinaunix.net 下载 。 在此表示感谢 。。。



分享到: 更多

这篇日志的 QR 二维码为:

四月 17th, 2008

Posted In: 未分类

无觅相关文章插件,快速提升流量