Installing PHP language support in Zeuswebserver _php

Source: Internet
Author: User
Keywords support language installation PHP settings Fastcgi semfi
Tags php error
Zeuswebserver

Objective
Zeus is a very good web Server running under UNIX, and PHP is a very good background scripting language for UNIX. Both of these products are for a very favorite product. Why write such a howto? is because there are a lot of Web site scripts developed using PHP, and these programs run under the Zeus is also a very good choice. The purpose of this document is to enable everyone's PHP system to run well on the Zeus server.
Early I wrote an article integrating Zeus and PHP, it is mainly about how to use PHP fastcgi local call mode to run in Zeus, this howto is mainly about how to let PHP run in remote responders mode. Because this will be more scalable and efficient than the local approach.

Preparatory work
First you should Zeus the installation, and not too much about how to install and configure the Zeus server itself, because its installation and configuration is too simple.
If possible, it's a good idea to upgrade ports using CVSup.
For PHP dependent software if it can be installed in advance, then install from the ports. such as MySQL, GD and so on. Installing fastcgi
Note that if you install a PHP version that will be below 4.3.0, you need this step. The new PHP version already has a built-in fastcgi library. The method of installing fastcgi is very simple:

root@~ $CD/usr/ports/www/fcgi/
Root@/usr/ports/www/fcgi$make;make Install;make Clean
After compiling, we can see the libfcgi.a file in the/usr/local/lib directory and all the fastcgi header files in the/usr/local/include directory.

Compiling PHP
Compiling PHP can use the usual PHP compilation options, here is a configuration I used:

./configure--prefix=/usr/local/php--enable-fastcgi--with-mysql=/usr/local
Note that in PHP 4.3.0 or later versions are the--ENABLE-FASTCGI option used, and the previous version of PHP 4.3.0 should use the--with-fastcgi parameter.
The next is to install PHP into the system:
Make
Make install
Once the compilation is complete, let's test that the installed PHP works correctly:

root@~ $CD/usr/local/php/bin/
root@/usr/local/php/bin$./php
This will enter the PHP code input state, enter


Press ctrl-d after running to see that the information returned by PHP is correct.

Configure fastcgi/php
Configure fastcgi
Go to the Zeus Management console and open the Vhost configuration you want to configure. Enter the FastCGI setting in API support. In which to set:
Enabling support for FastCGI programs:enable
Set in configuring FastCGI Remote responders:
Directory Name:/usr/local/php/bin/php
Location:machine Name:localhost
Additional Methods Supported?:none
If your PHP application is not native, even if PHP is not installed on this machine, then set the docroot path parameter, it can not exist in the corresponding directory.
After the settings are complete, click the Apply button. Configure PHP parsing to point to
Enter the handlers settings in the URL handling. Set the following parameters in Adding a Handler:

File extension:php
Specify the path and filename of the handler, relative to the document root:/usr/local/php/bin/php
HTTP 404 Errors is handled by:the handler
Note that the Specify the path and filename of the handler, relative to the document root should be the same as the Directory name value you set up in the previous step.
After the settings are complete, click the Apply button.
After all the settings are complete, use the commit feature of Vhost to submit the changes and apply them. This Zeus set up the fastcgi and PHP related parameters.

Configuring fastcgi/php Boot
Create a new s05php file in the Rc.d directory of Zeus, with the contents:

#!/bin/sh

# Script to start and stop the persistent PHP runner for FastCGI.
# Please check the paths before use.

# FastCGI PHP Binary
fphpbin=/usr/local/php/bin/php

# location to place Semaphore
Semfile=/tmp/php.pid
php_fcgi_children=100
php_fcgi_max_requests=1000
Export Php_fcgi_children
Export Php_fcgi_max_requests

# Linux-use/proc to increase the local (ephemeral) port range
#echo 1024x768 65000 >/proc/sys/net/ipv4/ip_local_port_range

If [-Z "$ZEUSHOME"]
Then
CD ' DirName $ '/.
Zeushome= ' pwd '
Export Zeushome
Fi

Case "$" in
' Start ')

If [-e $SEMFILE]
Then
Echo FastCGI PHP Error:already running. Restart FastCGI PHP Now
Kill ' Cat $SEMFILE '
Sleep 5
Fi

if [!-X $FPHPBIN]
Then
echo FastCGI PHP error:please check $FPHPBIN is executable and exists.
Exit 1
Fi

Echo Starting FastCGI PHP.
$ZEUSHOME/web/bin/fcgirunner--user=65534--group=65534--pidfile= $SEMFILE 8002 $FPHPBIN
;;

' Stop ')
If [-e $SEMFILE]
Then
echo Stopping FastCGI PHP.
Kill ' Cat $SEMFILE '
RM $SEMFILE
Exit 0
Fi
;;
' Restart ')
If [-e $SEMFILE]
Then
echo Stopping FastCGI PHP.
Kill ' Cat $SEMFILE '
Sleep 5
Fi
Echo Starting FastCGI PHP.
$ZEUSHOME/web/bin/fcgirunner--user=65534--group=65534--pidfile= $SEMFILE 8002 $FPHPBIN
;;
*)
echo "Usage: $ {Start|stop|restart}"
;;

Esac
Exit 1

In this script, the following content needs to be modified depending on the system situation:

Fphpbin=/usr/local/php/bin/php should be set to PHP's path
Semfile=/tmp/php.pid generates the path to the php.pid, which must be writable
php_fcgi_children=100 Number of PHP processes
php_fcgi_max_requests=1000 the number of requests that each PHP process can respond to before exiting, to release resources above two based on hardware configuration and site traffic settings, the default value is 8,500. Generally php_fcgi_children > Access concurrency Max +10
Php_fcgi_max_requests if the settings are too small, the heavily visited sites will frequently increase the load due to the PHP process re-starting.
#echo 1024x768 65000 >/proc/sys/net/ipv4/ip_local_port_range only for Linux
--user=65534--group=65534 users and groups that are running for the PHP process, typically set to nobody users and groups FreeBSD is 65534/65534,linux is 99/99
Finally, set the s05php file as an executable file and run the fastcgi/php:

chmod 755 s05php
./s05php Start
Once started, the php_fcgi_children+1 PHP process is shown in the Ps-ax list.
To your vhost, build a info.php file in the corresponding Docroot directory, as follows:
Phpinfo ();
?>
Using a browser to access the info.php file in Vhost, you should be able to see the PHP info page.

Note
Thanks to CCF's altar master Hunreal wrote the s05php script, it really works very well!
If there is anything else you would like to know, you can get more information on the Zeus PHP support page.

NOTE: Any reprint or excerpt please indicate the source of the article (Chinese FreeBSD user group http://www.cnfug.org)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.