php5-fpm以及fcgiwrap在ubuntu下的安装方法

网上搜索 大部分都是讲怎么编译安装的, 自己也搜索过ubuntu的源, 没有单独的php5-fpm的安装包, 不过按照一个老外的安装方法, 还是可以不用编译的。 

第一步: 

aptitude install python-software-properties 

第二步: 

add-apt-repository ppa:brianmercer/php 

第三步: 

aptitude -y update 

第四步: 

aptitude -y install php5-fpm 

安装好后, 配置一下 /etc/php5/fpm/php5-fpm.conf 

pm.max_children 设置大一点, 默认是10, 这是php5-fpm的进程数。 

然后就是 service php5-fpm start 启动。 

php5-fpm是可以平滑重启的,修改了php.ini文件后, 用service php5-fpm reload 就能重新加载配置文件。 

I've been using the dotdeb.org pacakges for my ubuntu 9.10 servers and they've been running well, except for some necessary patches to contrib modules for php 5.3. 

Now ubuntu 10.04 lucid is out and has php 5.3.2 in it. While php5-fpm won't be included in an official release until at least 5.4, it has become a part of official php development and is contained in the php version control. 

In order to ease installation and upgrade, I've created a debian style .deb package for php5-fpm on launchpad at https://launchpad.net/~brianmercer/+archive/php/. Unlike the dotdeb package, this one is adapted from the official ubuntu lucid source package and so has identical patches and compile options to the ubuntu 10.04 cgi and cli sapis. 

This package will only work on the Ubuntu 10.04 lucid release.

In order to install the package, you need to add the following to your /etc/apt/sources.list file:
deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main

and if you don't want to get the unsigned package warnings, add the launchpad key for the ppa with this command: 

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8D0DC64F 

Then it's the usual: 

sudo aptitude update
sudo aptitude install php5-fpm

You can then start (or stop or restart) php5-fpm with:

sudo service php5-fpm start

The new package works with all the usual ubuntu php extensions like php5-mysql, php5-gd, php-apc and php5-memcache. 

The config file is now in an ini style format instead of the xml format and is located at /etc/php5/fpm/php5-fpm.conf. By default it listens on 127.0.0.1:9000 but I typically change the conf to use a unix socket at /var/run/php5-fpm.sock. If you use a socket, you should also uncomment the user and group and mode in the conf file. (I also change the mode to 0660) 

I've set the package to start up 10 children by default. You can increase or decrease that amount depending on your memory constraints. There is a "dynamic" setting in the conf file with starting number, max number, max idle, etc. This "apache-like" system will start and stop children as needed depending on load. However, it is still experimental and it may be better to stick with the static setting for now. 

I've also set up a second repository at https://launchpad.net/~brianmercer/+archive/fcgiwrap with fcgiwrap. nginx does not have the built in ability to act as a cgi gateway for perl scripts, etc, the way that apache and most other web servers do. In order to use things like awstats.pl or nagios you need to proxy those requests to a backend. I previously ran thttpd and let nginx proxy *.pl and *.cgi requests to thttpd. (boa also worked). However, Grzegorz Nosek has written a small wrapper script in C to handle these requests which works well. http://nginx.localdomain.pl/wiki/FcgiWrap 

I've gone ahead and made a debian package from his code and put it up at https://launchpad.net/~brianmercer/+archive/fcgiwrap and it can be installed the same way as php5-fpm by adding the following to /etc/apt/sources.list:

deb http://ppa.launchpad.net/brianmercer/fcgiwrap/ubuntu lucid main
deb-src http://ppa.launchpad.net/brianmercer/fcgiwrap/ubuntu lucid main

and 

sudo aptitude update
sudo aptitude install fcgiwrap

My fcgiwrap package relies on spawn-fcgi but it has its own start/stop init script so you can use

service fcgiwrap start

It runs on 127.0.0.1:8000 by default but you can change the config file at /etc/default/fcgiwrap to also make it run as a unix socket at /var/run/fcgiwrap.sock. 

Then you can put a location in your nginx config such as

  location ~ (.cgi|.pl)$ {
#    auth_basic            "Restricted";
#    auth_basic_user_file  /var/private/htpasswd;  # somewhere outside the http root
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:8000;
#    fastcgi_pass unix:/var/run/fcgiwrap.sock; #if using unix socket instead of TCP
  }

