Pages

Sunday, December 26, 2010

Setting new dedicated server

I'm migrating my VPS server to a new dedicated server. So i need to repeat the same proses I've done for the old server to this one. For future reference , I'm going to document my steps :)


Setting swappiness

To set the vm.swappiness permanently you need to edit the /etc/sysctl.conf file and add the line

vm.swappiness=10

The default number usually 60. The smaller the number means that your system is unlikely to swap process from memory to the swap space. To see the change, use :

cat /proc/sys/vm/swappiness


Installing Sun JDK package

I'm still very fond to use the JDK from SUN, to do that in ubuntu you need to follow this steps.

You can add the repository manually by editing /etc/apt/sources.list
or installing the package python-software-properties and run

sudo apt-get install mysql-server-5.1

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

Then, update the repository information and install the jdk

sudo apt-get update
sudo apt-get install sun-java6-jdk

Installing MySQL
sudo apt-get install mysql-server-5.1
vi /etc/mysql/my.cnf #change the default port


Installing glassfish
wget -b -c -i http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1.zip -o log.out
sudo apt-get install unzip
unzip glassfish-3.0.1.zip

Start glassfish
./glassfish/bin/asadmin start-domain domain1

Connect to the admin console and change the admin password
http://yourip.net:4848/
enterprise server > administrator password
logout and re-login

If you want a more secure and thorough set-up you can follow this guide. I usually just change the port in the admin console to 80.

Installing Apache
sudo apt-get install apache2

enable reverse proxy
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo /etc/init.d/apache2 restart

add reverse proxy context
sudo vi /etc/apache2/sites-enabled/000-default
ProxyPass /itsme/ http://www.mysite.net:8080/itsme/
ProxyPassReverse /itsme/ http://www.mysite.net:8080/itsme/

if you have a problem "client denied by server configuration proxy" you need to modify the proxy.conf to allow access to your site. So far the only solution i know is by adding allow all or commenting deny all in the proxy.conf file. To edit the conf file, use this command :
sudo vi /etc/apache2/mods-enabled/proxy.conf

if you wan't to pass the original ip through your proxy server follow this link.

Setting mercurial server
To set the mercurial server you can see my previous post.

Using subdomain for mercurial server
To do this you need to add a CNAME entry to your DNS Server. For example I ask my hosting support to add CNAME entry for hg.myserver.net.

After that, you just need to copy the virtual host from the 000-default files and add

ServerName hg.myserver.net

And you should be able to access your hg server using http://hg.myserver.net/hg

I've edited the location and path for this virtual server so i can access it using http://hg.myserver.net/repo. Better than the redundant hg for the url :)

Start glassfish at reboot time
Create a glassfish.sh file at your home directory, copy the code below as the content

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

GLASSFISH_HOME="/home/mreunion/glassfish/"

case "$1" in
start)
    $GLASSFISH_HOME/bin/asadmin start-domain
    ;;
stop)
    $GLASSFISH_HOME/bin/asadmin stop-domain
    ;;
restart)
    $GLASSFISH_HOME/bin/asadmin restart-domain
    ;;
force-reload)
    $GLASSFISH_HOME/bin/asadmin restart-domain
    ;;
*)
    echo "usage: $0 (start|stop|restart|help)"
esac

sudo cp glassfish.sh /etc/init.d/
sudo chmod +x glassfish.sh
sudo update-rc.d glassfish.sh defaults

No comments: