title: Configuring ActiveMQ 5.6.0 as a UNIX service on CentOS 32bit from command line
body: <p>I can currently start ActiveMQ using xbean but ActiveMQ is not starting as UNIX service on boot</p>
  
  <pre><code>/home/username/activemq/bin/activemq start xbean:/home/username/activemq/conf/my-activemq.xml
  </code></pre>
  
  <p>the console prompted me to run setup so i</p>
  
  <pre><code>/home/username/activemq/bin/activemq setup etc/default/activemq
  </code></pre>
  
  <p>I'm confused why the console says to create a config file if I'm using xbean</p>
  
  <p>then i created producer.php and consumer.php</p>
  
  <pre><code>cd /etc/init.d/
  
  cat &gt; producer.php
  
  &lt;?php
  $queue1  = '/queue/queue1';
  try {$stomp = new Stomp('tcp://localhost:61613');} 
  catch(StompException $e) {die('Connection failed: ' . $e-&gt;getMessage());}
  for($i=1;$i&lt;10;$i++){$msg1 = "queue one my data".$i; 
  $stomp-&gt;send($queue1, $msg1, array('persistent' =&gt; 'true'));}    
  unset($stomp);
  ?&gt;
  
  cat &gt; consumer.php
  
  &lt;?php 
  $queue1  = '/queue/queue1';
  try {$stomp = new Stomp('tcp://localhost:61613');}
  catch(StompException $e) {die('Connection failed: ' . $e-&gt;getMessage());}
  $stomp-&gt;subscribe($queue1);
  while(1){$frame = $stomp-&gt;readFrame();
  if ( $frame != null) {echo $frame-&gt;body; //process your message
  echo "\n";  
  $stomp-&gt;ack($frame);}} unset($stomp);
  ?&gt;
  </code></pre>
  
  <p>started consumer.php with nohup</p>
  
  <pre><code>nohup php consumer.php &gt; consumer.log 2&gt;&amp;1 &amp;
  </code></pre>
  
  <p>it returned this to the console </p>
  
  <pre><code>[1] 32707
  </code></pre>
  
  <p>created startup file</p>
  
  <pre><code>cat &gt; activemqstart.sh
  
  #!/bin/bash
  export JAVA_HOME=/usr
  /usr/share/php/activemq/bin/activemq &amp;
  </code></pre>
  
  <p>created stop file</p>
  
  <pre><code>cat &gt; activemqstop.sh
  
  #!/bin/bash
  export JAVA_HOME=/usr
  /usr/share/php/activemq/bin/activemq-admin stop
  </code></pre>
  
  <p>service configuration script</p>
  
  <pre><code>cat &gt; activemq
  
  #!/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 /etc/init.d/activemqstart.sh ] || exit 0
  [ -f /etc/init.d/activemqstop.sh ] || exit 0
  
  RETVAL=0
  
  umask 077
  
  start() {
     echo -n $"Starting ActiveMQ: "
     daemon /etc/init.d/activemqstart.sh
     echo
     return $RETVAL
  }
  stop() {
     echo -n $"Shutting down ActiveMQ: "
     daemon su -c /etc/init.d/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 $?
  </code></pre>
  
  <p>then i set permissions</p>
  
  <pre><code>chmod +x /etc/init.d/activemqstart.sh
  chmod +x /etc/init.d/activemqstop.sh
  chmod +x /etc/init.d/activemq
  /sbin/chkconfig --add activemq
  /sbin/chkconfig activemq on
  </code></pre>
  
  <p>cleared the actviemq.log</p>
  
  <pre><code>cat /dev/null &gt; /home/username/activemq/data/activemq.log
  </code></pre>
  
  <p>rebooted</p>
  
  <pre><code>reboot
  </code></pre>
  
  <p>and checked the log but it's empty and ActiveMQ is not running</p>
  
  <pre><code>more /home/username/activemq/data/activemq.log
  </code></pre>