Hosting_VPS

http://daniel.gnoutcheff.name/dotname/reglist/

To restart

sudo reboot

For the ASP/DOT_NETer's

http://www.everleap.com/home.aspx

Engine X vs Apache

http://www.wikivs.com/wiki/apache_vs_nginx

http://www.everleap.com/cloud-hosting/vs-traditional-hosting/vps/
...but no root access/control

Tomcat cheap!

http://www.dailyrazor.com/java-jsp-hosting/private-tomcat-hosting/?java-code-geeks


Digital Oceans  (nice interface and api, and ssh of course)

https://www.digitalocean.com/pricing/
 for developers $10 a month!
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get


lots of locations/redundancy/speed

allows VM snapshots, etc...

promo code "last digital" (2 months free)

VPS - virtual private server .....down to $15/mo


https://www.godaddy.com/pro/managed-vps

Self-managed, non-gui linux with 3 ip addrs, 1GB ram, and 40GB drive is only $15/mo

https://www.godaddy.com/pro/managed-vps-config?plan=pro_vps_linux_t1_12month&planaddons=pro_vps_managed



This means you have full control of a virtual private server without having to purchase a static / business class internet at your house and of course the -server hardware.

.NAME tld is a must on the BucketList!

JoeSmith.name

ex: http://davidwalsh.name/


The domain name "name" is a generic top-level DNS domain (gTLD) in the Domain Name System of the Internet. It is intended for use by individuals for representation of their personal name, nicknames, screen names, pseudonyms, or other types of identification labels.
On the .name TLD, domains may be registered on the second level (john.name) and the third level (john.doe.name). It is also possible to register an e-mail address of the formjohn@doe.name. Such an e-mail address may have to be a forwarding account and require another e-mail address as the recipient address, or may be treated as a conventional email address (such as john@doe.com), depending on the registrar.


Digital Oceans vps (Ubuntu 14)

sudo apt-get install default-jdk

rot@C:~# sudo update-alternatives --config java
or which java  ...both showed /usr/bin/java

sudo nano /etc/environment
JAVA_HOME="/usr/bin/java"
source /etc/environment
echo $JAVA_HOME
java -version


