CDN2 Drupal Module Users Guide
Before You Start
Thanks for choosing CDN2 for video content delivery to your drupal site!
Before you start, you'll need to sign up for an account and tell the service
what site you'll be uploading video to.
Sign up for an account
- Visit http://signup.workhabit.com/
- Fill out the form. Enter your Contact information:
-
Enter your account information. NOTE! It is important that you
specify the complete URL to the site you wish to connect CDN2 to. If you
enter an incorrect URL, videos will upload but will not appear on your site.
- Enter your billing information.
-
Click Submit.
-
You must accept the CDN2 usage agreement before using the service.
Read the info on the next page and then click the accept button:
-
You will receive an email with access identifiers for your site.
During the CDN2 beta, it may take some time to receive your access
information. Be patient, we'll get it to you.
Prerequisites
In order to use CDN2, you will need to have the following. This
installation guide touches on standard ways to get the prerequisites installed,
but may vary based on your ISP or server.
- Drupal 5 or 6 (any version)
- Drupal CCK 1.6 (or CCK 2.1 for Drupal 6) Content module
- PHP 5.2 or greater
-
PHP SOAP extension
- jquery_update module
- PEAR library (and its associated tools)
- PEAR Crypt_HMAC library
-
MCrypt library
-
Access to your server to install any of the above (e.g. SSH).
Prerequisite Installation
Installing the PEAR Library
Depending on your platform, PEAR may already be installed. The best way
to determine this is to SSH to your server (or open a command line if you have
direct terminal access), and run this command:
| pear version |
If you have PEAR correctly installed, you will see a result similar to the
following:
|
PEAR Version: 1.7.2 PHP Version: 5.2.5 Zend Engine Version: 2.2.0 Running on: Linux www.example.com 2.6.21 #1 SMP Mon Oct 16 09:30:17 EDT 2006 i686 |
On RPM-based systems, you can use yum or up2date to install the php-pear
package. On debian/ubuntu based systems, you can use apt-get install
pear-package to install it. Please check the documentation for your
distribution for more information.
Installing MCrypt
CDN2 makes use of libmcrypt and the php-mcrypt extension to handle secure
communication with the web services backend.
To determine if libmcrypt is installed, run:
|
locate libmcrypt |
You should see a somewhat long list of files. If at least files similar
to the following appear in the list, you're all set:
|
/usr/bin/libmcrypt-config /usr/lib/libmcrypt.so.4.4.7 /usr/lib/libmcrypt.so.4 /usr/lib/libmcrypt.a /usr/lib/libmcrypt.so |
Installing PHP MCrypt and SOAP extensions
To determine if you have the PHP Mcrypt and SOAP extensions successfully
installed, you can use PHP's built in phpinfo() function. To access
this, create a file in your web server's document root called
phpinfo.php. In that file, put the following:
|
<?php phpinfo(); ?> |
If you go to http://www.example.com/phpinfo.php (replace www.example.com with
the name of your site), it will display information about how php is
configured on your server. Scroll down (it's alphabetical by section),
until you get to the "M's."
If you see something like the following, then mcrypt is installed:
Similarly, you can scroll down to the "S's" to ensure you have the SOAP
extension enabled:
IMPORTANT: Remember to remove the phpinfo.php file as it can represent a
security risk if left in place.
If PHP does not indicate that the mcrypt extension is installed, please refer
to your operating system's documentation on how to install it. On RPM
based systems, you can use yum or up2date to install the php-mcrypt
package. On Debian/Ubuntu, you can use apt-get install php-mcrypt.
Once you've installed the mcrypt and php extensions, you need to add them to
php.ini.
On some systems, you should create two files called /etc/php.d/mcrypt.ini and
/etc/php.d/soap.ini. On others, adding the lines below to php.ini will
work. Refer to your OS distribution documentation on what the approparte
course is. Irrespective of where you add it, you will add the following
lines to one of those files:
in /etc/php.ini or /etc/php.d/mcrypt.ini:
|
extension=mcrypt.so |
and
in /etc/php.ini or /etc/php.d/soap.ini
|
extension=mcrypt.so |
Remember to save the files, and then restart your web server so the new
extensions will be loaded. Viewing the phpinfo.php page as described
above will help you identify that they are both loaded, after which you should
remove the phpinfo.php file for security.
Installing Crypt_HMAC
Crypt_HMAC is a PHP class provided by PEAR for handling security and
encryption. It is the last component required.
Once you have PEAR installed as above, installing Crypt_HMAC is relatively
trivial. Run the following command:
|
pear install Crypt_HMAC |
If you have it installed already, you will see a message like the following:
|
Ignoring installed package pear/Crypt_HMAC Nothing to install |
If not, Crypt_HMAC will be downloaded and installed (you may safely ignore any
warnings about updated channels):
|
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update downloading Crypt_HMAC-1.0.1.tgz ... Starting to download Crypt_HMAC-1.0.1.tgz (2,149 bytes) ....done: 2,149 bytes install ok: channel://pear.php.net/Crypt_HMAC-1.0.1 |
Installing CDN2
Installing the CDN2 Module
Visit http://drupal.org/project/cdn2 and download the module. Place the
.tar.gz file into sites/all/modules under your Drupal document root.
You will also need to download the modules from:
http://drupal.org/project/cck
and (for Drupal 5 sites):
http://drupal.org/project/jquery_update
You may use a graphical tool to uncompress the file(s) you downloaded, or you
may run the following from the command line on your server:
|
tar -xvzf cdn2-5.x-1.0-beta1.tar.gz |
Replace the .tar.gz file name above with the one(s) you downloaded. This
will uncompress the tar.gz file into its own cdn2 directory.
Administration setion of your site. Click on "Administer," then "Site
Building," then "Modules." The page will look like this:
Under the CCK section, make sure you have at least the Content module checked.
Scroll down to the CDN2 and User Interface sections, and enable the modules
there as follows:
Scroll down and click "Save configuration" to enable CDN2 and its
dependencies.
To configure the JQuery Update module, please follow the instructions on the
jquery_update page at http://drupal.org/project/jquery_update. It is
important that you do so or video will not properly appear on your site.
Configuring CDN2 Access Keys
Next, you will need to reference the email we sent you after you signed
up. There are two pieces of information you'll need:
- Client ID
- Secret Key
You may only use this information on the site you used to sign up, and it's
best to not share this information with anyone.
Click on "Administer," then "Site Configuration," then "CDN2 Settings.":
Enter your Client ID and Secret key, and leave the fields above it
as-is. Click "Save Configuration"
At this point, CDN2 is configured to handle video, but there's a few more
things we need to do.
Configuring Formats and Players
Click on "CDN2 Formats" at the top of the page.
Select the formats to transcode to. Note that you will be charged based
on the formats you choose to transcode to, so only select the formats you need
on this list.
If you've checked more than one format, you may select which to display to
users by default at the bottom of the "Transcode Presets" section.
Additionally, you will notice that "FlowPlayer" is selected as the default
player. Refer to the cdn2/players/ module folder for examples of
creating your own player plugin.
Click "Save Configuration" to save your format defaults.
Configuring Workflow
It's optional, but you may click on the "CDN2 Workflow Settings tab to
configure how Drupal responds when a video is done transcoding:
Make sure to click "Save configuration" to save your changes.
Setting up CDN2 Content
In order for you or your users to start uploading video using CDN2, you must
add a CDN2 Video field to a content type on your site.
In this example, we will walk you through creating a Video content type on
your site, and adding a CDN2 Video Field to that content type.
First, click on "Administer," then "Content management," then "Content
Types." On a stock drupal install, the page will look like this:
Click on "Add content type" at the top.
On the next page, fill out the fields as follows:
Scroll to the bottom and click "Save content type"
Next, we'll click on the "Edit" button next to the new Video content type we
created:
On the subsequent page, click "Add Field." Name the field "cdn2_video," select
the "CDN2 Field" radio button and click "Create Field":
Next, change the Label of your field to something human readable, and click
"Save field settings":
Giving users permissions to upload videos
The last step before users can upload video is to tell Drupal who to allow to
upload what kinds of video. CDN2 relies on Drupal's user permissions to
control who has access to upload and view specific kinds of video.
Click on "Administer," then "User management," then "Access Control." In
our case, we want authenticated users to be able to both upload and view
video, but anonymous users can only view it. We are also not allowing any of
our users to delete video, so we specify the permissions like so:
We also need to tell drupal to allow users with the "Authenticated User" role
to upload content of type "Video," so we allow them to do so in the "node"
section of the permissions page:
and then click "Save permissions" at the bottom of the page.
Adding Content to your Site
Click on "Create Content," then select the "Video" content type you created
above.
Give the video a title, and a body (description).
Under the Body field, you will see the "Home Video" field we created:
Click browse to find a video on your local computer, then click upload.
During the upload process, you will see a progress indicator:
Pay careful attention to the warning above. If you navigate away from
the page before the video is completely uploaded, the upload will be canceled
and you'll have to start over.
When your video has been successfully uploaded, you will see this message:
Make sure you submit your node.
When you first visit the node, you will notice that no video is
displayed. Instead there's a message indicating that your video is still
processing. Depending on how busy the service is and how large your
video is, it may take quite some time before your video is available.
When it is available, it will be displayed on your site based on the
preferences you set in CDN2 Workflow Settings.
The resulting page looks like this:
At which point.. VOILA! Congratulations! You've uploaded video to your
site using the CDN2 video service!
