FTP server cent os

http://cafeandrew.com/archives/2339

#instalar FTP server
sudo yum install vsftpd

#configurar serviço
sudo vim /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=

#iniciar serviço
sudo service vsftpd start

#ativar no start-up
sudo chkconfig vsftpd on

liberar portas 20-21 e 1024-1048 no firewall

Tomcat 8 rodando como serviço

#adicionar o script do final do post com o nome tomcat em /etc/init.d/

sudo vim /etc/init.d/tomcat

#tornar arquivo executável

sudo chmod +x /etc/init.d/tomcat

#adicionar script ao chkconfig

sudo chkconfig --add /etc/init.d/tomcat

#habilitar o serviço no startup EC2

sudo chkconfig tomcat on

#Ubuntu

sudo update-rc.d tomcat defaults

Arquivo: tomcat

#!/bin/bash
#
# tomcat8 This shell script takes care of starting and stopping Tomcat
# Description: This shell script takes care of starting and stopping Tomcat
# chkconfig: - 80 20
#
## http://blog.maestropublishing.com/2013/04/23/tomcat7-service-startstop-script/
## Source function library.
. /etc/init.d/functions

TOMCAT_HOME=/home/ec2-user/tomcat
SHUTDOWN_WAIT=30

tomcat_pid() {
  echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Tomcat is already running (pid: $pid)"
  else
    # Start tomcat
    echo "Starting tomcat"
    /bin/bash $TOMCAT_HOME/bin/startup.sh
  fi
  return 0
}

stop() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Stopping Tomcat"
    /bin/bash $TOMCAT_HOME/bin/shutdown.sh

    let kwait=$SHUTDOWN_WAIT
    count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit";
      sleep 1
      let count=$count+1;
    done

  if [ $count -gt $kwait ]
  then
    echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds"
    kill -9 $pid
  fi
  else
    echo "Tomcat is not running"
  fi
  return 0
}

case $1 in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  status)
    pid=$(tomcat_pid)
    if [ -n "$pid" ]
      then
      echo "Tomcat is running with pid: $pid"
      else
      echo "Tomcat is not running"
    fi
    ;;
esac
exit 0

Instalar java Oracle a partir de um RPM

Para instalar o JDK da oracle a partir de um pacote RPM execute os seguintes comandos abaixo no terminal:

1 – Download da versão escolhida, neste caso 8u25

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.rpm

2 – Instalar o java

sudo rpm -ivh jdk-8u31-linux-x64.rpm

3 – Adicionar nas alternativas do sistema operacional

sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_31/bin/java 100

4 – Configurar o java default

sudo /usr/sbin/alternatives --config java

5 – Conferir se está apontando para o java correto

java -version

Para remover execute os seguintes comandos:

1 – Remover das alternativas do sistema operacional

sudo /usr/sbin/alternatives --remove java /usr/java/jdk1.8.0_25/bin/java

2 – Executar uma query no gerenciador de pacotes para identificar o nome do pacote a ser excluído

rpm -qa | grep jdk

3 – Remover o pacote instalado

sudo rpm -e jdk1.8.0_25-1.8.0_25-fcs.x86_64

4 – Apagar o pacote baixado

rm jdk-8u25-linux-x64.rpm