Unix and ApacheNT


Setting up membership sites with NETbilling is a relatively easy process. It basically involves three steps:

  1. Configuring the remote-control cgi script on your local webserver

  2. Adding a membership subsite to your NETbilling Admin Manager

  3. Creating join button or links and testing the site

If at any point, our instructions aren't working for you, you should contact your website hosting company, your system administrator, or someone who is familiar with operating systems and configuring CGI.


Part 1 - Configuring the remote-control cgi script on your local webserver

Before you do this, you need to make three decisions:

Where will you store your passwords?

This should be in a directory that is not accessible via the web. Most web hosting companies will set up your account so that you have a home directory that is off the web tree. This is where we suggest you keep your passwords.

Where will you create your membership directory?

Most of the time, we suggest you simply create a directory called 'members' on the top level of your web tree. That way, you can send your members to a URL like http://www.mywebsite.com/members/

Where can I run CGI programs on my website and how do I set them up?

Most of the time, there is a directory called cgi-bin where executable programs are placed. We are going to show you the most common way to setup these scripts and where to put our script. If at any point, our instructions don't make sense or aren't working for you, you should contact your website hosting company, your system administrator, or someone who is familiar with UNIX operating systems and configuring CGI.

With those things in mind, let's get started!

Step by step instructions

  1. Use an ftp client to login to your webserver

  2. Upload our membership script ( nbmember.cgi ) and configuration file ( nbmember.cfg ) to your cgi directory (usually cgi-bin). You can grab them from our server below:

  3. Shift-click to download control script nbmember.cgi

  4. Shift-click to download sample config file nbmember.cfg

  5. Logout and close your ftp client

  6. Open up a telnet client and log back into your website.

  7. You should be in your home directory when you login. At this point, you need to create a directory to store the password file, the password file itself, and set the proper permissions to the file so that the webserver can write to it. Here are the commands to execute:

  8. mkdir passwords

    touch passwords/htpasswd

    chmod 666 passwords/htpasswd

  9. Make note of the full path to the file you just created. If your home directory is something like:

  10. /home/htdocs

    then the path do your passwords will be:


  11. Next, find out and make note of the location of perl on your website. Normally, it is located somewhere like:

  12. /usr/bin/perl

    To find out for sure, type the following:

    which perl

    That will tell you the location. You should also verify which version of perl you are running. Our script only works with versions 5 or higher. Find out by typing the following:

    /usr/bin/perl -v

  13. Now, we need to edit the membership script file ( nbmember.cgi ) and the configuration file ( nbmember.cfg ) and get them ready for operation on your site. Change directories to your cgi directory as below:

  14. cd cgi-bin

  15. Open nbmember.cgi into your favorite unix text editor (pico, vi, emacs, etc.)

  16. Find this line at the top of the script:

  17. #!/usr/bin/perl

    Make sure that matches the path to perl on your webserver. If not, change it. Save and close the file.

  18. Next, open nbmember.cfg , and locate the line:

  19. HTPASSWD_FILE = "/path/to/htpasswd"

    Change that path to the path where your password file is located.

  20. Next, locate the line:

  21. ###ACCESS_KEYWORD = "Change_This_Now!"

    Get the Access Keyword from the Site Config Screen in your account. Replace the phrase Change_This_Now! with that access keyword. Remember it, or write it down, because you will need it later to enter it into the NETbilling Website Config screen. The purpose of the access keyword is to verify that your script is legitimate and validates your site to the NETbilling Website Management software.

  22. Save the file and exit your text editor.

  23. Change the permissions on nbmember.cgi to executable as below:

  24. chmod 755 nbmember.cgi

  25. Change the permissions on nbmember.cfg to be able to be read by nbmember.cgi :

  26. chmod 644 nbmember.cfg

  27. Your script should now be executable, and your config file should be readable. To test to see if it works, open a web browser and type in the URL of your script to see if it's working. For example: http://www.mywebsite.com/cgi-bin/ nbmember.cgi

  28. If the script is working properly, you should get the following message:


    supported cgi parameters:
    cmd = {test
    |append_user (post)
    |delete_user (post)
    |update_all_users (post)
    u = <username>
    p = <unix encrypted password>
    w = <md5 encrypted apache/win32 password>
    m = <md5 encrypted (unix) password>
    n = <plain text password>
    site_tag = <web site id>
    challenge = <authentication token>

    This error message just means that the script is working properly and that you didn't give it any parameters to work with, so everything is fine.

  29. Next, you must create the password popup box that will appear when your users attempt to login to your membership area. This is done by placing a file in your membership area called .htaccess.

  30. Change directories to your membership directory.

  31. cd /home/htdocs/members

  32. Open a text editor and create a file called .htaccess

  33. Copy the following code into the file:

  34. AuthUserFile /path/to/passwords/htpasswd
    AuthGroupFile /dev/null
    AuthName MembersOnly
    AuthType Basic
    <Limit POST GET PUT>
    require valid-user

    Change the pathname of /path/to/passwords/htpasswd to the correct location of your password file.

  35. Save your file and quit your text editor

  36. To test that this file works, enter the URL for your membership area in a web browser. It might be something like http://www.yoursite.com/members/

  37. If you get a membership popup window then this portion is configured correctly. Now that that part is finished, let's move onto configuring your NETbilling account to accept passwords and track them for you.

Part 2 - Setting up a membership subsite in your NETbilling Website Manager

Step by step instructions

  1. Login to your NETbilling Admin at https://secure.netbilling.com/merchant


  3. (OPTIONAL) If you have more than one website, Click SETUP. Under WEBSITE TOOLS, click BROWSE SITES and look for the site you are going to test and configure.

  4. (OPTIONAL)Click [config]

  5. Enter the URL of your membership site in the box labeled MEMBER URL. The URL will be something like http://www.yoursite.com/members/

  6. Enter the URL of your control script in the box labeled CONTROL CGI URL. The URL will be something like http://www.yoursite.com/cgi-bin/ nbmember.cgi

  7. Locate your access keyword in the box labeled ACCESS KEYWORD.

  8. Next, check the appropriate box next to the type of passwords you want submitted to your control script. The vast majority of the time, your site will be hosted on a unix-based site (which is why this is a unix-slanted tutorial) and you will most likely only check the box labeled DES encrypted passwords (Apache/UNIX). There are other options available, but you should consult your webmaster before choosing to use them. The other options are:

  9. Post DES encrypted passwords (Apache/UNIX)
    Post MD5 encrypted passwords (Apache/WIN33)
    Post MD5 encrypted passwords (MD5/UNIX)
    Post plain text passwords to your Control CGI

  10. (OPTIONAL) If you have more than one website being managed by NETbilling, you can check the box next to ACCESS OPTIONS labeled "Require unique user names with respect to all other sites". This will make sure you won't have members on two different sites with the same username, so searching by username in the NETbilling system will not garner results for multiple users.

  11. (OPTIONAL) You can also change the settings in the popup window labeled GRACE PERIOD. By default, if a rebilled member fails to be rebilled, their membership is suspended. You can optionally give the member a grace period for a number of periods from 12 hours to 4 weeks for the system to attempt to get payment from them.

  12. Now that you have filled in all the parameters, scroll to the bottom of the screen and click APPLY.

  13. Finally, make sure your account is in Test Mode. Click MAIN. Under GENERAL, click HOME. At the top of the page it will tell you if your account is LIVE! or in TEST MODE. If it is in TEST MODE, go on to Part 3. If your account is LIVE click SETUP. Under ACCOUNT CONFIG, click CREDIT CARDS. Put your account in test mode by clicking the checkbox next to the option labeled GLOBAL TEST MODE (SIMULATE PROCESSING). Scroll to the bottom of the page and click APPLY.

Now it's time to put a button on your site and test the whole system.

Part 3 - Creating a 'join button' and testing your membership site

The final step of this process is actually adding the buttons to your site that the customers will click to join your members area. This is done by using the NETbilling Form Maker to create code, then pasting it into a web page on your web site.


  2. Choose what type of membership you are creating from the popup menu labeled PURCHASE TYPE. The two types of memberships are 'SIGNUP' and 'SIGNUP + REBILLING'.
  3. A SIGNUP is a single-term membership with no recurring billing periods. Generally used for 1-month membership that do not renew.

    A SIGNUP+REBILLING is a membership that renews itself automatically using NETbilling's recurring billing feature. This is generally used for 1-month memberships that will renew each month until you stop them.
  4. Set the transaction type to SALE (CAPTURE FUNDS) or PREAUTH (AUTHORIZE ONLY). Generally you would choose SALE, except for special types of memberships where you would offer some period of time free before the actually billing begins. For setting up free trial memberships, see the section under REBILLING AMOUNT below.

  5. Next, choose the payment form you will use. Generally you would leave this on SITE DEFAULT. If you have a modified payment form for other uses on your website, you can create a new form using the FORM EDITOR, or you can choose NETbilling 2.2 NATIVE (MEMBERSHIP) FORM. Either way, your payment form has to be configured to use membership fields. You will almost always be OK by choosing SITE DEFAULT or NETbilling 2.2 NATIVE (MEMBERSHIP) FORM.

  6. Enter how much you want to charge in the box labeled PRICE. DO NOT include a dollar sign.

  7. Next to OPTIONS you can choose to ENABLE CRYTO-HASH This is a method of encrypting your data in such way to guarantee it's integrity, completely eliminating the possibility of someone altering things like the amount they are going to pay during the transaction process. If you use the Crypto-Hash feature, you must make sure that you have enabled the 'Enforce Crypto-Hash' option in your Card Setup area. We highly recommend using this feature, but it is optional. Also of note, if you use Crypto-Hash, you must always create your signup buttons with the Button Editor in order to correctly enable the feature. A more detailed explanation of this function is available in the Crypto-Hash documentation.

  8. Enter what you want to appear on the button itself in the box labeled BUTTON LABEL. This is usually something like "Join Now for $10 for one month".

  9. Enter a brief one-line description of the product in the box labeled PRODUCT DESCRIPTION. This is the description that will be stored in your database or passed along in an email. This is usually something like "One month membership, rebilled monthly for $19.95".

  10. Enter the URL of the page you want your members to wind up at in the box labeled RETURN URL. It should be something like "http://www.yoursite.com/members/" to have them log directly into your membership area after their purchase.

  11. The box labeled RETURN METHOD should probably be HTTP GET. Ask your administrator if it should be something different, or if you have a database on your site to capture data on the return.

  12. Next, specify the length of the membership and the rebilling options in the following fields:
  13. MEMBERSHIP VALID FOR should be in number of days. For example, one month is 30 days, and 3 months is 90 days.

    REBILING AMOUNT should be how much to rebill the customer. If you are offering a free trial membership, for 3 days, as an example, you should set the TRANSACTION TYPE above to PREAUTH (AUTHORIZE ONLY). Set the PRICE option to $1.00, and set MEMBERSHIP VALID FOR to 3 days. Finally, set the REBILLING AMOUNT for the full amount they will be billed for a full-price membership.

    REBILLING PERIOD should be how long between rebillings. Choose one from the popup menu, or enter a custom number of days in the box.

    REBILLING COUNT should be the number of periods that the rebilling should happen. For example, a year long membership rebilled each month would enter the number 11. The first is the initial transaction, followed by 11 more months. If the membership is going to be indefinite, leave the box blank.

    Next to OPTIONS, the box PRORATE FIRST PERIOD should be checked if you have want to prorate you initial signup so that all your company's rebilling can then fall on the same day of the month.

  14. Now, click 'Apply'

  15. A form will now appear in the top half of the window containing all the HTML code that is necessary for your web page.

  16. Copy and paste this code into a web page on your site.

  17. Reload this web page and your button will appear.

  18. Now you are ready to test your website! Click the button and walk through the process to see if it works.

  19. Some possible errors are described here.

  20. Once you are satisfied that everything works, be sure to remember to take your account out of test mode to make the system live.