Running WordPress on Android using KSWEB

< Warning >
You need the skill to set your Android’s IP address public. I don’t write the procedure about network settings, because it depends on your network hardware, software and provider. I’m sorry but please check it on another website.

< Awesome App for Android >
There is an awesome app on Google Play. The app name is KSWEB. Developer page is here. You can download from this page or Google Play.

< Requirements >
The developer of KSWEB says Android device with OS version 2.3.3 or higher and ARM-based processor is required. I will try to run KSWEB on IS05 (Japanese old Android smartphone by SHARP) and the procedure on this post is about this device. But maybe KSWEB can run on so many kinds of Android devices. Please try on any devices you have.

< Installing from Google Play >
( If you want to install from Google Play, please follow this procedure. )
You just need to go KSWEB – Google Play and install it. That’s all of installation.

< Installing from APK file >
( If you want to install from APK file, please follow this procedure. )
Before installing APK file, you need to change your Android’s setting for apps. You need to allow app installs from “unknown sources”. After that, please visit http://kslabs.ru/download/ to download the APK file of KSWEB.
20140531-174245

< Downloading WordPress >
You can choose “downloading on Android directly” or “downloading on PC and upload to Android”. I downloaded on PC from http://wordpress.org/. I installed AirDroid to my Android and visited http://web.airdroid.com/ to upload WordPress ZIP file to my Android. If you want to “download on Android directly”, you just need to visit http://wordpress.org/ by your Android browser.

< Installing ZIP extractor to your Android >
You need to extract WordPress ZIP file on your Android. I installed AndroZip™ File Manager to my Android. But there are many kinds of ZIP extractor on Google Play, you can choose any app you like.

< Extract ZIP file >
I put the ZIP file “wordpress-3.9.1.zip” on the root of SD card directory. After I extract it “wordpress” directory was automatically made.
20140531-180921

< Adding and enabling optional functions >
Please tap [ TOOLS – WebFace – Start ] to enable KSWEB Web Interface. Please tap [ TOOLS – Main – phpMyAdmin ] to add phpMyAdmin. phpMyAdmin is for making a database on MySQL for WordPress, so it’s not necessary. You can also make a database by PHP script.
20140530-002435

< Making a database by phpMyAdmin >
Please access http://localhost:8000/ by itself(Android) or http://< Android’s local IP address >:8000/ from any computer on the same network.
phpMyAdmin_login
You can login as root with no password. In my sample picture, I made a database “wordpress” for WordPress.
phpMyAdmin_table

< Change WWW root of lighttpd >
Please access http://localhost:8003/ by itself(Android) or http://< Android’s local IP address >:8003/ from any computer on the same network. It’s KSWEB Web Interface. Default user and password are both admin.
KSWEB_Web_Interface
Please click Server settings. You can edit a config file of lighttpd.
Please find a line like below.

server.document-root = “/mnt/sdcard/htdocs”

Change directory path of this line to your WordPress root.
My new setting is below.

#server.document-root = “/mnt/sdcard/htdocs”
server.document-root = “/mnt/sdcard/wordpress”

After changing config file, please reboot lighttpd or KSWEB.

< Ports of lighttpd >
Default ports setting is like below.
lighttpd_ports
If you want to change them, please edit config file.

< Don’t sleep! >
Basically Android smartphone automatically sleeps. If you want it to work 24 hours, you need to keep it away from sleeping. There are many apps to stay it awake on Google Play. Please use StayAwake, KeepScreen or another one you find on Google Play.

< Start WordPress >
Next step is same procedure of general installation of WordPress. Please access your Android with your domain name. WordPress default installation will start. Enjoy your energy‐saving WordPress life.

Reverse proxy on nginx on Raspberry pi

< Ready to install >
You need Debian wheezy to follow my procedure. Not only for Raspberry Pi.

< Why I use Raspberry Pi >
Reverse proxy is simple function. Basically it’s too easy task for general personal computers or any servers. Raspberry Pi is not so powerful, but it’s energy saving computer. It’s not expensive. Anyone can buy it all over the world. It’s enough for reverse proxy on nginx. That’s why I choose Raspberry Pi for reverse proxy server and wrote this post.

< Installing nginx >
Execute command below as root.

apt-get install nginx

That’s all.

< Edit config file >
Edit default config file.

nano /etc/nginx/sites-available/default

My “/etc/nginx/sites-available/default” is like below.

server {
listen 80;
server_name mydomain.net;

location / {
proxy_pass http://127.0.0.1:8080;
}
}

This config transfer accesses “mydomain.net” to 8080 port of local Apache server on Raspberry Pi.

< Add proxy config file >
Add a file for proxy settings.

nano /etc/nginx/conf.d/proxy.conf

My “/etc/nginx/conf.d/proxy.conf” is like blow.

