Wednesday, July 23, 2008

Apache/PHP在Linux安装配置过程记录(freetype, GD, JPEG, libpng, multbyte charset, Zend Optimizer)

作者:白东(Albert Ding)

由于更换了新的服务器,因此安装了新的版本。

  1. 下载 apachephpfreetypelibpngGD2
  2. 解压 (tar xvfz httpd.xxxx.tar.gz),(tar xvfz php.xxxx.tar.gz),(tar xvfz freetype-2.1.9.tar.gz),(tar xvfz gd-2.0.26gif.tar.gz);
  3. 安装Apache:
    1. 配置Apache (./configure --prefix=/usr/local/apache --enable-so),注意这里的参数(--enable-so)为打开DSO(动态共享对象)以便日后升级模块;
    2. 编译和安装Apache( make / make install);
    3. 将(/usr/local/apache/bin/apachectl)复制到 /etc/init.d/apache ,也可不做这步;
    4. 启动并测试Apache (/etc/init.d/apache start 或 /usr/local/apache/bin/apachectl start);
    5. 停止Apache (/etc/init.d/apache stop 或 /usr/local/apache/bin/apachectl stop);
  4. 安装 Freetype
    1. cd freetype-2.1.9
    2. ./configure (默认是安装到 /usr/local 目录中)
    3. make
    4. make install
  5. 安装 libpng
    1. cd libpng-1.2.8-config
    2. ./configure
    3. make
    4. install
  6. 安装 GD 2
    1. cd gd-2.0.26gif
    2. ./configure
    3. make
    4. make install
  7. 安装PHP:
    1. 配置php ('./configure' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-mysql' '--enable-calendar' '--enable-force-cgi-redirect' '--with-gd' '--enable-gd-imgstrttf' '--enable-gd-native-ttf' '--enable-inline-optimization' '--enable-magic-quotes' '--with-bz2' '--with-ftp' '--with-xml' '--with-zlib=yes' '--with-gd' '--enable-mbstring' '--with-png-dir=/usr' '--with-ttf' '--with-freetype-dir=/usr/local' '--enable-ctype' '--enable-dbase' '--enable-ftp' '--with-ftp' '--with-gdbm' '--with-gettext' '--with-tiff-dir=/usr' '--with-jpeg-dir=/usr' '--with-freetype')。
      1. 红色部分 如果之前Apache安装没有设定参数(--enable-so)那么这里就不可以使用这样的方法来配置。
      2. 绿色部分是为了支持 multibyte charset (多字节字符) 的,打开这个使用 split 函数对中文以及其他多字节字符才能完全正确。同时PHPMyAdmin也需要使用这个模块(如果不安装这个模块,PHPMyAdmin的首页会有红色问题提示:The mbstring PHP extension was not found and you seem to be using multibyte charset. Without mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.因此,如果想要使用PHPMyAdmin来通过web管理MySQL,那么就需要把这个模块打开)。
      3. 蓝色部分是启用GD库。
      4. 紫色部分是打开gd支持 freetype的功能。
    2. 编译和安装PHP (make / make install);
    3. 复制PHP配置文件 (cp php.ini-dist /usr/local/lib/php/php.ini);
    4. 修改Apache(httpd.conf)文件,添加以下选项:
      1. LoadModule php4_module libexec/libphp4.so (注:PHP可自动添加这个内容到httpd.conf,如果没有则手动添加);
      2. AddType application/x-httpd-php .php;
      3. AddType application/x-httpd-php-source .phps (注:这项可不添加)
      4. 修改:DirectoryIndex index.html index.html.var 后添加:index.php (你也可以填写任何你想要的模块index文件)
    5. 编写phpinfo()文件以测试PHP是否安装成功;
    6. 安装 Zend Optimizer (2.5.7的版本需要注意的是,安装后使用phpinfo()页面中看看Configuration File (php.ini) Path 的路径中是否有已经修改过的php.ini或者link文件);
  8. 启动Apache (/etc/init.d/apache start);

No comments: