Pivotal Knowledge Base


Using your own version of PHP with vFabric Web Server under Linux/Unix (2032050_draft)


To use separate PHP execution out from your webserver, you may use mod_fcgid to link your web server to your desired PHP installation.

This article discusses a Linux/Unix environment. For information about a Windows environment, see Using your own version of PHP with vFabric Web Server under Windows.


This article assumes that you have installed vFabric Web Server in /opt/vmware/vfabric-web-server and want to use php/php-cgi from an instance defined in /usr/bin. To do so, modify the files and directories specified below to match your own installation:
  1. Install the desired version of PHP, either via your operating system update mechanism, or by compiling a source download from http://php.net/
    1. As part of this, you need to have a FastCGI-enabled executable. The default for this is is /usr/bin/php-cgi, but these directions can be adjusted to match your installation.

      • php-cgi may not be part of a base PHP package provided by your OS.

        Example: Red Hat Enterprise Linux 5 comes with the separate package php-cli (or php53-cli).

      • If you are compiling PHP 5.3 from source, add --enable-cgi to the configure options to create php-cgi.

    2. You need to know the location of php.ini. The default location is is /etc/php.ini, but these directions can be adjusted to match your installation.

    Note: PHP should be non-thread-safe for best performance.

  2. Create a FastCGI wrapper script for use by mod_fcgid. This script can be used to specify environment variables.

    # Set desired PHP_FCGI_* environment variables.
    # Example:
    # PHP FastCGI processes exit after 500 requests by default.

    # Replace with the path to your FastCGI-enabled PHP executable
    exec /usr/bin/php-cgi

    Save the script as as /usr/bin/php-wrapper.

  3. Configure mod_fcgid into your instance.

    1. Add these lines to /usr/local/ers/servers/instance/conf/httpsd.conf:

      LoadModule fcgid_module "/usr/local/ers/apache2.2/modules/standard/mod_fcgid.so"
      <IfModule mod_fcgid.c>
          AddHandler fcgid-script .php
          FcgidInitialEnv PHPRC "/etc/php.ini"
          FcgidInitialEnv PATH "/opt/vmware/vfabric-web-server/httpd-2.2/bin"
          # How many requests a process should handle before recycling itself:
          FcgidMaxRequestsPerProcess 10000
          # Should match or exceed the number above
          FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 10000
          # Max PHP requests to handle at a time:
          FcgidMaxProcesses 10
          FcgidIOTimeout 120
          FcgidIdleTimeout 120
          FcgidWrapper "/usr/bin/php-wrapper" .php
          AddType application/x-httpd-php .php

    2. Add Options ExecCGI in the directory section where you want PHP to be enabled.

      Example: Add it to the <Directory "/opt/vmware/vfabric-web-server/instance/htdocs/"> section, so that it looks like this:

      Options Indexes FollowSymLinks Includes ExecCGI

  4. To verify that the instance works with your new PHP, create the file /opt/vmware/vfabric-web-server/instance /htdocs/info.php with exactly these contents:

  5. Start the instance ( bin/httpdctl start). In your browser, navigate to page created on your server in step 4.

    Example: http://localhost:8080/info.php

The standard PHP Information screen is displayed. The Server API parameter is CGI/FastCGI and indicates your version of PHP (under Core).

When looking at a system process tree (ps faxw), the /usr/bin/php-cgi process is running under one of the httpd child processes. This is only created after a PHP request has been served.

In the /opt/vmware/vfabric-web-server/instance/logs/error_log file, there are [notice] messages. These indicate that mod_fcgid is configured and a child process has been started.

Additional Information

For more information about configuration details, see the mod_fcgid documentation.

For more information about the FastCGI standard itself, see the FastCGI web site.

Note: The preceding links were correct as of July 25, 2012. If you find a link is broken, provide feedback and a VMware employee will update the link.

©VMware 2013


Powered by Zendesk