Store
Community Documentation

v3 Knowledgebase

Storing Images, Videos & Songs on Separate Servers (Phpfox CDN)

Requires: phpFox v3.1.0 or higher

This article will guide you how to store images, videos and songs being uploaded by your end-users on a separate server or multiple servers. This is to emulate services such as Amazon S3 or a traditional CDN

When you download our product you will find the folder:
tools/cdn/

In that folder you will find 2 files:
phpfox-cdn.php
phpfox-cdn-setting.php.new

These files must be placed on the server that will receive the images, videos and songs we are sending from your phpFox site. In this article our phpFox domain will be "www.mainsite.com". The server that we will upload content to will be called "www.uploadserver1.com".

Lets begin...

1) Access your upload server www.uploadserver1.com via FTP and upload the following 2 files:
phpfox-cdn.php
phpfox-cdn-setting.php.new

2) Make a directory called file on your upload server phpfox-cdn-setting.php.new and give it full write permission (usually 0777 on most servers).

3) Rename the file phpfox-cdn-setting.php.new to phpfox-cdn-setting.php and then open that file.

4) Look for:
PHP:
define('CDN_KEY'''); 


and replace that with:
PHP:
define('CDN_KEY''abc123'); 


In this example the key I created is abc123. Make sure to use that key now. You can change this in the future. Save and close that file.

5) Via FTP, log onto your main site www.mainsite.com and rename the file:
include/setting/cdn.sett.php.new
to
include/setting/cdn.sett.php

6) Open the file:
include/setting/cdn.sett.php

7) Look for:
PHP:
$aServers = array(); 

and replace with:
PHP:
$aServers = array(    
    array(
        
'upload' => 'http://www.uploadserver1.com/'
        
'file' => 'http://www.uploadserver1.com/file/'
        
'key' => 'abc123'
    
)
); 


8) Log into your Admin Control Panel and go to:
Settings >> Manage Settings >> CDN (Content Delivery Network)

9) For the setting CDN Service select phpfox.

10) For the setting Enable CDN (Beta) select True.

That's it!

Now that everything is setup, lets look over step 7 again. This is where we edited the CDN config file and added the following:
PHP:
$aServers = array(    
    array(
        
'upload' => 'http://www.uploadserver1.com/'
        
'file' => 'http://www.uploadserver1.com/file/'
        
'key' => 'abc123'
    
)
); 

You can add as many servers here as you want, each with their own unique key. The key you add here must match the key on the upload server. So if we wanted to add more sites this variable could look like:
PHP:
$aServers = array(    
    array(
        
'upload' => 'http://www.uploadserver1.com/'
        
'file' => 'http://www.uploadserver1.com/file/'
        
'key' => 'abc123'
    
),
    array(
        
'upload' => 'http://www.uploadserver2.com/'
        
'file' => 'http://www.uploadserver2.com/file/'
        
'key' => 'abc1234'
    
),
    array(
        
'upload' => 'http://www.uploadserver3.com/'
        
'file' => 'http://www.uploadserver3.com/file/'
        
'key' => 'abc12345'
    
)
);