VNC on openvz

PaulBones

InterServer Staff
Staff member
This howto is based on:
http://www.howtoforge.com/how-to-install-vnc-server-on-ubuntu-14.04

The difference is – I am using lxde(which is better resources wise) instead of xfce4.
I have successfully setup a vnc on openvz VPS by doing the following:

NB! This WILL work but this will be SLOW.
Adding extra slices will improve the performance.

NB! Must use it on a fresh install of Ubuntu server 14.04
if you have previous attempts of installing vncserver already – reinstall your VPS
with Ubuntu 14.04 minimal 64 bit - you can reinstall OS at any time from your account.

Important!
(Do not skip this step, without vsvap enabled on your VPS you will experience firefox crashes etc.)
Login to your account. On the top menu choose "Support" and click on
"Open A Support Ticket". Fill in the support ticket form:
"Link Product To Ticket" - choose your VPS from the menu.
"Describe Your Problem" - Type here: Please enable vsvap.
Submit the ticket.

Login to your VPS as root.
User: root
Password: the one that you chose for your VPS.
Windows - use putty: http://www.putty.org/
Linux - ctrl+alt+t to bring up the console and type: ssh ip_address_of_your_VPS -l root

Should see something like:
root@servername:~#

# Now lets begin:

apt-get update
# might ask if you want to install without verification: type Y and hit enter.

apt-get install nano
# install small editor called “nano”
# might ask if you want to install without verification: type Y and hit enter.
# when editing files with it use Ctrl+O to save, Ctrl+X to exit.

apt-get install lxde-core firefox vnc4server
# might ask if you want to install without verification: type Y and hit enter.
# might ask Country of origin for the keyboard: type 29 and hit enter
# next question about keyboard layout: type 1 for US English and hit enter.

apt-get install flashplugin-installer
# only if you need flash. it will work but veeery slow.

adduser vncuser
# it will ask for password, provide the password of your choice, you will be connecting to the vnc server on your VPS with username:vncuser and that password. You can skip the rest by hitting enter.

sudo usermod -a -G sudo vncuser
#grant privileges

su - vncuser

vncserver
# enter your password you chose earlier.

sudo -i
#enter your password

nano ~/.vnc/xstartup
# lets edit with nano editor
# delete everything and paste the following:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startlxde &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &


# don't forget to use Ctrl+O – save. Ctrl+X – exit from nano.

vncserver -kill :1

su
#use your VPS root password

nano /etc/init.d/vncserver
# Copy and paste the following:

#!/bin/bash
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "\n"
echo "VNCServer Stopped"
}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac


# again, use Ctrl+O to save and Ctrl+X to exit nano editor.

cd

chmod +x /etc/init.d/vncserver

mkdir -p /etc/vncserver

nano /etc/vncserver/vncservers.conf

# copy and paste the following:

VNCSERVERS="1:vncuser"
VNCSERVERARGS[1]="-geometry 1920x1080"


# Ctrl+O to save and Ctrl+X to exit nano.
# you can change 1920x1080 to your desired resolution.

update-rc.d vncserver defaults 99
# now vncserver will startup automatically with every reboot

reboot

Now connect to your VPS using VNC client software
The port on your VPS is 5901

For Windows you can use tightvnc client:
http://www.tightvnc.com/download.php

Example:
Server address: 192.168.0.2:5901
(Do not forget to add that port number 5901)
Username: vncuser
Password: password you have setup for vncuser (not the root password for your VPS)
 
Last edited:

prey

New Member
Thanks! I've been looking for this for a while, but I've never came across the site you quoted, unfortunately. Thanks for the share!
 

pawlo.litasi

New Member
# it will ask for password, provide the password of your choice, you will be connecting to the vnc server on your VPS with username:vncuser and that password. You can skip the rest by hitting enter. snaptube word to pdf vidmate
 
Last edited:
Top