Running PHP in FastCGI Server Mode!

 
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Fri May 04, 2007 6:26 pm    Post subject: Running PHP in FastCGI Server Mode! Reply with quote

Hello Everyone,

I'm here today to bring you a tutorial on installing PHP5 on Windows as a FastCGI Server. Recently Aprelium has release v2.4.0.3 of Abyss Web Server. This new version of Abyss, allows you to run FastCGI externally using the "FastCGI (Remote - TCP/IP sockets)" option.

First thing you need is PHP5 (Zip Archived package). You can download the latest version from
www.php.net (PHP 5.2.2 is the newest and recommended).

Step 01.
Unzip the contents from the Zip Archive file that you downloaded from php.net to a new folder C:\PHP5 (You need to create the PHP5 folder yourself.)

Step 02.
Open a command line (Start -> Run -> cmd.exe) and change to your PHP5 folder "cd C:\PHP5"

Step 03.
Type this command "php-cgi.exe -b 127.0.0.1:2700" in the command line. This will start the server (By the way, it's multi-threaded!)


Step 04.
Now that we have our server runnning, let's configure Abyss Web Server to connect to it. Open your abyss console and click Configure for the Host you wish to configure. Go to "Scripting Parameters" and click "Add" in the Interpreters table (Click the Edit icon if your following the "PHP FastCGI Backup System" tutorial). Copy the following settings

Interface: FastCGI (Remote - TCP/IP sockets)
Remote Server IP Address: 127.0.0.1
Port: 2700

Type: PHP Style

Now click "Add" in the "Associated Extensions" table and type "php" without the quotes. Note: You shouldn't need to do this if you're following the tutorial for "PHP FastCGI Backup System". Link: http://www.aprelium.com/forum/viewtopic.php?t=12766

Save your settings!

Click "Add" in the "Environment Variables" table and add the following settings.

Name: REDIRECT_STATUS
Value: 200

Note: You only need to do this part if you don't have it already listed.

Apply your settings and restart Abyss Web Server.

It's time to test it!

Create a new file in your htdocs folder and call it "phpinfo.php". Add the following code to that file.

Code:
<?php phpinfo(); ?>


Save the code run it from your browser "http://localhost/phpinfo.php".

Now, instead of multiple FastCGI processes, you can run your PHP scripts from a multi-threaded FastCGI server! Enjoy!
Note: The address for the FastCGI server can also be remotely accessed by other servers unless you keep it at "127.0.0.1".

Note: You can also create a batch file so that the FastCGI server can be runned at startup.

Example batch code: fastcgi_server.bat

Code:
@echo off
echo The FastCGI Server is started!
C:\PHP5\php-cgi.exe -b 127.0.0.1:2700


I hope everyone liked the tutorial.


Last edited by TRUSTAbyss on Wed May 16, 2007 4:22 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
gctmpr
-


Joined: 28 Apr 2007
Posts: 18

PostPosted: Wed May 16, 2007 4:03 pm    Post subject: Reply with quote

can i use php 521 ?

because PHP 5.2.2 i use, my side become error..

install back php521,site become normal
_________________
wap site-
arunothai.myvnc.com/registered
username-abyss
password- free

web site
[url]arunothai.myvnc.com[/url]
Back to top View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed May 16, 2007 4:22 pm    Post subject: Reply with quote

PHP 5.2.2 is the only version that has the FastCGI Server. Unless you're on a Mac/Linux/FreeBSD OS.
Back to top View user's profile Send private message Visit poster's website
gctmpr
-


Joined: 28 Apr 2007
Posts: 18

PostPosted: Wed May 16, 2007 5:22 pm    Post subject: Reply with quote

after delete php 522, back to php 512...
all setting is o.k...
but web site just can connect with local net
cant connect to my side ,help
_________________
wap site-
arunothai.myvnc.com/registered
username-abyss
password- free

web site
[url]arunothai.myvnc.com[/url]
Back to top View user's profile Send private message Visit poster's website
JaturontThan
-


Joined: 29 May 2008
Posts: 3

PostPosted: Thu May 29, 2008 9:28 am    Post subject: Reply with quote

It sounds pretty complicated to me...didn't work the first time I tried, but I'll try it again...thanks
_________________
Cosmetic Surgery Thailand
Plastic Surgery Thailand
Back to top View user's profile Send private message
luka8088
-


Joined: 24 Feb 2009
Posts: 2
Location: Rijeka, Croatia, Europe

PostPosted: Tue Feb 24, 2009 1:45 pm    Post subject: it is not multi-threaded ... Reply with quote

php-cgi is not multi-threaded ....

try this code:

<?php

sleep(10);
phpinfo();

?>

and then open 3 browser tabs, and call open that script from all 3 at the same time... you will see that first will finish after 10 seconds, second after 20, third after 30... and that is single-thread....

or am I wrong ??
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Feb 24, 2009 6:02 pm    Post subject: Reply with quote

You're right. PHP is only a single threaded application, hence the behavior your seeing
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Mar 13, 2009 4:44 pm    Post subject: Re: it is not multi-threaded ... Reply with quote

luka8088,

You are running a single instance of php-cgi and it is not multithreaded hence the behavior you are getting.

It is recommended to set the FastCGI mode with local pipes/local TCP/IP as it allows Abyss Web Server to launch as many instances as required and you won't get that behavior (Abyss can manage several instances of PHP and load balance processing between them).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
luka8088
-


Joined: 24 Feb 2009
Posts: 2
Location: Rijeka, Croatia, Europe

PostPosted: Fri Mar 13, 2009 5:01 pm    Post subject: Re: it is not multi-threaded ... Reply with quote

aprelium wrote:
luka8088,

You are running a single instance of php-cgi and it is not multithreaded hence the behavior you are getting.

It is recommended to set the FastCGI mode with local pipes/local TCP/IP as it allows Abyss Web Server to launch as many instances as required and you won't get that behavior (Abyss can manage several instances of PHP and load balance processing between them).


yes, I know.... but I just wanted to correct:

Quote:

Step 03.
Type this command "php-cgi.exe -b 127.0.0.1:2700" in the command line. This will start the server (By the way, it's multi-threaded!)
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group