Backup mysql database to amazon S3


Hits: 5327  

Below is the simple code to create sql script of database on Amazon EC2 server using “mysqldump”…

then upload this sql script to Amazon S3 bucket using command line S3 tool “s3cmd”…


<?php

$sqlbackup="/usr/bin/mysqldump -v -u root -h localhost -r /var/www/html/backup/".date("Y-m-d-H-i-s")."_db.sql -pdbusername  databasename 2>&1";

exec($sqlbackup$o);

echo 
implode("<br /> "$o);

$file "/var/www/html/backup/".date("Y-m-d-H-i-s")."_db.sql";

$bucket "s3bucketname";

exec("/usr/bin/s3cmd  put –acl-public –guess-mime-type  –config=/var/www/html/.s3cfg   ".$file."  s3://".$bucket."  2>&1"$o);

echo implode("<br /> "$o);

?>

0 */12 * * * env php -q /var/www/html/s3bkup/s3bkup.php > /dev/null 2>&1 (per 12 hours)

You can set above php file as scheduled task (cronjob) for automated backup on Amazon S3 Bucket, I mostly use CloudBerry Explorer for Amazon S3 PRO for managing Amazon S3 files 😉

Installing XAMPP in Linux


Hits: 7116  

What is XAMPP ?

XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. LAMPP (XAMPP for Linux) is very easy to install and to use – just download, extract and start.

Download XAMPP

http://sourceforge.net/projects/xampp/files/XAMPP Linux/

Installing XAMPP in Linux

Download XAMPP Latest version from the following link
http://sourceforge.net/projects/xampp/files/XAMPP Linux

Currently latest XAMPP version is 1.7.3a

$wget http://downloads.sourceforge.net/project/xampp/XAMPP%20Linux/1.7.3a/xampp-linux-1.7.3a.tar.gz?use_mirror=nchc

Now you should be having xampp-linux-1.7.3a.tar.gz in your downloaded location

Go to a Linux shell and login as root:
Perform these commands as root user

$ su -p
Extract the downloaded archive file to /opt

#tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

XAMPP is now installed below the /opt/lampp directory.

Start XAMPP Server

To start XAMPP simply call this command:

#/opt/lampp/lampp start

Starting XAMPP for 1.7.3a…
XAMPP: Starting Apache with SSL (and PHP5)…
XAMPP: Starting MySQL…
XAMPP: Starting ProFTPD…
XAMPP for Linux started.

Test Your XAMPP Installation

OK, that was easy but how can you check that everything really works? Just type in the following URL at your favourite web browser:

http://localhost

Starting LAMPP automatically on startup
Starting LAMPP automatically on startup

XAMPP Security Configuration

As mentioned before, XAMPP is not meant for production use but only for developers in a development environment. The way XAMPP is configured is to be open as possible and allowing the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

Here a list of missing security in XAMPP:

The MySQL administrator (root) has no password.
The MySQL daemon is accessible via network.
ProFTPD uses the password “lampp” for user “nobody”.
PhpMyAdmin is accessible via network.
Examples are accessible via network.
MySQL and Apache running under the same user (nobody).
To fix most of the security weaknesses simply call the following command:

#/opt/lampp/lampp security

It starts a small security check and makes your XAMPP installation more secure.
Start And Stop Server Services

start
Starts XAMPP.

stop
Stops XAMPP.

restart
Stops and starts XAMPP.

startapache
Starts only the Apache.

startssl
Starts the Apache SSL support. This command activates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay activated.

startmysql
Starts only the MySQL database.

startftp
Starts the ProFTPD server. Via FTP you can upload files for your web server (user “nobody”, password “lampp”). This command activates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay activated.

stopapache
Stops the Apache.

stopssl
Stops the Apache SSL support. This command deactivates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay deactivated.

stopmysql
Stops the MySQL database.

stopftp
Stops the ProFTPD server. This command deactivates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay deactivated.

security
Starts a small security check programm.

For example: To start Apache with SSL support simply type in the following command (as root):

#/opt/lampp/lampp startssl

