閱讀543 返回首頁    go 阿裏雲 go 技術社區[雲棲]


web profiler 環境搭建

        初嚐LAMP,WAMP or MAMP,可能大多數同學會想到使用AppSer套件吧。今天,借著我們的Web Profiler,我想和大家分享的一下LAMP環境搭建(不過這裏暫時不需要M)。

一. 環境準備

       工欲善其事必先利其器。首先,我們需要列出環境搭建過程中的Requirements and Optional

1. Apache HTTP Server 2.4.x

  Requirements : 

    1.1  APR and APR-Util

    1.2  PCRE 2.4中,該兼容工具包已經不再隨server一起分發,所以需要我們自己下載安裝,地址在:https://www.pcre.org

    1.3  GCC

    1.4  基於NTP的時間同步工具,如:ntpdate,xntpd

 Optional:

    1.5  Perl 5 一些apxs腳本需要運行在perl 5 解釋器上

2. PHP 5.3.x

        Php 的安裝有些小糾結。如果你運行開源php程序,一定需要搞清楚當時的運行環境,感覺它的版本兼容性做的不是很好,某個程序在5.3.x上能運行,到5.4.x就出問題了。這裏取上一個穩定版本,故選定5.3.10

  Requirements : 

    2.1 PHP 5.3.10

    2.2 Libxml

  Optional:

       這裏根據需要選擇,由於我要用到zlibcurlxdebug等開源庫,所以待會會看到我的配置參數裏會有其身影。

二.開工(隻列出重要步驟)

1 Apache的安裝:

./configure --enable-mpms-shared=all --enable-mods-shared=most --prefix=/home/admin/apache2 --with-port=9898 --with-included-apr --with-pcre=/home/admin/pcre/bin/pcre-config --enable-so --with-included-apr --with-pcre=/home/admin/pcre/bin/pcre-config

備注:這裏mpm我選擇了all,目的很明確,後麵要對新版本的Apache Io模型進行性能壓測.最後兩個選項是2.4.x與之前版本不同的地方.

2 PHP的安裝:

./configure --prefix=/home/admin/php5 --with-apxs2=/home/admin/apache2/bin/apxs --with-libxml-dir=/home/admin/libxml2 --with-curl=/home/admin/curl --enable-mbstring  --with-zlib-dir=/home/admin/zlib --enable-ftp --enable-zip --with-config-file-path=/home/admin/php5/lib

備注:由於GD庫是隨發行bundle的,所以這裏我省去以下參數--with-gd --with-jpeg-dir --with-png-dir ---enable-gd-native-ttf mbstring是多字節編碼,這個用過visual studio的朋友都很有感觸吧。另外,with係列的命令根據具體需求添加,enable係列的命令同理,附一份我的配置清單吧,如下:


    接下來,安裝debug擴展模塊,首先進入xdebug目錄,執行../php5/bin/phpize,有了configure文件後,像其它源碼安裝一樣,執行configure,make,install命令.隻不過這裏的配置命令需要稍作改變,如:./configure --enable-xdebug --with-php-config=/home/admin/php5/bin/php-config.最後一步,將生成的擴展模塊及其一些debug信息加入php.ini文件,如:

zend_extension=/home/admin/xdebug-2.1.4/modules/xdebug.so

xdebug.remote_enable=on

xdebug.remote_host=127.0.0.1

xdebug.remote_port=33333

最後通過php -m 或者 -i查看查看是否成功.

PHP 5.3.10 (cli) (built: Apr  7 2012 13:55:06) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.4, Copyright (c) 2002-2012, by Derick Rethans

......

3 環境配置

        經過一陣子makemake install安裝完畢後,進入配置環節,首先拷貝php.ini-production到我剛才指定的目錄/home/admin/php5/lib,並命名為php.ini,初始化參數都在這裏麵定義,後麵可以酌情修改(如short_open_tag = On等)。

        恩,php要做的配置也就這麼多了,下麵是apache的一係列配置:

       a. 虛擬主機配置

       <Directory "/home/admin/profiler/www">
               AllowOverride all   
               Require all granted
       </Directory>
       <VirtualHost *:9898>
               DocumentRoot /home/admin/profiler/www
       </VirtualHost>

     備注:2.4之前使用的訪問控製命令如下:

        Order allow,deny

        Allow from all

      現在,隻需要Require all granted就搞定了

     b. Php handler配置

        <FilesMatch \.php$>
              	SetHandler application/x-httpd-php
       	</FilesMatch>
     	<FilesMatch "\.ph(p[2-6]?|tml)$">
    		SetHandler application/x-httpd-php
	</FilesMatch>
	<FilesMatch "\.phps$">
    		SetHandler application/x-httpd-php-source
	</FilesMatch>
	<IfModule dir_module>
    		DirectoryIndex index.php index.html index.htm
	</IfModule>

備注:LoadModule php5_module modules/libphp5.so,由於你指定了apxs2目錄,php安裝過程中也一並幫你搞定了

c. 與profiler應用相關的一些權限設置

         chmod 766 tmp

         chmod 766 results

         chmod 766 work/jobs

         chmod 766 work/video

         chmod 766 logs

三.收工

 成功後,截圖如下:


參考文獻:

1.https://httpd.apache.org/docs/2.4/install.html 

2.https://www.php.net/manual/en/install.unix.apache2.php 

3.https://httpd.apache.org/docs/2.4/upgrading.html 

4.https://xdebug.org/docs/install

5.https://arturito.net/2011/05/21/local-and-remote-php-debuging-in-netbeans-with-xdebug-on-google-chrome-just-like-in-visual-studio/

6.https://netbeans.org/features/php/

7.https://docs.activestate.com/komodo/6.0/debugphp.html

8.https://www.netperf.org/netperf/training/Netperf.html

9.https://www.ibm.com/developerworks/cn/linux/l-netperf/

10.https://www.ibm.com/developerworks/cn/linux/l-hisock.html

最後更新:2017-04-02 18:44:44

  上一篇:go LayerDrawable層疊樣式layer-list
  下一篇:go java中的this關鍵字