2008-05-23

vsFTPD on SELinux

500 OOPS: cannot change directory

#su -
#getsebool -a | grep ftp

output :
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_disable_trans --> off
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off


#setsebool -P ftp_home_dir on




By : ต้นร่มเกล้า

2008-05-22

FreeNAS

FreeNAS is a free network-attached storage server, supporting: CIFS (Samba), FTP, NFS, rsync, AFP protocols, iSCSI, S.M.A.R.T., local user authentication, and software RAID (0,1,5), with a web-based configuration interface. FreeNAS takes less than 32 MB once installed on CompactFlash, hard drive or USB flash drive.[1] FreeNAS is currently distributed as an ISO image and in source form. It is possible to run FreeNAS from a Live CD, with the configuration files stored on an MS-DOS-formatted floppy disk. There is also a VMWare disk image available.

The minimal FreeBSD 6.2 distribution, web interface, PHP scripts, and documentation are based on m0n0wall. FreeNAS is released under the BSD license.

URL : http://www.freenas.org/


By : ต้นร่มเกล้า

2008-05-21

STOMP Delete Queue on ActiveMQ Server

PHP Code :

require_once("Stomp.php");

// make a connection
$con = new StompConnection("tcp://localhost:61613");

// connect
$con->connect();

// subscribe to the queue
$con->subscribe("/queue/test");

// receive a message from the queue
$msg = $con->readFrame();

// Print Result
print_r( $msg );

// Delete queue
$con->ack($msg->headers['message-id']);

// disconnect
$con->disconnect();

XMPPHP Connect Google Talk!!

XMPPHP

URL : http://code.google.com/p/xmpphp/

XMPPHP is the successor to Class.Jabber.PHP that I've been promising for years. Taking advantage of PHP5, I believe it to be an elegant solution with a direct approach.

Some of the features include:

  • Connect to any XMPP 1.0 server (Google Talk, LJ Talk, jabber.org, etc)
  • Supports TLS encryption
  • Several XML processing approaches and supported styles (process indefinitely, processUntil an event, processTime for a number of seconds), waiting on events or map them, etc.
  • Persistent connections (AJAX Web client anyone?)

I don't host the SVN @ Google, so get it at svn://netflint.net/xmpphp . I encourage you to check out my python XMPP Library (SleekXMPP) at http://code.google.com/p/sleekxmpp .

Feel fee to IM me any time with questions, feature requests, etc. Don't be afraid to take a little bit of my time!

Jabber ID: fritzy AT netflint.net

Jabber MUC (Chatroom): xmpphp@conference.psi-im.org

Examples

A simple code example for sending messages:

include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'username', 'password', 'xmpphp', 'gmail.com', $printlog=False, $loglevel=LOGGING_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('someguy@someserver.net', 'This is a test message!');
$conn->disconnect();
?>

To not use SSL/TLS encryption if available, set

$conn->use_encryption = False;

before calling connect()

Apache ActiveMQ

Apache ActiveMQ is the most popular and powerful open source Message Broker and Enterprise Integration Patterns provider.

Apache ActiveMQ is fast, supports many Cross Language Clients and Protocols, comes with easy to use Enterprise Integration Patterns and many advanced features while fully supporting JMS 1.1 and J2EE 1.4. Apache ActiveMQ is released under the Apache 2.0 License

Grab yourself a Download, try our Getting Started Guide, surf our FAQ or start Contributing and join us on our Discussion Forums.


Features

  • Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP
    • OpenWire for high performance clients in Java, C, C++, C#
    • Stomp support so that clients can be written easily in C, Ruby, Perl, Python, PHP, ActionScript/Flash, Smalltalk to talk to ActiveMQ as well as any other popular Message Broker
  • full support for the Enterprise Integration Patterns both in the JMS client and the Message Broker
  • Supports many advanced features such as Message Groups, Virtual Destinations, Wildcards and Composite Destinations
  • Fully supports JMS 1.1 and J2EE 1.4 with support for transient, persistent, transactional and XA messaging
  • Spring Support so that ActiveMQ can be easily embedded into Spring applications and configured using Spring's XML configuration mechanism
  • Tested inside popular J2EE servers such as Geronimo, JBoss 4, GlassFish and WebLogic
    • Includes JCA 1.5 resource adaptors for inbound & outbound messaging so that ActiveMQ should auto-deploy in any J2EE 1.4 compliant server
  • Supports pluggable transport protocols such as in-VM, TCP, SSL, NIO, UDP, multicast, JGroups and JXTA transports
  • Supports very fast persistence using JDBC along with a high performance journal
  • Designed for high performance clustering, client-server, peer based communication
  • REST API to provide technology agnostic and language neutral web based API to messaging
  • Ajax to support web streaming support to web browsers using pure DHTML, allowing web browsers to be part of the messaging fabric
  • CXF and Axis Support so that ActiveMQ can be easily dropped into either of these web service stacks to provide reliable messaging
  • Can be used as an in memory JMS provider, ideal for unit testing JMS


