• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            xiaoguozi's Blog
            Pay it forword - 我并不覺的自豪,我所嘗試的事情都失敗了······習慣原本生活的人不容易改變,就算現狀很糟,他們也很難改變,在過程中,他們還是放棄了······他們一放棄,大家就都是輸家······讓愛傳出去,很困難,也無法預料,人們需要更細心的觀察別人,要隨時注意才能保護別人,因為他們未必知道自己要什么·····

            Recently I've come face-to-face with a significant processing task for a web application written in PHP.  I haven't worked with process control very much, so I started researching ways of distributing the calculations to multiple processes.  PHP offers several libraries for doing this (pcntl, POSIX), but it quickly became clear that if you're running Windows these libraries are not an option, and unfortunately at work I have a Windows machine.  After a lot more research, I came across Gearman.

            Gearman is essentially a distributed processing framework, and seems to have community support for many programming languages.  It consists of two main components: the job server, and a Client and Worker API.  The Client and Worker API can be used in a wide variety of languages, but the job server is only available as a C library or a Perl library.  This makes it a bit tougher to get the server running on Windows, especially when you start running into some of the dependencies that it requires to build.  As well, the Client/Worker API for PHP can only be installed as a PECL extension, or a very-out-of-date PEAR extension called Net_Gearman.

            Nonetheless, after yet more research I decided that I would give it a shot by using Cygwin to get the job server running (if you haven't used Cygwin before, be sure to read about it before attempting to install Gearman this way), and PEAR to use the API.  Pre-built PECL extensions aren't available for Windows anymore, and the build process for PHP extensions can be pretty painful, so it makes PEAR look good by comparison even if the code will be out of date.

            I had a pretty frustrating time finally getting everything up and running due to various dependency issues, so I went back through the whole process and wrote it out step-by-step.  I used a Windows XP SP3 machine for this, but I also got it working on a Windows 7 machine as well.

            Installing the Gearman job server (gearmand) on Windows with Cygwin

            Installing Cygwin

            1. If you don't have Cygwin already, you can get it from http://www.cygwin.com.  The setup file is located here, and the setup process is pretty straightforward; run it and follow the wizard.  Full installation instructions are available at the Cygwin site.
            2. Keep the Cygwin setup.exe file handy after you've installed the default software packages, as you'll need it in the future to add packages, similar to apt-get, yum, and other Linux/UNIX package managers.
            3. Cygwin installs with some basic packages, including a Cygwin Bash Shell that goes into your Start Menu.  I prefer the mintty emulator instead, as it has less of a DOS Command Prompt feel and better terminal features.  Feel free to use whatever shell you like of course.  You can get mintty by re-running the setup.exe, and at the package selection screen, type 'mintty' into the Search bar at the top left.  Expand the "Shells" category, and click on the word "Skip" under the "New" column beside the mintty package to select it before continuing the install process.

            Installing Cygwin Package Dependencies needed for Gearman

            If you're not already in the Cygwin setup, re-run the Cygwin setup.exe and go through to the package selection screen.  The following is a list of dependency packages you will need in order to build the Gearman job server (gearmand).  None of these packages were installed by default with Cygwin:

            • gcc
            • make
            • libuuid1-devel
            • libiconv

            There's a good installation tutorial here that walks through getting gcc and make installed for people unfamiliar with Cygwin.  Finding the others is pretty straightforward, the Search bar in the package selector works well.

            Installing libevent

            Gearmand requires an event notification library called libevent that you cannot get as a Cygwin package, which means it has to be installed from source.  You can get the source here.

            1. Download and unpack the latest libevent stable release.  At the time of this writing, I used libevent-1.4.14b-stable.
              NOTE: Download and unpack to a directory that does not contain spaces in the name, such as "C:/cygwin/home/Zombat/libevent-1.4.14b-stable".  If you unpack to something with spaces like "C:/Documents and Settings/Zombat/", the build process might not be able to install libevent correctly (libtool has a hard time with spaces)!
            2. Open a Cygwin shell and cd to the unpacked libevent directory.
            3. Run the following commands:

            ./configure
            make
            make install

            libevent should now be installed and ready to be used when compiling the Gearman job server.

            Installing the Gearman job server, gearmand.exe

            1. Download and unpack the C implementation of gearmand from http://gearman.org/index.php?id=download
            2. Open a cygwin shell and cd to your unpacked gearmand directory.  Same rules apply as before, make sure you've unpacked in a directory with no spaces in the path!  libtool hates that, and your build may fail.
            3. Run the following commands:

            ./configure
            make
            make install

            The Gearman job server should now be installed and ready to use!  Mine was installed at /usr/local/sbin/gearmand.exe, and running it with a "triple verbose" flag (-vvv) should produce the following:

            gearmand.exe startup debug output

            That's it for the job server.  When you want to start it, simply open a Cygwin shell and run gearmand.exe.  Running it with the -d flag will cause the server to run as a daemon in the background, and running with --help will show you the full option list.

            Installing the Gearman Client and Worker API (Net_Gearman)

            I chose to install the PEAR Client and Worker API, as it is native PHP and doesn't involve compiling PECL extensions.  The PEAR package is called Net_Gearman, and was originally written by Joe Stump at Digg.com.  It is old and out of date now, although there appears to be a more recent fork at http://github.com/brianlmoon/net_gearman.  I stuck with the older version, as I suspect it will meet my needs, and was readily available as a PEAR package.

            This also makes installation relatively painless.  Assuming you've previously set PEAR up, then all you have to do is open a command window (not a Cygwin shell) and run:

            pear install Net_Gearman-alpha

            The "-alpha" portion is necessary, as Net_Gearman apparently never made it to a stable release version.  That being said, it has functioned well for me so far.  Perhaps someone will pick the project up in the future.

            I'll write more about getting started with the Client and Worker API in the next article, so we can actually use Gearman to get some work done.

            轉自:
            http://www.phpvs.net/2010/11/30/installing-gearman-and-gearmand-on-windows-with-cygwin/
            posted on 2012-12-28 11:17 小果子 閱讀(2618) 評論(0)  編輯 收藏 引用 所屬分類: 學習筆記 、C++
            精品多毛少妇人妻AV免费久久| 久久免费精品一区二区| 狠狠色丁香婷婷综合久久来| 99久久99久久精品国产| 久久久久久久女国产乱让韩| 国产亚洲婷婷香蕉久久精品| 99久久精品无码一区二区毛片 | 2020久久精品国产免费| 欧美午夜精品久久久久久浪潮| 久久夜色精品国产网站| 国产精品gz久久久| 97久久超碰国产精品旧版| 久久综合久久鬼色| 国产香蕉97碰碰久久人人| 久久精品国产2020| 久久久无码精品午夜| 99国产欧美精品久久久蜜芽| 亚洲人AV永久一区二区三区久久| 久久精品国产精品亚洲人人| 一本久久久久久久| 久久香综合精品久久伊人| 久久强奷乱码老熟女网站 | 日本WV一本一道久久香蕉| 久久精品aⅴ无码中文字字幕不卡| 久久亚洲精品成人AV| 亚洲国产成人久久笫一页| 91精品无码久久久久久五月天| 亚洲日本va中文字幕久久| 久久这里有精品| 国产免费久久精品99re丫y| 国产精品va久久久久久久| 久久亚洲国产中v天仙www | 欧美与黑人午夜性猛交久久久| 69国产成人综合久久精品| 久久男人Av资源网站无码软件 | 亚洲午夜久久影院| 亚洲va国产va天堂va久久| 久久久一本精品99久久精品88| 久久人人添人人爽添人人片牛牛| 亚洲精品无码久久毛片| 久久久国产99久久国产一|