You should be aware of the serious security implications of that section. You don't want someone uploading a nasty perl script to your server and running it. A section like that should only exist behind a protected subdomain or at least should have password authentication added to it. If you're only using awstats then instead of using the location above you can use one like this:

  location = /awstats.pl {
    gzip off;
    root /usr/lib/cgi-bin;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/awstats.pl;
    fastcgi_pass 127.0.0.1:8000;
#    fastcgi_pass unix:/var/run/fcgiwrap.sock;
  }

  location ~ ^/awstats-icon/(.*)$ {
    alias /usr/share/awstats/icon/$1;
  }

I hope these packages are useful and that they ease one of the complications of installing and using nginx. 
Login or register to post comments 
Comments 
php5-fpm for Debian Lenny 
Posted by omega8cc on May 23, 2010 at 4:41pm 

Thanks for this how-to, Brian. 

Since dotdeb.org has also php5-fpm for Debian Lenny and it works great, however still there are too many issues with PHP 5.3 in many contrib Drupal modules, so we are using it only for testing on our dev servers. 

Simple how-to for all Debian fans:

sudo echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list
sudo echo "deb-src http://php53.dotdeb.org stable all" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get -y install php5-cli php5-common php5-suhosin php5-memcache php5-imagick php5-apc php5-dev
sudo apt-get -y install php5-curl php5-gd php5-imap php5-mcrypt php5-mysql php5-xsl php-pear
sudo apt-get -y install php5-fpm php5-cgi
invoke-rc.d php5-fpm start

See also: http://www.dotdeb.org/instructions/ 

~Grace 

    Login or register to post comments 

I was using the dotdeb repos 
Posted by brianmercer on May 23, 2010 at 5:26pm 

I was using the dotdeb repos on ubuntu 9.10 for a while and they worked perfectly, and it's good of Guillaume Plessis to make those packages available. I also owe him thanks because I used his scripts to make my Ubuntu packages. 

To use the dotdeb packages on Ubuntu instead of Debian you have to manually install two packages:

http://us.archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4...
http://us.archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu...

and one more if you use php5-mycrypt: 

http://mirrors.kernel.org/ubuntu/pool/main/libt/libtool/libltdl3_1.5.26-... 

I repackaged php5-fpm for Ubuntu on a launchpad ppa for 3 reasons: 

First, I wanted to avoid the extra work for Ubuntu users of manually adding the packages above. 

Second, I wanted to have php built with the identical compile options and patches as Ubuntu's current 10.04 php. Guillaume uses the php bundled gd (which is not a bad idea) and also the mysqlnd native driver, whereas Debian and Ubuntu use the official gd and the libmysql driver. There are also several code patches that Ubuntu applies that Guillaume doesn't. I wanted my php-fpm to match the decisions of the Ubuntu packagers. 

Ubuntu has updated php5 twice this month to incremental releases php5-5.3.2-1ubuntu4.1 and php5-5.3.2-1ubuntu4.2 and I wanted to be able to track those patches immediately and add them to my php-fpm build. 

Third, I wanted the latest version of php-fpm. Guillaume is using the fpm patch from last year that has proved very stable but didn't receive full attention from the fpm originator Andrei Nigmatulin. By the time version 5.3 and 5.2.13 were released, Andrei had already stopped updating his great work. As far as I know, there's no dev maintaining the 5.2.x branch. 

Luckily, since then, fpm has been merged into the official php.net development trunk and is now actively maintained by Antony Dovgal and Jerome Loyet, two php.net devs. Jerome has put in some good work bringing in the apache-like dynamic child spawning, and Antony has been committing patches based on reported problems. They've also committed a conversion from an xml conf file to the ini format. 

I'm using the very latest svn development version of fpm to get the benefits of the new code and watchful eye of php.net devs. 

I completely agree with you about the state of Drupal contrib modules (and core) with respect to 5.3 compatibility. I'm up to nine patches that I have to apply now to core and to contrib modules that I use.

时间: 2024-09-29 07:24:25

php5-fpm以及fcgiwrap在ubuntu下的安装方法的相关文章

Ubuntu下SubVersion安装方法(摘抄)

今天,我得到领导的命令在ubuntu上搭建一个SVN服务器.对于我这个对Linux都不怎么熟的菜鸟而言,确实有一定的挑战. 于是我在网上查了很多资料,越看头越大.最后找到一篇关于在Window环境建SVN服务器的文章.我想,在windows下建与在ubuntu上应该差 不多.所以我说按着上面的步骤一步一步做.终于,还是搞定了!现在回想起来,在ubuntu上建一个SVN服务器还是非常简单的. 以下是摘抄的,并根据我自己的实际情况加以修改.原文:Subversion之路 服务器IP地址:192.16