STOMP Client and ActiveMQ

Stomp

The Stomp project is the Streaming Text Orientated Messaging Protocol site (or the Protocol Briefly Known as TTMP and Represented by the symbol :ttmp).

Stomp provides an interoperable wire format so that any of the available Stomp Clients can communicate with any Stomp Message Broker to provide easy and widespread messaging interop among languages, platforms and brokers.


Easy Integration

Stomp is a very simple and easy to implement protocol, coming from the HTTP school of design; the server side may be hard to implement well, but it is very easy to write a client to get yourself connected. For example you can use Telnet to login to any Stomp broker and interact with it!

Many developers have told us that they have managed to write a Stomp client in a couple of hours to integrate their particular language, runtime or platform into the Stomp network. So if your favoured language/runtime of choice does not offer a good enough Stomp client please try write one as we love contributions!


Stomp client for PHP
Download the current release from http://stompcli.googlecode.com/files/stompcli-php4-1.0-SNAPSHOT.tar.gz

After you download the archive, extract it to your include_path. Once you've done that, you can use the client as follows

PHP Code:
// include a library
require_once("stomp/Stomp.php");
// make a connection
$con = new StompConnection("tcp://localhost:61613");
// connect
$con->connect();
// send a message to the queue
$con->send("/queue/test", "test");
// subscribe to the queue
$con->subscribe("/queue/test");
// receive a message from the queue
$msg = $con->readFrame();

// do what you want with the message
$this->assertEquals($msg->body, "test");

// disconnect
$con->disconnect();



Find Process ID (PID) and Kill Process

Linux Command :

Step 1 : Find PID
#ps -ef | grep [service name]

Step 2 : Kill PID
#kill [Number of PID]

Creating a Unix Service for ActiveMQ

Installation

Sun Java JDK

1. Install Sun Java JDK on /opt/java/ directory.

2. Create a shortcut to JDK directory:

sudo ln -s /opt/java/jdk1.5.0_06 /opt/java/java

ActiveMQ

1. Install ActiveMQ on /opt/activemq/ directory.

2. Make ActiveMQ startup and shutdown scripts executable:

sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/activemq
sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/shutdown

ActiveMQ as Linux Daemon

1. Create activemq user:

sudo /usr/sbin/useradd activemq

2. Create ActiveMQ startup script /home/activemq/activemqstart.sh with the
following content:

#!/bin/bash
export JDK_HOME=/opt/java/java
export JAVA_HOME=/opt/java/java
/opt/activemq/incubator-activemq-4.0/bin/activemq &

3. Make /home/activemq/activemqstart.sh executable:

sudo chmod +x /home/activemq/activemqstart.sh

4. Create ActiveMQ shutdown script /home/activemq/activemqstop.sh with the
following content:

#!/bin/bash
export JDK_HOME=/opt/java/java
export JAVA_HOME=/opt/java/java
/opt/activemq/incubator-activemq-4.0/bin/shutdown

5. Make /home/activemq/activemqstop.sh executable:

sudo chmod +x /home/activemq/activemqstop.sh

6. Create ActiveMQ Linux service configuration script /etc/init.d/activemq
with the following content:

#!/bin/bash
#
# activemq Starts ActiveMQ.
#
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: $activemq
### END INIT INFO

# Source function library.
. /etc/init.d/functions

[ -f /home/activemq/activemqstart.sh ] || exit 0
[ -f /home/activemq/activemqstop.sh ] || exit 0

RETVAL=0

umask 077

start() {
echo -n $"Starting ActiveMQ: "
daemon /home/activemq/activemqstart.sh
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down ActiveMQ: "
daemon su -c /home/activemq/activemqstop.sh activemq
echo
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

exit $?

7. Enable ActiveMQ service configuration as Linux Daemon:

sudo chmod +x /etc/init.d/activemq
sudo /sbin/chkconfig --add activemq
sudo /sbin/chkconfig activemq on

8. Restart the server.



By : ต้นร่มเกล้า




Source : http://activemq.apache.org/unix-service.html