We Can Use Python Swift Client to Selective Upload the Static Objects to OpenStack Swift, like in HP Cloud CDN. Here is How to Configure W3TC. W3TC means – W3 Total Cache Plugin. There are few steps involved. First and foremost important thing is that – creating a PHP based Plugin or helper Plugin for WordPress W3TC is not that easy for Key Stone Based Authentication System. Rackspace Cloud uses API, it makes it easy to upload stuffs. However, we have ways for you, primitive, but you can use nicely.
OpenStack Swift (HP Cloud CDN) with WordPress W3TC : Initial Upload
Previously, we have described how to upload all the things to OpenStack Swift (HP Cloud CDN). You must read it. That is the basic thing for the uploading part. But, uploading in that way, has risk of uploading the core PHP files, even uploading backups in .sql
format.
So, you will arrange exactly the same settings but at the point of running commands, you’ll stop. We need to add filter for the file types. We can exclude the .php
, .htaccess
, .html
files in several ways. If your WordPress is installed at /usr/share/nginx/html
, then, you can copy to a directory named cdn
(or whatever you want to name it) :
---
1 | rsync -av --exclude='*.PHP' --exclude='*.ZIP' --exclude='*.SQL' /usr/share/nginx/html /usr/share/nginx/html/cdn |
Now, if cd
to that cdn
directory and upload all the stuffs, it becomes easier. You can, even exclude the directories to extract files. This is the syntax :
1 | rsync -av --progress /source /destination --exclude exclude-directory-name |
Second way to add filter for the file types is using tar
:
1 | tar -c --exclude .php --exclude .sql | tar -x -C ~/dest |
Yes, cp
can do it :
1 | cp !(file1|file1) dest |
or
1 | find ./source-directory -not ( -name .php -a -prune ) -print0 | xargs -0 -IFILES cp FILES ./destinationdirectory |
But works better as bash script :
1 2 3 4 5 | # add your shell head here # delete this line, keep second line clean # sets extended pattern matching shopt -s extglob # sets extended pattern matching cp $(ls -laR !(sub-dir1/file1|file2|sub-dir2/file3)) destination |
rsyc
is the best way. Now cd to that directory and upload to an already published Container created via web GUI control panel. Run swift upload
command, as we have shown in the previous guide.
If your instance get hanged or Nginx throws error, during the first time upload, simply reboot the instance from SSH. It happens because some files might be in use!
OpenStack Swift (HP Cloud CDN) with WordPress W3TC : W3TC Configuration
Set W3TC for Rackspace Cloud Files. We are showing you the options needs to be adjusted :
+ ————————————————————————
+ ————————————————————————
+ General
+ =======
+
+ Host attachments : Checked or Not, depends on your wish
+ Host wp-includes/ files : Checked
+ Host theme files : Checked
+ Host minified CSS and JS files : Checked
+ Host custom files : Checked
+ Force over-writing of existing files : Checked (does not matter)
+ Import external media library attachments : Unchecked
+
+ Configuration
+ =============
+ Username: Use a Fake Name
+ API key: Use a Fake Password
+ Location: [keep it default]
+ Container: Give real container name to remember yourself!
+ SSL support: [Yes for us]
+ Replace site’s hostname with: Paste the whole path like this,
+ this is SSL one, do not append HTTP or HTTPS
+ a248.e.akamai.net/cdn.hpcloudsvc.com/h3c328c03/whoever//wp-content
+
+ Advanced
+ ========
+
+ No need to change anything.
+ ————————————————————————-
Save the settings. It is likely, that you are using Nginx. W3TC will prompt to write this block on Default
file (do you know, that W3TC has the option to set path to config file on the General settings page? Change the default value, you’ll get prompt) :
1 2 3 4 5 | # BEGIN W3TC CDN location ~ \.(ttf|ttc|otf|eot|woff|font.css)$ { add_header Access-Control-Allow-Origin "*"; } # END W3TC CDN |
Reload Nginx. Your static contents will be served via HP Cloud CDN / OpenStack Swift Storage.
Tagged With openstack php video cdn