Operating Systems: AIX, HP-UX, Linux, Solaris, Windows, z/OS
Creating PHP servers and PHP dynamic clusters
By creating PHP Hypertext Preprocessor (PHP) servers or dynamic clusters, you can deploy PHP applications. You can use the product to manage these applications and servers.
Before you begin
- Install Apache HTTP Server and PHP on the nodes that you want to host PHP servers. The supported Apache HTTP Server versions are 1.3 (all releases), 2.0 (all releases), and 2.2 (all releases). The supported PHP versions are 4 and 5 (all releases). Default server templates are provided for these combinations of Apache HTTP Server and PHP.
- Federate these nodes into the cell.
- Attention: If you are using Apache HTTP Server Version 2.2 and PHP V5.2 (all releases), then perform some manual edits to the httpd.conf file. Instead of performing these edits each time you create a PHP server or dynamic cluster, create a PHP server with the APACHE22_PHP5 template, edit the httpd.conf file, and create a server template from that server, which you can use to create the rest of your PHP servers.
You can also choose an existing server to use as the template for a new PHP server by using the PHP server administrative tasks, or by selecting a predefined server instead of a template. You cannot select a user-defined template from the PHP server wizard.
About this task
A PHP server is defined in WebSphere® Virtual Enterprise as an Apache HTTP Server with the mod_php module. You can define a PHP server on nodes that are running WebSphere XD or the middleware agent. PHP server configuration consists of three documents: the server.xml, httpd.conf and php.ini files. The server.xml file contains properties that describe the Apache and PHP runtime locations and server operations. The httpd.conf file is the Apache HTTP Server configuration file that includes PHP modules. You can define variables in the administrative console to be used in the httpd.conf file. The php.ini file contains configuration data that is used by the PHP interpreter.
Procedure
- Configure the middleware descriptors so that you can run discovery to find the Apache and PHP runtimes. In the administrative console, click System administration > Middleware descriptors > middleware_platform_name. The default locations are listed in the apacheWebServerRuntime and phpRuntime middleware descriptors. The discovery service uses middleware descriptors to define where to look for the Apache and PHP runtimes. Verify that the middleware descriptors contain the correct installation locations for your environment. Use a semicolon delimiter for Windows® paths, and a colon delimiter for UNIX® paths.
- Run discovery to find the PHP and Apache HTTP Server runtimes on the nodes to host PHP servers. Discovery runs automatically when the middleware agent starts. Discovery also runs at a predefined time interval that you can specify in the middleware descriptor. However, you can also invoke discovery:
Only the default installation locations are listed in the apacheWebServerRuntime and phpRuntime middleware descriptors. You can modify the middleware descriptor so that the discovery looks for the correct installation location.
- In the administrative console, click System administration > Middleware nodes.
- Select the nodes to run through discovery, and select the Run discovery operational action.
- Click Run.
- Verify that the discovery service found the run time. In the administrative console, click System administration > Middleware nodes > node_name > Node Installation Properties. If any runtime environments exist, then properties that begin with APACHE or PHP strings are displayed.
- Create PHP deployment targets. The deployment target is where you deploy the PHP application. You can create individual PHP servers or PHP dynamic clusters.
- Create a PHP server.
- In the administrative console, click Servers > Add a server. Choose Create a new server instance, and select the PHP server type. You can also click Servers > Other middleware servers > PHP servers > New.
- Select the node on which you want the PHP server to run. This node must have the PHP and Apache HTTP Server runtime environments.
- Choose the appropriate Apache HTTP Server and PHP runtime environments for the node.
For both runtimes, a list of variables displays at different levels of granularity such as APACHE, APACHE_2, APACHE_2_0, and APACHE_2_0_59. With these variables, you can select the runtime that corresponds to either a specific or a general version that you need. For example, the most generic variables are APACHE and PHP, which always point to the newest versions that are installed on your node. Select these variables if you always want to use the newest runtimes and you do not need a specific version. You can also choose a runtime that is based on major version such as APACHE_2. With this variable, you can use any Apache 2 runtime. The newest Apache 2 runtime that is installed on your node is used. By always using the newest Apache V2 runtime, you can upgrade between minor versions without any manual server configuration changes. If you update from Apache V2.0.58 to Apache V2.0.59 and add the new runtime location to the middleware descriptor, the runtime service automatically detects the newer runtime and updates the server configuration to point to the new runtime.
- Choose the PHP server template.
- Confirm and save the PHP server.
- Create a PHP dynamic cluster.
- In the administrative console, click Servers > Dynamic clusters > New.
- Choose the PHP server dynamic cluster type, and name the dynamic cluster.
- With PHP servers, use automatic membership. Define a membership policy to identify which nodes host the PHP servers in the dynamic cluster. These nodes must have the PHP and Apache HTTP Server runtime environments installed. For example, you might use the following membership policy:
node_property$APACHE IS NOT NULL and node_property$PHP IS NOT NULLRestriction:PHP dynamic cluster members must be at the same two digit Apache version and one digit PHP version. This limitation is caused by the differences in configuration between releases. If multiple versions are installed on your system, update the membership policy to include the version number, like in the following example:
node_property$APACHE_2_0 IS NOT NULL and node_property$PHP_4 IS NOT NULL- Select the server template for the PHP runtime and Apache HTTP Server runtime that you are using.
- Specify other dynamic cluster properties.
- Save your PHP dynamic cluster.
- If you are using PHP V5.2 (any release), then you must manually edit the httpd.conf file to use the php5apache2_2.dll module, instead of the default php5apache2.dll module.
- Verify that you created the PHP server with the APACHE22_PHP5 template.
- Open the httpd.conf file. In the administrative console, click Servers > Other middleware servers > PHP servers > php_server_name > External configuration. Choose the httpd.conf file, and click Retrieve.
- Modify the file to use the php5apache2_2.dll module. Search for the following string in the httpd.conf file, where php_server_root is the location of your PHP server:
LoadModule php5_module "php_server_root/php5apache2.dll"Edit this line to reference the php5apache2_2.dll module. See the following example:LoadModule php5_module "php_server_root/php5apache2_2.dll"- Apply and save your changes.
- Optional: To avoid repeating these steps for each PHP V5.2 server that you create, make a template of your current server that you can use when you create subsequent PHP servers. In the administrative console, click Servers > Other middleware servers > PHP servers > Templates > New. Select the server from which you want to create a template, specify properties for the template, and save your changes. Choose this template when you create other PHP servers or dynamic clusters. You can also choose an existing server to create your new PHP server from the PHP server wizard.
- Optional: Update the HTTP and HTTPS ports for your servers. The default port is uniquely generated. modifying the port changes the port for the Apache server, which updates the httpd.conf file.
- In the administrative console, click Servers > Other middleware servers > PHP servers > php_server .
- Edit HTTP connector or HTTPS connector. Click OK and save and synchronize your changes.
What to do next
Deploy PHP applications to your PHP servers and dynamic clusters.
Previous topic
Federating middleware nodesNext topic
Deploying applications with defined service levelsNext topic
Deploying PHP applications
Related concepts
Middleware nodes and servers
Related tasks
Creating dynamic clusters
Creating middleware server templates
Configure middleware descriptors Adding complete life cycle middleware servers
Related reference
PHP server administrative tasks
Dynamic cluster administrative tasks