Installing the PHP Language Support _php Foundation in Zeus Web server

Source: Internet
Author: User
Tags install php php language php error phpinfo sleep

Objective
Zeus is a very good web Server running under UNIX, and PHP is a very good background scripting language in UNIX. Both of these products are for a very like product. Why write such a howto? 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 writing this document is to make everyone's PHP system run well on the Zeus server.
Early on I wrote a consolidated Zeus and PHP article, it is mainly about how to fastcgi PHP to run the local way to operate in the Zeus, the howto is mainly about how to let PHP run in remote responders mode. This is because it is more scalable and efficient than the local way.

Preparatory work
First you should Zeus installation and not too much talk about how to install and configure the Zeus server itself, because its installation and configuration is too simple.
If possible, it's best 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. Install fastcgi
Note that if you install a version of PHP that is less than 4.3.0, you need this step. The new PHP version already has a fastcgi library built in. The way to install 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 header files in the/usr/local/include directory will be fastcgi.

Compiling PHP
Compiling PHP can use the usual PHP compilation options, and here's a configuration I use:

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

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

? Phpinfo ();?>
When you press ctrl-d, the information returned to PHP is correct.

Configure fastcgi/php
Configure fastcgi
Enter the Zeus Management console and open the Vhost configuration that you want to configure. Enter the FastCGI setting in the API Support. In which to set up:
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 on this computer, even if PHP is not installed on this computer, you should also set the Docroot path parameter, it can not exist in the appropriate directory.
When the settings are complete, click the Apply button. Configure PHP resolution Point
Enter the handlers setting 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 are handled by:the handler
Note that specify the path and filename of the handler, relative to the document root should be identical to the Directory name value you set in the previous step.
When the settings are complete, click the Apply button.
When all the settings are complete, use the Vhost commit feature to submit and apply the changes. So Zeus set the fastcgi and PHP related parameters.

Configure fastcgi/php Startup
Create a new s05php file in the Rc.d directory of Zeus, which reads:

#!/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

# This are linux-use/proc to increase the local (ephemeral) port range
#echo 1024 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 that $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 items need to be modified depending on the system:

Fphpbin=/usr/local/php/bin/php should be set to the path of PHP
Semfile=/tmp/php.pid generates the path of the php.pid, which must be writable
Number of php_fcgi_children=100 PHP processes
php_fcgi_max_requests=1000 the number of requests that each PHP process can respond to before exiting, which is used to free up two of resources. The default value is 8,500 based on hardware configuration and site traffic. Generally speaking Php_fcgi_children > Access concurrent maximum value +10
Php_fcgi_max_requests if the settings are too small, a site with a large number of visits will increase the load frequently because the PHP process is heavy.
#echo 1024 65000 >/proc/sys/net/ipv4/ip_local_port_range only for Linux
--user=65534--group=65534 the users and groups 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 displayed in the Ps-ax list.
Build a info.php file in the corresponding Docroot directory of your Vhost, which reads:
?
Phpinfo ();
?>
Using the 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 to write the s05php script, it is really very useful!
If there's anything else you'd like to know, get more information on the Zeus PHP support page.

NOTE: Any reprint or excerpt please indicate the origin 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.