Minimal Ubuntu VPS: Setting up VNC
I’m writing this blogpost because I recently got myself a virtual private server (VPS) from the German provider Hetzner.de. I chose a small one (512 MB RAM, one CPU core, 40 GB space) for just 7.90 euros per month (including German tax that can be deducted if you’re a non-German citizen, which I am). I fired it up with Ubuntu 11.10 (the minimal version) and I wanted to get Apache, MySQL, PHP and phpMyAdmin running right away. So I started checking stuff out via Google and I learned a number of things. In this blogpost, I will boil these things down to a simple step-by-step guide. So here it is:
Part 1: How to setup your Ubuntu VPS with VNC
First of all, many VPS providers ship minimal versions of Linux (whether it be Debian, CentOS, Ubuntu or any other distro). So to be able to use VNC (remote desktop), you would want to setup the desktop interface. I’m running Ubuntu 11.10 here but the same commands might work for other systems. Log in via SSH and, once connected, run these commands. Setting up the desktop:
sudo apt-get install ubuntu-desktop
Setting up and configuring the Gnome Desktop Manager and XServer:
sudo apt-get install gdm
sudo /etc/init.d/gdm start
sudo dpkg-reconfigure xserver-xorg
Now, we would be having a fully working desktop interface on our Ubuntu server that started off being “minimal.” With this in place, we can install the VNC server that would let us connect to the server via remote desktop. I tried out different VNC servers for Ubuntu and I liked TightVNC the most. So that’s what I’m going to use:
sudo apt-get install tightvncserver
Installing TightVNC via the package manager doesn’t take long. The next step is to configure the first instance of the server. When you connect to TightVNC from your client desktop, you would normally connect via port 590x (where x is the number of the instance you want to connect to). Let’s setup the first instance:
vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565
You will be asked to set a password. This can be of 8 characters at the most. Set the password and you’re done. Now, there is one last thing that we would need to do and that is to make TightVNC use the Gnome Desktop Manager. This is not configured by default. So open up the TightVNC config file with either VIM or nano. I will use nano here:
sudo nano ~/.vnc/xstartup
We don’t want to use x-window-manager so comment out that line by adding a number sign (#) in front of the line. Add this line to the bottom of the file:
gnome-session &
Restart your VPS by this command:
sudo reboot
Wait a minute or so before connecting via SSH again. Once the VPS has restarted, connect to it via SSH and start your TightVNC server. TightVNC does not automatically start when you reboot your VPS:
vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565
That’s it! You’ve got VNC running on your Ubuntu server with desktop interface. Connect to it with your favorite VNC client (the Chicken of the VNC client is good for Mac and the TightVNC client is good for Windows). Use the IP or hostname given by your provider. The port to connect through would be 5901 and the password is the one you configured yourself. Done!
Part 2: Setting up LAMP on your Ubuntu VPS
We’ve configured VNC for our Ubuntu VPS but in this part I will work entirely through SSH. For operations like this I prefer SSH because it’s a lot faster. Check the following blogpost for this part of setting up your LAMP server.
Link: …