You can also access your Apache server via SSL under https://localhost.

Important Configuration Files And Directories

/opt/lampp/bin/ – The XAMPP commands home. /opt/lampp/bin/mysql calls for example the MySQL monitor.
/opt/lampp/htdocs/ – The Apache DocumentRoot directory.
/opt/lampp/etc/httpd.conf – The Apache configuration file.
/opt/lampp/etc/my.cnf – The MySQL configuration file.
/opt/lampp/etc/php.ini – The PHP configuration file.
/opt/lampp/etc/proftpd.conf – The ProFTPD configuration file. (since 0.9.5)
/opt/lampp/phpmyadmin/config.inc.php – The phpMyAdmin configuration file.

Stopping XAMPP

To stop XAMPP simply call this command:

#/opt/lampp/lampp stop

You should now see:

Stopping XAMPP 1.7.3a…
XAMPP: Stopping Apache…
XAMPP: Stopping MySQL…
XAMPP: Stopping ProFTPD…
XAMPP stopped.

And XAMPP for Linux is stopped.

Starting LAMPP automatically on startup

For starting LAMPP automatically on startup, add the following line to you /etc/rc.local file

# /opt/lampp/lampp start

where /opt/lampp is the location where XAMPP files are kept. You will have to substitute the path to your XAMPP in the above command.

Uninstall XAMPP From your Machine

To uninstall XAMPP just type in this command

#rm -rf /opt/lampp


Install RED5 with java tomcat on linux


Hits: 5126  
http://www.red5.org/
http://www.red5.org/

Red5 is an Open Source Flash Server written in Java that supports:

  • Streaming Audio/Video (FLV, h264, AAC, and MP3)
  • Recording Client Streams (FLV only)
  • Shared Objects
  • Live Stream Publishing
  • Remoting (AMF)

export variables in /etc/bashrc to become available for every user login or for any terminal opens.

echo “export ANT_HOME=/usr/local/ant” >> /etc/bashrc
echo “export JAVA_HOME=/usr/lib/jvm/java” >> /etc/bashrc

set CLASS PATH for java

# vi /etc/profile

JAVA_HOME=/usr/java/jdk1.6
export JAVA_HOME

Start/Stop Tomcat

# cd /usr/java/tomcat/bin
# ./shutdown.sh
# ./startup.sh

# cd ../webapps/
# netstat -ntlp|grep 1935

Install Tomcat

# wget http://www.trieuvan.com/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz
# tar xzf apache-tomcat-6.0.20.tar.gz
# ls
# mv apache-tomcat-6.0.20 tomcat
# mv tomcat /usr/java/
# cd /usr/java/tomcat/
# vi /etc/profile    (set class path)
# source /etc/profile
# /usr/java/tomcat/bin/startup.sh

Install Red 5

# wget http://dl.fancycode.com/red5/war/red5-0.6.2-java6.war
# ls
# cp red5-0.6.2-java6.war  /usr/java/tomcat/webapps/
# cd /usr/java/tomcat/bin
# ./shutdown.sh
# netstat -ntlp|grep 1935
# netstat -ntlp|grep 8080
# ./catalina.sh start

We are always hungry for TIME 😉


Lunarpages.com Web Hosting

Crontab Command Line


Hits: 2004  

crontab Crontab Command Line

1. dump the content of the existing crontab to a file
# crontab > /tmp/dump
2. echo “your lines” >> to the corntab file
# echo ” 00 1 * * * /monitor_file_system 2>/dev/null” >> /tmp/dump
3. import the new crontab
# crontab /tmp/dump

other option….
# crontab -e
It will open a editor, add job here like
00 1 * * * /monitor_file_system 2>/dev/null

Set cronjob from other server:
# crontab -e
0 0 * * * curl http://www.domain.com/svnlabs.php

here svnlabs.php file is located on different server…

and save this crontab files…. now cronjob successfully installed 🙂

CakePHP in svnlabs


Hits: 2154  
CakePHP in svnlabs
CakePHP in svnlabs

CakePHP is the rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. It follows design patterns like MVC and ORM, CakePHP reduces development costs and helps developers write less code.

