免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1913 | 回复: 0
打印 上一主题 下一主题

Apache20 + MySQL50 + PHP5 + PEAR [复制链接]

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-09 09:12 |只看该作者 |倒序浏览
Description :

        最近學習到
PEAR
因此也在我的 FreeBSD 上將 Apache20 + PHP5 + MySQL5 + PEAR 環境架起來,PEAR 的英文縮寫是 ( PHP Extension and Application Repository ) , 而甚麼是
PEAR
呢?簡單的說就是 PHP 程式庫包成的『 套件 』,主要目的就是提供程式開發者引用,如此一來 PHP 的開發者便可以不必自己完全手工打造所有的程式碼,而只要會引用 PEAR 程式庫便可以輕易及快速的建立強大的應用程式。
        
PEAR
將許許多多不同功能的程式庫包裝成『 套件 』,免費提供 PHP 開發者使用今天 (2006/09/14)
PEAR
數據統計已經累積了403 個套件,而且套件數目還在不斷的持續增加中,
PEAR
的優點是程式庫就如同模組一樣可輕易抽換及更新,同時也完全不會去影響到其他程式,程式碼容易維修因此吸引不少 PHP 程式開發者相繼投入使用,若想多了解 PEAR 可到 PEAR 的官網站上去查看,網址是
http://pear.php.net
官網上面有很豐富的資訊。
Environment :
硬體:i386 PC Intel P3 500
記憶體網卡:512M RAM + Intel 網卡
作業系統:FreeBSD 6.0 Release
Setp 1.
安裝 Apache + MySQL + PHP 的基本 web 環境:
#cd /usr/ports/database/mysql50-server    #   安裝 MySQL 50
#make install clean
#cd /usr/ports/www/apache20    #  安裝 Apache 20
#make install clean
#cd /usr/ports/lang/php5    #  安裝 PHP5
#make install clean     #  我只有選擇下列相關套件一併安裝  
[X] CLI               Build CLI version [X] CGI              Build CGI version [X] APACHE      Build Apache module [X] FASTCGI      Enable fastcgi support (CGI only) [X] PATHINFO    Enable path-info-check support (CGI only)
#cd /usr/ports/lang/php5-extensions    #  安裝 PHP5-Extensions
#make config     #  安裝前先手動選擇所需要的延伸套件
[X] CTYPE      ctype functions  [X] DOM        DOM support[X] GD         GD library support[X] GETTEXT    gettext library support[X] HASH       HASH Message Digest Framework[X] ICONV      iconv support[X] MYSQL      MySQL database support [X] PCRE       Perl Compatible Regular Expression support[X] PDO        PHP Data Objects Interface (PDO)[X] POSIX      POSIX-like functions[X] SESSION    session support[X] SIMPLEXML  simplexml support[X] SQLITE     sqlite support[X] TOKENIZER  tokenizer support[X] XML        XML support[X] XMLREADER  XMLReader support [X] XMLWRITER  XMLWriter support [X] ZLIB       ZLIB support
#make install        #  因為 Extensions 有選 GD library 所以必須要選擇加裝 T1LIB 及 TRUETYPE 同時 SQLITE 也必須選擇是否開啟 UTF-8 編碼
    Options for php5-gd 5.1.6[X] T1LIB     Include T1lib support[X] TRUETYPE  Enable TrueType string function
    Options for php5-sqlite 5.1.6        #  PHP 下的精簡型文字資料庫 Text Database[X] UTF8  Enable UTF-8 support
