Thursday, April 24, 2014

free web host cloud introduct - openshift

this is git address:

ssh://52c6d36f5973ca9404XXXXXX@{app name}-{other name}

NOW, mysql 5.5 address:

Database Name: {app name}
Password: xxxxxxxxxx

Username: xxxxxxxxx


1.setup rhc client on my windows worker.
1.1 install cygwin,with ruby

download ruby gem


ruby setup.rb install

gem update --system


for linux:

sudo yum install rubygems git


1.2.Installing OpenShift RHC Client Tools


gem install rhc

rhc setup

// typed in your account and passwords


3.clear old data
rhc app force-stop -a {app name}
rhc app-tidy -a {app name}
rhc app restart -a {app name}

4.add multiple account

rhc setup -l {openshift email account}

5.port forward // this command can bind remote mysql ip and port to port
rhc port-forward -a {app name}

This is output:

Service Local OpenShift

------- --------------- ---- ------------------------------------------------

haproxy =>

haproxy =>

httpd =>

mysql =>


Press CTRL-C to terminate port forwarding



6.create cron service

\> rhc app cartridge add -a {app name}-c cron

\> vi ~/app-root/repo/.openshift/cron/daily/cleanup-old-logs

rm -rf ~/app-root/logs/*

rm -rf ~/haproxy/logs/*


# find . -type f \( -name access_log-\* , -name error_log-\* \) -mtime +3 -exec rm {} \; # Add this to the above command to backup as a gzipped tarball: | xargs tar -czvf backup-logs-$(date +%Y%m%d).tar.gz

# Add this to the above command to delete 'em: -exec rm {} \; or | xargs rm)


\> ~/app-root/repo/.openshift/cron/hourly/test1

/usr/bin/curl can used this to do some other my hourly work.


7.fixed default mysql 5.1 file is out of quota 100%,and it cannot start(delete old,add new cartridge)

problem message: openshift MySQL 5.1 is using 100.0% of disk quota
\> rhc app cartridge remove -a {app name} -c mysql-5.1

\> rhc app cartridge add -a {app name} -c mysql-5.5


after that,your can not used default $_SERVER['OPENSHIFT_MYSQL_DB_HOST'] code to get mysql profile,now your need input your new right value to php mysql connection string.
8 remove unused files

rm -rf ~/git/{app name}.git/objects/pack/*

rm -rf ~/app-deployments/{year}-{monty}-{day}_{hour}-{day}-{second}.{microsecond}/repo/*

rm -rf ~/app-root/logs/* # (above cron is also clean this logs)
rm -rf ~/haproxy/logs/*


x.other commands

see directory size: du -sh *

delete logs files: rm -rf ~/php/logs/*