ubuntu下如何安装codeblocks集成开发环境

codeblocks是一个十分优秀的C/C++开发IDE,虽然后起之秀codelite目前来看大有超越之势哦. 不过在ubuntu下安装codeblocks却比较麻烦,不像其他linux发行版,比如suse,debian和fedora等在官网上有现成的bin文件可以直接下载安装. 下面简单介绍下如何在ubuntu下快速安装最新的codeblocks: 1.加入ppa源: sudo add-apt-repository ppa:pasgui/ppa 2.更新ppa源: sudo apt-get u

ubuntu下rvm安装ruby报错

问题描述 ubuntu下rvm安装ruby报错 错误如下,在线等,谢谢 rvm install ruby-2.2 Searching for binary rubies, this might take some time. No binary rubies available for: ubuntu/14.04/x86_64/ruby-2.2.1. Continuing with compilation. Please read 'rvm help mount' to get more inf

ubuntu下怎么安装myBase.run文件

问题描述 ubuntu下怎么安装myBase.run文件 在官网上下载了一个myBase的linux版,解压后要运行myBase.run文件,已经给了可运行的权限了,但死活都运行不起来. 上网查资料已尝试的方法有: 1.先给权限:chmod u+x myBase.run或chmod +x myBase.run或chmod 777 /myBase.run,之后再./myBase.run还是不行 2.提示bin/sh解释器错误,又在文件尾写了:set ff=unix,或是下载了dos2unix,之后

在Ubuntu下如何安装VMware Tools

&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp;   在Ubuntu 下如何安装 VMware Tools 安装编译环境: sudo apt-get install build-essential linux-headers-`uname -r` 2.在VMware的菜单中,点击VM->Install VMware Tools,你将看到有光盘被加载. 解压缩VMwareTools*.tar.gz文件.执行命令

Ubuntu下手动安装jdk及配置

在ubuntu下可以通过多种方式来安装jdk,如使用Adept/新立得软件管理器在其中分别搜索"sun-java6-jre"和"sun-java6-jdk"并标记安装.通过apt-get命令来安装(sudo apt-get install sun-java6-jre.sudo apt-get install sun-java6-jdk).同样也可以通过从java官网上下载jdk安装文件进行手动安装(我下载的文件是:jdk-6u20-linux-i586.bin),这

【转载】Linux(ubuntu)下如何安装与卸载软件总结

刚开始使用Ubuntu的用户时常有这样的问题,我要安装新软件怎么办?.exe文件在哪里,怎么软件有这么多格式?RPM包,.tar.gz是什么?怎么就是安装不了啊?等等. 的确,在Windows下安装文件只需要双击即可,所以很多人在Ubuntu下觉得很不习惯.事实上,使用Ubuntu平台下的新利得软件包管理器安装大部分软件比在Windows平台下更加简单,操作更加容易.当然,也有很多软件Ubuntu的储藏库里面没有,而这些软件有着各式各样的格式,因而安装方法也都不一样.下面我就Ubuntu下安装软

ubuntu下AMP安装+webmin搭建web服务器例子

 一直用window的服务器系统,随着水平的提升,觉得window服务器越来越不能满足要求,大神们又都说Linux怎吗怎吗好,那决定从完全不懂Linux系统的角度,来研究一下Linux服务器系统. 我的目的很单纯,只是想用linux系统来发布网站系统,并不想过度的研究Linux安全什么的,好,开始吧. 各种Linux系统版本了解了一遍,我选择了ubuntu,你懂得,这个对菜鸟最友好,而且本地可以安装一个桌面版练手. 很容易就可以得到,下载地址:  http://www.ubuntu.org.cn

Ubuntu下如何安装视频转换工具 Selene

Selene 是一款自由开源视频转换工具软件,支持常见的视频和音频格式文件:OGG. OGV. MKV. MP4. WEBM. OPUS. AAC. FLAC. MP3 和 WAV 等.最新的版本是 Selene Media Encoder 2.5.2.支持 vp9 编码和 H.265/HEVC 编码. 安装方法,有PPA可用,Ubuntu 15.04.14.10.14.04.12.04 用户可安装,打开终端,输入以下命令: sudo apt-add-repository ppa:teejee2