# Header
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Timeout
proxy_connect_timeout 60;
proxy_read_timeout 90;
proxy_send_timeout 60;

# Buffer
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 100 8k;

# Cache
proxy_cache_path /var/cache/nginx/mydomain.net levels=1:2 keys_zone=cache_$
proxy_temp_path /var/cache/nginx/temp;

proxy_cache_valid 200 2h;
proxy_cache_valid 302 2h;
proxy_cache_valid 301 4h;
proxy_cache_valid any 1m;

Also you need to make cache dir as root.

mkdir /var/cache/nginx

< Start nginx >

service nginx start

How you think about this procedure? So easy?

Generating dynamic web pages only with Google Drive

< Warning >
I recommend you to get extra Google account only for public.
Because if you follow my procedure, your Gmail address will be on public XML file.

< Can I put adsense codes on HTML on Google Drive? >
The answer is NO. I found the important information on Google Product Forums below.
Can I place adsense codes (ads) in my google drive every doucement?
You can not place adsense codes on any documents in Google Drive. Please be careful.

< New solution on 2014/07/07 >
I wrote the post Get new version of Google Spreadsheets as JSONP. If you want to use new version of Google Spreadsheets to generate dynamic web pages instead of the old version, please read that post.

< Updated on 2014/04/26 >
Please use Anyfile Notepad or any other text editor apps for Google Drive on Google Web Store instead of Drive Notepad. Because Drive Notepad was removed from store.

< Updated on 2014/05/12 >
Hey! Drive Notepad is back to Google Web Store!

< Recommendation >
I recommend you to install “Drive Notepad”. It’s an extension for Google Drive. When you install Drive Notepad, you need Chrome. But after connecting Drive Notepad to Google Drive, Chrome is not required. You can use Drive Notepad on any browsers.
https://chrome.google.com/webstore/detail/drive-notepad/gpgjomejfimnbmobcocilppikhncegaj?hl=en-GB
drive_notepad_en_us

< For updating contents from Spreadsheet >
You need to use “Google Spreadsheet version 1”. Because “version 2” doesn’t support CSV and XML sharing yet. ( I wrote this post in April 19 2014. ) If you normally generate new spreadsheet today, it’s automatically be version 2.

Google explained new spreadsheet on “Check out the new Google Sheets“.

I worried about CSV and XML sharing will not support in version 2. So I checked also “Unsupported features in the new Google Sheets“. But this function isn’t listed on that page. Yep … not listed … but nobody is sure when Google change their mind….
Can you agree this situation? LOL

Let’s access https://g.co/oldsheets to generate a spreadsheet in version 1.

It’s my sample.

It’s only one sheet. It has header, 3 cols and 2 rows.
( I’m going to generate imgur image web site. )

< Let’s make it public >
Follow the pic below.
publish_to_the_web_en_us

Select “Publish to the web” and push “Start publishing”.
See “Get a link to the published data” section.
publish_to_the_web_2_en_us
You can get your spreadsheet as Web page, HTML, CSV, TXT, PDF, ATOM, RSS, XLS and ODS.
If you want to sync spreadsheet to your website, you should choose CSV, ATOM or RSS. These are easy format for syncing. When you choose one of them, you can find the function to select column and row. This function can make file size per request smaller.

If you choose CSV, before selecting range, please select a target sheet. Sample is like the pic below.
select_sheet_en_us
In my sample, “A1” is header. I want to get 5 rows maximum. So I set the range “A2:A6”.
select_cell_en_us
You can find “range=A2%3AA6” in the url. If you want to add paging function to your web site, you should dynamically change the parameter for “range” by Javascript.

< Is it difficult? >
Don’t worry. I wrote the Javascript code here.
https://github.com/mecrazy/generateGoogleDriveUri
This script is compatible with CSV, ATOM and RSS formats. It’s only URI generator. It doesn’t have parser. If you choose ATOM or RSS, you can use jQuery as a parser.

Please use “generateGoogleDriveUri.min.js” like below.

<!DOCTYPE html>
<html>
<head>
<title>Sample page</title>
<script src="js/generateGoogleDriveUri.min.js"></script>
<script type="text/javascript">
window.onload = function(){

//Casting object
var gduObj = new genGDU('Put a link to the published data here');

//Generate URI
var atomUri = gduObj.genUri(
  'atom', // I choose ATOM format.
  {
    startRow:2, //Start from row 2
    startCol:1, //Start from col 1
    cols:1, //Cut 1 columns
    rows:5, //Cut 5 Rows per page
    page:1 //Get page 1
  }
);

var html = '<a href="' + atomUri + '" target="_blank">' + atomUri + '</a>';
document.getElementById('sample').innerHTML = html;

}
</script>
</head>
<body id="sample"></body>
</html>