Features of CakePHP:
– Extremely Simple.
– Active, Friendly Community.
– Flexible License.
– Clean IP
– Best security, authentication, and session handling.
– Compatible with PHP versions 4 and 5.
– Integrated CRUD for database interaction
– Application scaffolding
– Code generation
– MVC architecture
– Flexible ACL
– Data Sanitization
– Flexible Caching
– Request dispatcher with custom URLs
– Built-in validation.
– Helpers for AJAX, JavaScript, HTML Forms and more
– Email, Cookie, Security, Session, Request Handling etc.
– Localization

CakePHP Console

# ./cake bake all

# ./cake bake model models -app /var/www/cakeproject/app
# ./cake bake controller models -app /var/www/cakeproject/app scaffold admin
# ./cake bake view models -app /var/www/cakeproject/app

Source:
http://cakephptips.blogspot.com/
http://teknoid.wordpress.com/2008/06/09/15-essential-cakephp-tips/

wsdl in php


Hits: 1811  

We can use nusoap and pear library to invoke web service … there are some command line tools to consume services and generate/validate wsdl …..

1. wsdl (call method at CLI)
# wsdl WSDL_URL METHOD

2. soapUI
create wsdl project and use web services

3. wsdl2php
wsdl2php convert service methods as the class like structure
http://www.urdalen.no/wsdl2php/manual.php

4. SoapClient – PHP
$path_wsdl = “wsdl/svnlabs7.wsdl”;
$client = new SoapClient($path_wsdl, array(‘trace’ => 1));
$request = array(‘….. |wsdl request array| ……’);
$response = $client ->getLog($request);

5. nuSOAP
http://sourceforge.net/projects/nusoap/

Resources:
http://wsdlpull.sourceforge.net/
http://code.google.com/p/ezerphp/
http://www.mehtanirav.com/2008/12/26/xplanner-php-soap-client
http://code.google.com/p/wsdl2php-interpreter/
https://www.ohloh.net/p/php-wsdl-viewer
http://php.net/manual/en/book.soap.php
http://phpwebservices.blogspot.com/

midentify – mplayer


Hits: 1534  

midentify – It is the utility come with mplayer to find video ID of video files….

# /usr/bin/midentify video.mp4
ID_VIDEO_ID=0
ID_AUDIO_ID=1
ID_AID_1_LANG=eng
ID_FILENAME=video.mp4
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=avc1
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=320
ID_VIDEO_HEIGHT=240
ID_VIDEO_FPS=25.000
ID_VIDEO_ASPECT=1.3333
ID_AUDIO_FORMAT=255
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=24000
ID_AUDIO_NCH=2
ID_LENGTH=72.62
ID_SEEKABLE=1
ID_CHAPTERS=0
ID_VIDEO_CODEC=ffh264
ID_AUDIO_BITRATE=128000
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=2
ID_AUDIO_CODEC=faad
ID_EXIT=EOF

Try # mediainfo to get video infrmation on linux box  🙂

HTMLDOC – html2image


Hits: 3050  

htmldoc is a powerful simple-to-use tool/utility, which converts HTML to Postscript, PDF or indexed HTML output.

# convert /var/www/html/html2img/grid.ps -crop 280×300+40+9 -modulate 100 -geometry 530×480 /var/www/html/html2img/grid.png

here convert is ImageMagick tool for manipulating images..

TinyMCE load ajax


Hits: 2192  

Today I got problem to load TinyMCE as dynamic loaded textareas by Ajax?

Solution:

<a href=”javascript:void(0)” onclick=”ajaxEdit(); showEditor();”>Edit Content</a>

here ajaxEdit() is ajax function where textarea loaded by ajax as html response.

here we have use showEditor(); to load TinyMCE editor … page loaded by Ajax

<script>

function showEditor()
{

setTimeout(“initEditor(‘newsdesc’)”,4000);

}

tinyMCE.init({………………………
…………………………………………………});

function initEditor(id)
{

tinyMCE.execCommand(‘mceAddControl’, false, id);

}

</script>

tiny