Here is How to Upload WordPress Objects to OpenStack Swift, Working Example is With HP Cloud CDN and W3TC Plugin. Necessity is the Mother. What a Linux Server will have difference with a Mac? We have shown how to upload objects to HP Cloud CDN, that is a raw OpenStack Swift from OS X. OpenStack Swift – simple! Why fight with hundreds of crap PHP scripts when there is a perfect tool name Python Swift Client? Most funny, Python Swift Client is more easy to use on GNU/Linux. For our Example, it is an Ubuntu Server! This thing actually trying for the last 3 years. HP has, dedicated developers as employees.
We love OpenShift. It is PaaS, true. But they honor all the peoples who works for free for OpenShift. No freebie, no backlink, not even a Retweet, who will work for free?
Upload WordPress Objects to OpenStack Swift (HP Cloud CDN) : Initial Preparation
Read that guide to upload stuffs to HP Cloud CDN. You need that modified OpenStack RC file. Our modified way is (this is for West) :
---
1 2 3 4 5 6 | export OS_AUTH_URL=https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/ export OS_TENANT_ID=xxxxxxxxxxxxxx export OS_TENANT_NAME="xxxxxxxxxxx-Project" export OS_USERNAME="yourusername" export OS_PASSWORD="yourpassword" export OS_REGION_NAME="region-a.geo-1" |
We hope, you have a colorful SSH with Nano’s Syntax Highlighting. If you have not, read it later, you can do something within this guide. You are root
, right? If sudo su
is throwing error, read this guide to resolve sudo: unable to resolve host error. You can do that later too. Your $HOME
is ~
. You can not see, but there is a .bashrc
file. Open it :
1 | cd ~ && nano .bashrc |
uncomment the line unset color_prompt force_color_prompt
, that will give you some color on SSH. Go to the end of the file and add your modified real stuffs copied from above block, which is actually part of OpenStack RC file. Load the environment :
1 | source .bashrc |
First part done.
Upload WordPress Objects to OpenStack Swift (HP Cloud CDN) : Step 2
Run this command :
1 | apt-get install python-swiftclient |
It will say many things, you need not to read, accept with Y
. After installation, run this command to test :
1 | swift stat |
It will return a thing which means, you have done the right :
1 2 3 4 5 6 7 8 | No handlers could be found for logger "keystoneclient.httpclient" Account: XXXXXXXXXXXXXXX Containers: XXXXXX Objects: XXXXXXXX Bytes: 116969 Accept-Ranges: bytes X-Timestamp: 1416220171.44924 X-Trans-Id: tx1baabf46a5ee4baea80a7-005 |
You can list your containers :
1 | swift list |
That No handlers could be found for logger "keystoneclient.httpclient"
is not a problematic error. It looks bad, but you’ll have no issue. Suppose you are using nginx and your WordPress is located at /usr/share/nginx/html
, then cd to that place :
1 | cd /usr/share/nginx/html |
Or may be :
1 | cd /usr/share/nginx/html/wp-content |
See the screenshot here in full size.
wget this on your local computer and read :
1 | wget http://docs.openstack.org/api/openstack-object-storage/1.0/os-objectstorage-devguide-1.0.pdf |
Upload all the files you want. Actually, on nginx, you need a simple directive to auto replace the static files’ URLs. That is exactly done by W3TC. You can enable CDN with Rackspace Cloud Files option and use the HP Cloud or whatever OpenStack Swift domain name
. W3TC will provoke you to use password, username etc. Do not use your real HP Cloud credentials. Rackspace guys will able to see your password! NSA can also see, that is different thing. But the needed change either will be done automatically by W3TC or it will prompt. Together, PHP and Nginx block does the thing. Simple.
Yeah, as there is no filter, all files will get uploaded. 35MB extra upload. You can create a small bash script to do avoid typing commands and set cron. Instead of PHP, you’ll use command line. WordPress plugin is for those who use Shared Hosting.
No password prompt, no fuss. Very fast upload. You are not disturbing weak PHP, so no chance of WordPress white page. Run this command (create a container named tcw-january-w3tc
from Dashboard, set TTL, Publish it publicly as CDN beforehand) :
1 | swift upload tcw-january-w3tc /usr/share/nginx/html |
You’ll see, how nicely stuffs are getting uploaded. If you want only to upload the updated stuffs, then run :
1 | swift upload -c tcw-january-w3tc /usr/share/nginx/html |
Thats what you need to create a script with. Instead of you, cron will run it. Virtual directory will be created in this way :
1 2 | https://horizon.hpcloud.com/project/containers/tcw-all-january/usr/share/nginx/html/ # fake url |
You can not download from CDN :
1 | /usr/share/nginx/html/wp-config.php |
It is file ownership and permission preventing it to get uploaded! Thats the fun of *nix. It is basically, file level backup which Rackspace sells at higher cost. If you modify the method, you can use more powerfully. By the way, it is Apache2 server, .htacess
works!.htacess
does not work. You can block need to delete the sensitive PHP, HTML etc. files on web server.