May 17, 2013

Rapidleech with PHP FastCGI and NginX server

What is Rapidleech?
Rapidleech welcome page

taken from their website (http://rapidleech.com),
Rapid Leech is a free server transfer script for use on various popular upload/download sites such as megaupload.com, Rapidshare.com and more than 45 others. The famous Rapidleech script transfers files from Rapidshare, Megaupload, Depositfiles.com, Easy-share.com, etc, via your fast servers connection speed and dumps the file on your server. You may then download these files from your server anytime later.
not only it allow you to transfer files from other file-sharing host or from another FTP server, you also use it to upload a file to another file-sharing host or FTP server. You don't even need to worry about database plus, it's free with a very helpful community too.

What is PHP FastCgi?
taken from their website (http://php-fpm.org/),
PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. These features include:
Adaptive process spawning (NEW!)
Basic statistics (ala Apache's mod_status) (NEW!)
Advanced process management with graceful stop/start
Ability to start workers with different uid/gid/chroot/environment and different php.ini (replaces safe_mode)
Stdout & stderr logging
Emergency restart in case of accidental opcode cache destruction
Accelerated upload support
Support for a "slowlog"
Enhancements to FastCGI, such as fastcgi_finish_request() - a special function to finish request & flush all data while continuing to do something time-consuming (video converting, stats processing, etc.)
Pretty cool eh? with this, you can serve many people at the same time without killing the server a.k.a overload with too much request from the visitor.

What is NginX
taken from their website (http://nginx.org/en/
nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VKontakte, and Rambler. According to Netcraft nginx served or proxied 13.54% busiest sites in May 2013. Here are some of the success stories: Netflix, Wordpress.com, FastMail.FM.
The Tutorial
i assume that you already have your own server and had install PHP FastCGI and NginX as the server. I'll cover the installation of this two later on.

when i first use NginX as the server, i notice that rapidleech had a lot of troublesome problem.
The most notably problem is, when transloading, whether from a file-sharing host or an FTP, the progress bar will not shown and the percentage will stay at zero.

Only after the file is downloaded successfully that the progress bar is shown in FULL and the percentage straight to 100%.

This is not a BUG with the rapidleech. I repeat, NOT A BUG!

The problem is within the NginX and PHP FastCGI configuration. To solve this, You can use my configuration here.

PHP FastCGI Configuration
edit your php.ini to match the following setting
output_buffering = off
zlib.output_compression = off

Nginx Configuration
edit your NginX Configuration file to have or match this setting. it should be at /etc/nginx/nginx.conf
gzip off;
proxy_buffering off;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript application/xml application/xml+rss text/javascript;
fastcgi_keep_conn on;

With this configuration, your rapidleech should work as it should be. The transloading process will proceed normally.

Plus, with that configuration, every of your PHP script that flushing data to the browser should work correctly. You dont have to wait until the execution of your php script end to see the flushed result.

Downloading in progress

Download finished!

hope this help to solve those problem using NginX powered Rapidleech.

An example of Rapidleech server using Nginx.

No comments:

Post a Comment

Whats your thought on this post?