Knowledge base
How to use OCS for serving static files in sites based on WordPress and W3 Total Cache plugin?
Posted by Pomoc Oktawave on 29.10.2014 21:10

To configure Wordpress to use OCS, a package php5-curl must be on instance with WP:

 

apt-get install php-curl

 

In Settings | Permalinks select the type of permalinks, and then install in Wordpress a plugin called W3 Total Cache, but don't turn it on.

We must modify the W3 Total Cache plugin, by introducing the following changes.

 

w3-total-cache/lib/W3/Cdn/Base.php:
481c481
<                 if (preg_match('~^([a-z0-9\-\.]*)~i', $_domain, $matches)) {
---
>                 if (preg_match('~^([a-z0-9\-\.\_]*)~i', $_domain, $matches)) {

w3-total-cache/lib/W3/Cdn/Rscf.php:
88a89,92
>
>           case 'pl':
>               $host = PL_AUTHURL;
>               break;

w3-total-cache/lib/CF/cloudfiles.php:
81a82
> define("PL_AUTHURL", "https://ocs-pl.oktawave.com/auth");
211c212
<         if ($status != 204) {
---
>         if ($status != 204 && $status != 200) {

w3-total-cache/inc/options/cdn/rscf.php:
21a22
> <option value="pl"<?php echo selected($this->_config->get_string('cdn.rscf.location'),
 'pl'); ?>>PL</option>

 

Now we can turn on W3 Total Cache plugin.

Then, in the Performance | General Settings | CDN tab, choose CDN Type | Rackspace Cloud Files and save the changes.

Go to Performance | CDN and enter the following configuration:

  • As the username give the full name of OCS, for example. NameSurname1234:user.
  • As an API key, give the password of the OCS user.
  • Select Location | PL.
  • In Container field, enter the name of a previously created container.
  • SSL support set to Auto.
  • In the field Replace site's hostname type in the adress from where the files will be available, to upload into the OCS. It can be eg. in the form of <container>.<Auth_token>.ocs-pl.oktawave.com. You can also set CNAME record earlier for your domain, which redirects to the container and give it at this point.
  • You can verify the settings are correct by clicking Test Cloud Files upload.
  • From wp-includes file types to upload and Theme file types to upload remove entries for files with extensions *.css and *.js. Modified default values ​​for these fields are as follows:
  1.      wp-includes file types to upload: *.gif; *.png; *.jpg; *.xml
  2.      Theme file types to upload: *.gif; *.Png; *.Jpg; *.Ico; *.Ttf, *.Otf *.WOFF, *.Less

In the Performance | General Settings | CDN you can now Enable and save the changes. From now on all files added to the Wordpress media library will be uploaded to the OCS, including links to these files will be carried out at the address listed previously in section above.

After you verify that everything is working properly using the options in Performance | CDN | General we can transfer to the OCS other static elements of our service, for example. the media and attachments, which were placed on website before, elements of graphic motif, etc.

Files made ​​available from the OCS are also stored in the traditional way on instance, and are not removed automatically, but you can add to the cron entry that will remove files from the disk for us. If needed, there will always be possible to recover them from the OCS service.

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.