Tomcat run as unprivileged user (not root). 


  home is /opt/tomcat (where we will install Tomcat), 
  w/shell of /bin/false (so nobody can log into the account):
  sudo groupadd tomcat
  sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
  download latest tomcat binary & config it manually
  wget http://mirror.sdunix.com/apache/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.tar.gz
  sudo mkdir /opt/tomcat
  sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
  cd /opt/tomcat
  sudo chgrp -R tomcat conf
  sudo chmod g+rwx conf
  sudo chmod g+r conf/*
  sudo chown -R tomcat work/ temp/ logs/

# add startup script
sudo nano /etc/init/tomcat.conf
description "Tomcat Server"
  start on runlevel [2345]
  stop on runlevel [!2345]
  respawn
  respawn limit 10 5

  setuid tomcat
  setgid tomcat

  env JAVA_HOME=/usr/bin/java
  env CATALINA_HOME=/opt/tomcat

  # Modify these options as needed
  env JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
  env CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

  exec $CATALINA_HOME/bin/catalina.sh run

  # cleanup temp directory after stop
  post-stop script
    rm -rf $CATALINA_HOME/temp/*
  end script

now reload upstart
sudo initctl reload-configuration

now start tomcat


if it fails then create bin/setenv.sh
 with this line
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

then try again

verify
netstat -ano | grep 80 



Change putty deamon listening port

 nano /etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
Port 520
sudo /etc/init.d/ssh restart



ubuntu likes tar.gz's  NOT rpm's!

rot@IC:/opt/tomcat/logs# chown tomcat:tomcat webapps/
rot@IC:/opt/tomcat# chown -R tomcat:tomcat *


got 32-bit (“i686” or “i386”) or 64-bit (“x86_64”)?
rot@IC:/opt/tomcat/logs# uname -a
Linux IC 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


To use ports lower than 1024 the application needs to be started by a root user (which is usually bad juju)

So it is better to port forward (or use rev proxy such as nginX)

setup firewall

sudo ufw allow ssh
sudo ufw allow 221/tcp
sudo ufw allow 221/udp

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8089/tcp
sudo ufw show added
sudo ufw enable

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8089
sudo iptables-save

List forwarding/NATing rules

sudo iptables -L -vt nat | grep 80
    6   312 REDIRECT   tcp  --  any    any     anywhere             anywhere             tcp dpt:http redir ports 8089

List rules by specification
sudo iptables -S


List ALL iptables settings and routing rules
sudo iptables -L


sudo iptables -L -vt nat
 to List your iptables PREROUTING rules

List chain and line number
sudo iptables -L --line-numbers

Delete rule 3 of the "INPUT" chain
sudo iptables -D INPUT 3



List nat entries and their line numbers 
iptables -t nat --line-numbers -L

Remove PREROUTING chain line 6:
iptables -t nat -D PREROUTING 6


after changing firewall (add/chg/del rules), you must restart it:
sudo ufw disable
sudo ufw enable  
or       sudo service ufw restart
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

check firewall status

ufw status



rot@IC:~# sudo ufw status numbered

Status: active

To                         Action      From
--                         ------      ----
80/tcp                     ALLOW       Anywhere
224                        ALLOW       Anywhere
229/tcp                    ALLOW       Anywhere
443/tcp                    ALLOW       Anywhere
229/udp                    ALLOW       Anywhere
8088/tcp                   ALLOW       Anywhere


To reorder/resort the sequence of the firewall rules, you can edit the rules file:

nano /lib/ufw/user.rules

Add tomcat service (and script)


create init script to start tomcat after NICs are configed
/etc/init.d/tomcat

--------------------------------------------------------------------
#!/bin/bash

### BEGIN INIT INFO
# Provides:        tomcat
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

start() {
 sh /opt/tomcat/bin/startup.sh
}

stop() {
 sh /opt/tomcat/bin/shutdown.sh
}

case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac
--------------------------------------------------------------------
add correct symlinks:

chmod 755 /etc/init.d/tomcat
sudo service        tomcat start|stop|restart
sudo update-rc.d    tomcat defaults
sudo update-rc.d -f tomcat remove


to manually start:
  service tomcat <stop|start|restart>

tomcat stdout logs are stored here
   /var/log/upstart/tomcat.log
other logs here
   /opt/tomcat/logs#
-rw-r--r-- 1 tomcat tomcat  31933 Sep  8 16:59 catalina.2015-09-08.log
-rw-r--r-- 1 tomcat tomcat 106797 Aug 25 16:55 catalina.out
-rw-r--r-- 1 tomcat tomcat      0 Sep  8 14:52 host-manager.2015-09-08.log
-rw-r--r-- 1 tomcat tomcat   1668 Sep  8 16:24 localhost.2015-09-08.log
-rw-r--r-- 1 tomcat tomcat  12076 Sep  8 17:13 localhost_access_log.2015-09-08.txt
-rw-r--r-- 1 tomcat tomcat      0 Sep  8 14:52 manager.2015-09-08.log

Example

rot@IC:/opt# sudo service        tomcat start
start: Job is already running: tomcat
rot@IC:/opt# ./tomcat/bin/shutdown.sh
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
root@INFODOC:/opt# sudo update-rc.d tomcat defaults
 Adding system startup for /etc/init.d/tomcat ...
   /etc/rc0.d/K20tomcat -> ../init.d/tomcat
   /etc/rc1.d/K20tomcat -> ../init.d/tomcat
   /etc/rc6.d/K20tomcat -> ../init.d/tomcat
   /etc/rc2.d/S20tomcat -> ../init.d/tomcat
   /etc/rc3.d/S20tomcat -> ../init.d/tomcat
   /etc/rc4.d/S20tomcat -> ../init.d/tomcat
   /etc/rc5.d/S20tomcat -> ../init.d/tomcat



curl

 curl http://localhost:8088

useful command alias'

#add to ~/.bash_aliases

rot@IC:~# nano   ~/.bash_aliases
alias e='exit'
alias s='sudo'
alias restart='sudo shutdown –r now'   #disable root pwd "sudo chmod u+s /sbin/shutdown"
alias mounted='mount | column –t'
alias documents='cd ~/Documents'
alias downloads='cd ~/Downloads'
alias desktop='cd ~/Desktop'
alias ..='cd ..'
alias ...='cd ../..'
alias ts='nano /opt/tomcat/conf/server.xml'
alias tc='cat /opt/tomcat/logs/catalina.out'
alias ports='netstat -plunt'
alias ct='cd /opt/tomcat'
alias tstop='sudo service tomcat stop'
alias tstart='sudo service tomcat start'
alias f='find / -name '
alias tl='cat /var/log/upstart/tomcat.log'
alias nt='netstat -plunt'
alias fws='sudo ufw status'
alias fwl='cat /var/log/ufw.log'
alias fws='sudo ufw status numbered'
alias tp='ps -ef | grep tomcat'
alias aliases='cat ~/.bash_aliases'


rerun/reload it
. ~/.bashrc


.bashrc - Interactive Console/Terminal (Gnome, KDE, Xfce...)


add login scripts/commands to

.profile - TTY Console/Terminal  (replaced the old .bash_profile)

Get SshHostKeyFingerprint for winSCP

 ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

Comments

Popular Posts