The PHP-FPM's homepage http://php-fpm.org/ states that it is part of PHP since PHP 5.3.3. Now, I was wondering, when I download the newest PHP binaries from php.net, there is no php-fpm in it. How do I get it? Is it even available for Windows?
Here how to setup php-fpm on Windows:
Download the .zip file from http://windows.php.net/download/. The .zip file should be VC9 which has the FastCGI file (php-cgi.exe). Don't download VC6, and don't download the .msi file because it requires that you have IIS setup already in order to install php-fpm. The zip file contains the php-cgi.exe which is what you need for php-fpm. I downloaded a slightly older version, php-5.3.10-Win32-VC9-x86.zip, from here http://windows.php.net/downloads/releases/archives/ because I wanted to match the version running on my production server.
Unzip the file, e.g. unzip into C:\php-5.3.10-Win32-VC9-x86
Edit the php.ini file as needed. What I did:
# nginx security setting
cgi.fix_pathinfo=0
extension_dir = "C:\php-5.3.10-Win32-VC9-x86\ext"
enable the following modules by uncommenting them:
extension=php_curl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
Create a .bat file somewhere, e.g. start-php-fcgi.bat in webserver directory or in the PHP directory:
#ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=C:\php-5.3.10-Win32-VC9-x86;%PATH%
C:\php-5.3.10-Win32-VC9-x86\php-cgi.exe -b 127.0.0.1:9123 -c C:\php-5.3.10-Win32-VC9-x86\php.ini
Double click the .bat file to start php-fpm. A window will popup and stay open while its running. Its kind of annoying, but just haven't looked into setting it up as service yet.
Configure your webserver. If you wish to use it with nginx, here a config sample for 127.0.0.1:9123:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Old as this post is I have to weigh in here because what has been posted here is not PHP-FPM, it's running PHP using Fast-CGI.
Yes PHP-FPM stands for PHP-FastCGI Process Manager and so implements FastCGI but you are forgetting that FPM is much more than that as it contains process management features that are not managed by the webserver.
On *nix systems PHP-FPM has a separate process that manages the PHP child processes and has a detailed configuration to specify how these processes are managed. For details on these features read here
Launching a CGI process on windows is not the same thing. It does not spaw worker processes or dynamically scale them or allow multi-threading.
There is no PHP-FPM for windows yet.
http://php.net/manual/en/install.fpm.php#121725
However as suggested, you may launch a CGI process if you wish.
Alan's answer is a great start. However, for Apache 2.4 and later you do not need to run PHP-FPM as a separate service, you can use mod_fcgid to handle everything within Apache.
Here is an example configuration:
LoadModule fcgid_module modules/mod_fcgid.so
FcgidInitialEnv PHPRC "c:/php"
FcgidInitialEnv PATH "c:/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 500
<Files ~ "\.php$">
AddHandler fcgid-script .php
FcgidWrapper c:/php/php-cgi.exe .php
</Files>
Note, this is based on a post in Apache Lounge. As helpful as it was, their version had quotes around c:/php/php-cgi.exe and if you do that it WILL NOT START php-cgi.exe, at least on Windows Server 2012, and you get HTTP 500. Took me a painful few days to figure that out.
Starting PHP v5.3.3, FPM Server-API [SAPI] support has been integrated into core PHP. This means, you can take PHP's source codes and compile and build them with FPM-SAPI [using --enable-fpm configuration parameter] support, instead of let's say Apache SAPI [--enable-apx2]. As shown in PHP-Wiki you can build PHP almost the same way you do in *nix systems - that is, configuration-wise. I would suggest you learn the ins and outs of building PHP in *nix systems first, and even try to do it yourself [usual configure, make and make install pattern], and then try to utilize the experience gained from it to build on Windows environment.
In addition to --enable-fpm configuration parameter, there are two additional parameters as well: --with-fpm-user=USERNAME_HERE and --with-fpm-group=USERGROUPNAME_HERE. These two work in *nix environment, but may not be available in Windows.
Overall, I am pretty sure you can build your own PHP-FPM server app on Windows using Visual Studio IDE. There are no official PHP-FPM builds as of the date of this writing.
EDIT 1: Ok, guess I might be wrong re the possibility of building PHP-FPM on Windows, since this SAPI uses libevent component from *nix environment. Guess you will have to stick with Cygwin-bundled installation after all.
PHP-FPM is only available to linux as of now. There are some sites that provides a tutorial on how to get php-fpm to run on windows, under cygwin. You can try those guides.
On Windows, when you run PHP with IIS and install the "PHP FastCGI" module, you get similar functionality to what is explained about PHP-FPM. In other words, this is not the official PHP-FPM code base, but just similar functionality.
For one, IIS would spawn multiple php-cgi.exe processes (worker processes). And any PHP requests that come in will be handed down to a worker, IIS will dynamically spawn more workers depending on the server resources. These settings are configurable under the "Fast CGI" options for the server tree node on IIS.
That said, I believe performance-wise the php-cgi.exe is not on par with Apache servers.
You can view the installation procedure for IIS 7 here: https://learn.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis
FastCGI addresses the performance issues that are inherent in CGI by providing a mechanism to reuse a single process over and over again for many requests. Additionally, FastCGI maintains compatibility with non-thread-safe libraries by providing a pool of reusable processes and ensuring that each process handles only one request at a time.
PHP-FPM uses mainly *NIX specific features and is not likely to ever be ported to Windows. In the end there really isn't the motivation, especially when considering php-cgi was developed to allow Windows specific services to configure it as a fork pool. Yes, they have their differences, but not enough so to push the community into a complete rewrite of PHP-FPM.
Keep in mind that php-cgi on Windows is not just multiple instances of a CGI, but uses a Windows managed pool of forked FastCGI processors which use the same architecture of PHP-FPM. Multiple processes complete the module initialization of PHP, and from these multiple forks are maintained (and restarted when needed) to handle requests. php-cgi hasn't been a CGI since at least as early as PHP3.
Related
I have been using Apache on Windows (+PHP +MySQL) for a long time now. Lately, I decided to have the configuration files of Apache, PHP and MySQL in one directory, outside of the installation folders of any of them.
With PHP it works by setting PHPIniDir in Apache's httpd.conf
With MySQL it works by setting the --defaults-file=<path/to/my.ini> option while installing on the command line as a Windows service.
With Apache itself, I haven't been able to find a way. Is it possible to choose an arbitrary location or name for the httpd.conf file? And how?
Thank you.
you could use "..-f httpd.conf" on startup. see http://httpd.apache.org/docs/current/de/invoking.html
Regards
I'm trying to set up a development server with PuPHPet, which is essentially just a pre-made build of Vagrant with PHP, Nginx and a few other things pre-installed.
I'm having a weird caching issue with my .css files.
When I access my .css file directly at my dev URL, it shows part of the file. This is the file as it was originally before I started editing it. You will notice from my screenshot that I've deleted the entire contents of the file and replaced it with the numbers "12345". When I refresh the .css file in my browser, I see the first 5 characters of the old file. Adding an extra character restores an additional character from the old file.
Restarting nginx does not clear the cache. Ctrl+F5 does not clear the cache. Checking the file contents from vagrant ssh:
[08:11 PM]-[vagrant#precise64]-[/var/www/public/css]-[hg default] B
B$ cat main.css
12345
I can see the file is up to date. The file it's partially displaying simply does not exist. My best guess is it's reading the length of the file on disk, and then pulling the actual contents from memory.
The built-in PHP 5.4 development server does not have this problem, so I'm pretty sure Nginx is the culprit.
How can I get Nginx to behave in a sane fashion?
Most probably it's this know VirtualBox bug with the sendfile system call.
Try disabling sendfile in nginx config:
sendfile off;
(In apache EnableSendfile off)
I'm trying to install and configure Symfony2 on my server.
My website is on a shared hosting plateform therefore have limited access to root level, apache & php.ini files...
I downloaded then extracted symfony2 files on my dev environment:
www/
dev/
symfony/
app/
bin/
web/
...
When I navigate to http://dev.mydomain.com/symfony/web/config.php I get some recommendations:
Install and enable a PHP accelerator like APC (highly recommended).
Upgrade your intl extension with a newer ICU version (4+).
Set short_open_tag to off in php.ini*.
Set magic_quotes_gpc to off in php.ini*.
Being on a shared hosting plateform I'm not allowed to modify/download the necessary files to fix those recommendations (which I believe shouldn't block the install).
I follow the link "Bypass configuration and go to the Welcome page" which sends me to http://dev.mydomain.com/symfony/web/app_dev.php/
The server throws a 500 Internal Server Error.
Any advice on how to fix that issue would be very much appreciated.
Thanks,
John
When it happened to me I forgot to tell my FTP client to transfer also invisible file (.htaccess) OR permissions on /web folder are not correct
Debian Etch/Apache 1.3
I have one server happily running TWiki, and want to replicate it on a 2nd server. Apt-get install twiki runs OK except for an apache2 failure. It does appear to have worked out it need to use apache 1.3 though I could be persuaded otherwise!
However, when I got to
myhost/twiki
it successfully goes to /twiki/bin/view.pl/XXX/WebHome but returns
The requested URL /twiki/bin/view.pl/XXX/WebHome was not found on this server.
Apache log shows
File does not exist: /var/www/packages/twiki/bin/view.pl/XXX/WebHome
On the working system, there is no .pl extension on the 'view' which may be vital. Also, I can't see why the packages get installed to the packages dir, but I have moved twiki dir under this. Not sure if the apache config needs to be changed.
It would make life simpler if I could remove the 'packages' dir from things but can't see how.
Any help on this appreciated!
Thanks,
Martin
mmm, I stopped maintaining the twiki packages when we forked the project to foswiki.
however. I don't recal ever putting the twiki files into /var/www/packages.
where are you getting the twiki packages from ?
http://fosiki.com/blog/2007/04/22/debian-repository-for-twiki/ are probably more up to date (than the deb in debian's own repository) - and includes plugins, but i've not used / tested anything since 2008 - but that repo does include all the plugins from twiki.org.
i think your dependancy on apache 1.3 issue is because this is a quite old debian package -
http://distributedinformation.com/experimental/dists/experimental/main/binary-i386/Packages depends on apache2
if you're rolling your own, there's an apache cfg generator topic on twiki.org somewhere - we've made many updates to our version on foswiki.org
Sven
I'd like to use mercurial on a Windows server. Since I want to pull and push via http, hg serve seems the easiest solution. It works fine, but I have restart it after each reboot, so I need it as a Windows service. Installing it manually with sc create ... didn't work, it created a service that throws an error when I attempt to start it. I found some references to this problem
https://bitbucket.org/tortoisehg/stable/issue/1245/configure-hg-serve-to-run-as-a-windows-service-from
https://bitbucket.org/andrearicossa/hgservice
but they are poorly documented if at all. (Of course, I could install a web server and use hgweb, but it seems even more complicated.) Do you have any experience how to set up easily hg serve ... <many args> as a Windows service?
UPDATE:
Thanks for the different approaches. We stayed with hg serve, the windows-guy at our company managed to install it as a not-quite-proper service.
Using a web server such as apache/lighttpd/iis gives a lot of features such as authentication or HTTPS support. But 'hg serve' is a simple and fast solution. Furthermore, 'hg serve' can serve multiple repositories. But hg serve cannot itself be run as a Windows service because it cannot respond to the Windows control commands. So using HgService is a good solution to make 'hg serve' a real Windows service.
Here is an example of my configuration. I followed following steps:
Install TortoiseHG
Install HgService
Create "C:\Repositories" folder and put needed repos into it.
Create "C:\Repositories\hgweb.config" with following contents:
[paths]
/ = C:\Repositories\*
[web]
style = monoblue
Modify HgService.exe.config in C:\Program Files\Mercurial\HgService
<add key="CommandLine" value="hg.exe"/>
<add key="CommandLineArguments" value="serve --prefix=/hg --address 0.0.0.0 --port 80 --web-conf c:\Repositories\hgweb.config -A access.log -E error.log" />
Start the service
Hope this sequence of action will be helpful to you also.
Or you could use the SCM-Manager
You should check out Jerremy Skinner his blogpost on this subject. He explains how you can host Mercurial repositories on IIS7 and use some nice url-routing.
I did it on my machine and it works like a charm. It takes some configuration, but it's worth it.
1 error in his post I noticed was that he's writing about a hgwebdir.cgi, but I couldn't find that one. I did find a hgweb.cgi, so did the copy-pasting with this file.
An Apache-based alternative: HgServe - Mercurial Repository Server for Windows on Apache
hg serve works fine with NSSM !