< Add index.html and Drive Notepad setting >
After you add Drive Notepad on Chrome, you can find “Text Document” on create menu of your Google Drive.
add_index_en_us
If it’s your first time to use Drive Notepad, you will be asked like below.
permission_01_en_us
Push “Login and/or grant app permissions…” and accept the question below.
permission_02_en_us

Please change file name to “index.html”. After saving the file, close the tab.
change_file_name_en_us

Please change setting about “Manage apps”.
manage_apps_en_us
Please check “Use by default” of Drive Notepad row.
use_by_default_en_us
After that, you can use Drive Notepad like the other apps on Google Drive.

< Change sharing settings >
Select your folder to set public.
After that, follow the pic below.
set_sharing_enabled_01_en_us
Set “Public on the web” checked.
set_sharing_enabled_02_en_us

< Preparing HTML, CSS, Javascript >
Use Drive Notepad to prepare them.
Or edit with your own text editor and upload them.
My relative position is like below.
my_public_tree_en_us

The link below is my web page created with Google Spreadsheet.
https://googledrive.com/host/0B2hsIY7iHEnLS290OHlmRkFmbU0/
If you want, please use sources as sample.

< Extra script >
I developed imgur URL converter for my web page. If you want, please use this.
https://github.com/mecrazy/imgurUrlConverter

bochs on Raspberry Pi

< x86 on ARM >
I try to run DOS on Debian wheezy on Raspberry Pi.
( Windows95 is also possible, but it’s too slow )

< Install “bochs” >
Installing “bochs” is very easy.
Command line is as below.

root@myhost:~# apt-get install bochs bochs-x bochs-sdl bochs-svga

< Generate hard disk image >
Execute “bximage” on your Raspberry Pi.
I recommend to execute “bximage” as non-root user.
You should execute “bximage” as a user which use “bochs”.
It’s 2GB image sample.

$ bximage
========================================================================
                                bximage
                  Disk Image Creation Tool for Bochs
        $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $
========================================================================
Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd]
What kind of image should I create?
Please type flat, sparse or growing. [flat]
Enter the hard disk size in megabytes, between 1 and 129023
[10] 
2048
I will create a ‘flat’ hard disk image with
  cyl=4161
  heads=16
  sectors per track=63
  total sectors=4194288
  total size=2047.99 megabytes
What should I name the image?
[c.img] 
msdoshdd.img
Writing: [] Done.
I wrote 2147475456 bytes to msdoshdd.img.
The following line should appear in your bochsrc:
  
ata0-master: type=disk, path=”msdoshdd.img”, mode=flat, cylinders=4161, heads=16, spt=63

“bximage” said to add line “
ata0-master: type=disk, path=”msdoshdd.img”, mode=flat, cylinders=4161, heads=16, spt=63” to “.bochsrc”.

< Generate “.bochsrc” for MS-DOS >
Go to your home directory.
I use “nano” to edit text files.

$ cd /home/username
$ nano .bochsrc

My “.bochsrc” is as below.

megs: 64
romimage: file=$BXSHARE/BIOS-bochs-latest
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
display_library: sdl
ata0-master: type=disk, path=/home/username/msdoshdd.img, mode=flat, cylinders=4161, heads=16, spt=63
ata0-slave: type=cdrom, path=/home/username/MS-DOS-6.22.iso, status=inserted
boot: cdrom, disk
#keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
log: bochsout.txt
clock: sync=realtime, time0=local

“MS-DOS-6.22.iso” is my MS-DOS bootable file. Please replace it to any iso bootable file you have. In my “.bochsrc”, mouse is unavailable. If you want to use mouse, please google about “How to edit bochsrc to use mouse”.

< Install VNC >
If you use HDMI display, you don’t need this step.
If you don’t use display, you need to install VNC server to remote X on Raspberry Pi.
Execute this command line as root.

root@myhost:~# apt-get install tightvncserver

Run this command line as a user which use “bochs”.

$ vncserver :1 -geometry 1024×768 -depth 24
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? 
n
New ‘X’ desktop is myhost:1

“:1″ means port “5901″.
“-geometry 1024×768″ means resolution.
“-depth 24″ means colors in bits.

< Execute bochs >
Please connect your VNC server on Raspberry Pi. ( or use “startx” with HDMI display )
And execute terminal. ( ex. LXTerminal )
Execute bochs on terminal.

$ bochs

Sometimes bochs ask you like this syntax.

A PANIC has occurred.  Do you want to:
  cont       – continue execution
  alwayscont – continue execution, and don’t ask again.
               This affects only PANIC events from device [MEM0 ]
  die        – stop execution now
  abort      – dump core
  debug      – hand control to gdb

I always answer “alwayscont”.

< To be honest >
I tried to install Windows95.
But it needs FD images of DOS and Windows3.1. ( My Windows95 is upgrade version )
It was troublesome for me.
So I changed my goal.