#vi /etc/rc.conf      #  編輯 FreeBSD  的開機設定檔,設定 mysql 及 apache 開機自動啟動
mysql_enable="YES"
apache2_enable="YES"
#vi httpd.conf     #   編輯 Apache 的設定檔,加入下列幾行:
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsDirectoryIndex index.php
#cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini      # 編輯 PHP5 的設定檔將複製 php.ini-dist 到 php.ini
#vi php.ini     #  如果必須要相容舊語法可將 Off 改為 On
register_globals = On      
#apachectl      #  重新啟動 apache
#reboot    # 重開機讓 MySQL 啟動
Setp 2.
安裝 PEAR 開發環境及基本套件:
#cd /usr/ports/devel/pear    #  安裝 PEAR 套件管理指令 ( 這邊只是 PEAR 的套件管理指令,PEAR 的基本套件要等裝完 lynx 才可加裝 )
#make  install clean
#vi /usr/local/etc/php.ini     #  將 pear 的絕對路徑加到 php.ini 設定檔中
include_path = ".:/usr/local/share/pear"
#cd /usr/ports/www/lynx    #  安裝 lynx
#make install clean
#lynx -source http://go-pear.org | php    # 安裝 PEAR 的基本套件
Welcome to go-pear!Go-pear will install the 'pear' command and all the files needed byit.  This command is your tool for PEAR installation and maintenance.Go-pear also lets you download and install the PEAR packages bundledwith PHP: MDB2.If you wish to abort, press Control-C now, or press Enter to continue: 按 Enter
HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none::  按 Enter    #  ( 我無 proxy 所以跳過 )
Below is a suggested file layout for your new PEAR installation.  Tochange individual locations, type the number in front of thedirectory.  Type 'all' to change all of them or simply press Enter toaccept these locations. 1. Installation prefix           : /usr/local 2. Binaries directory            : $prefix/bin 3. PHP code directory ($php_dir) : $prefix/share/pear 4. Documentation base directory  : $php_dir/docs 5. Data base directory           : $php_dir/data 6. Tests base directory          : $php_dir/tests 7. Temporary files directory     : $prefix/temp1-7, 'all' or Enter to continue: 按 Enter
The following PEAR packages are bundled with PHP: MDB2.Would you like to install these as well? [Y/n] : y
#apachectl restart    #  重新啟動 apache
#pear list    #  查看 pear 已安裝的套件版本
Installed packages, channel pear.php.net:==============================Package            Version       StateArchive_Tar          1.3.1        stableConsole_Getopt    1.2          stableMDB2                  2.2.2        stablePEAR                  1.4.11      stableXML_RPC            1.5.0         stable
Setp 3.
安裝套件並且測試安裝結果:
#chown -Rf www:www /usr/local/share/pear    #  修改 pear 套件存放目錄權限    #chown www:www  /usr/local/share        #  修改 pear 套件目錄權限
#pear install Benchmark        #  安裝一個套件來測試看看
pear/Benchmark can optionally use PHP extension "bcmath"downloading Benchmark-1.2.6.tgz ...Starting to download Benchmark-1.2.6.tgz (7,915 bytes).....done: 7,915 bytesinstall ok: channel://pear.php.net/Benchmark-1.2.6
#pear list        #  再次查看所有已安裝套件
Installed packages, channel pear.php.net:=========================================Package                       Version         StateArchive_Tar                    1.3.1           stable
Benchmark                    1.2.6           stableConsole_Getopt             1.2              stableMDB2                            2.2.2           stablePEAR                            1.4.11         stableXML_RPC                      1.5.0           stable
#cd /usr/local/share/pear/Benchmark        #  查看所安裝的套件目錄
# ls -l        #  Benchmark 下總共有三個套件
total 30
-rw-r--r--  1 root  www   4658  9 14 17:40 Iterate.php-rw-r--r--  1 root  www  13323  9 14 17:40 Profiler.php-rw-r--r--  1 root  www  10095  9 14 17:40 Timer.php
#vi Timer.php        #  查半 Timer.php 這個套件如何引用 Timer 裡面有說明
#vi /usr/local/www/data-dist/show.php        #   寫個 php 的時間計數小程式來測試
require_once 'Benchmark/Timer.php';$timer = new Benchmark_Timer();$timer->start();echo "Hello World!";$timer->stop();$totaltime=$timer->timeElapsed();echo "
This Page Show Time:".$totaltime."Sec";?>
http://xxx.xxx.xxx.xxx/show.php        #   開個瀏覽器看一下 Timer 計時器是否成功
Hello World!This Page Show Timer:0.000207185745239Sec
#pear install PEAR_Info
#vi /usr/local/www/data-dist/info.php
require_once 'PEAR/Info.php';$pear_info = new PEAR_info();$pear_info ->show();?>
http://xxx.xxx.xxx.xxx/info.php        #   開個瀏覽器可看見PEAR 設定檔及所安裝的套件訊息
To Add .
#pear uninstall Benchmark     #  解除安裝套件
#pear help    #  查看 pear 指令


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4206/showart_522945.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP