Saturday, April 30, 2011

setup Ubuntu with VNC for remote desktop

To run a VNC server on your VPS, you need to have the desktop version of Ubuntu installed. The server version, which you are probably running, is missing some required features.

On your VPS, run the following command to install the desktop version:


Code:
sudo apt-get install ubuntu-desktop
While you are waiting for this to install, download the latest version of tightVNC for your OS (it's free), or another VNC client.

After the desktop install is complete you want to make sure GNOME is installed and configured:

Code:
sudo apt-get install gdm
Code:
sudo /etc/init.d/gdm start
Code:
sudo dpkg-reconfigure xserver-xorg
In order to remotely control the server, you need to install a VNC server. We are going to be using TightVNC, instaling VNC on your server and your computer.

This step will install tightVNC on the server :

Code:
sudo apt-get install tightvncserver
You can now start the VNC. Note: make sure you set a password and remember it when prompted. The password will have 7 character limit:
Code:
vncserver :1 -geometry 1024×768 -depth 16 -pixelformat rgb565
If you forgot your password:
Code:
vncpasswd
Go a head and turn off the the VNC:
Code:
vncserver -kill :1
We want to configure it so the desktop environment uses GNOME. Open the startup file:
Code:
sudo nano ~/.vnc/xstartup
And add this line at the bottom:
Code:
gnome-session &
Restart your server:
Code:
sudo reboot
Start the VNC again:
Code:
vncserver :1 -geometry 1024×768 -depth 16 -pixelformat rgb565
All of our VNC requests will come from port 590x. The last number is reserved for the desktop number that you assign. We are using 1 (:1) so we only need to open up 5901. If we wanted to start another sever (:2) then we would need to open up port 5902.

On your PC open up TightVNC Viewer. Set the Host to the IP of your server. Set the Display to 1 (:1).

Enter the password that you set when you started the server and connect. You should be remotely viewing your VPS's Ubuntu desktop!

backup software

Raqbackup is EXCELLENT! it will zip everything up and ftp it to the server of your choice on schedule. It also emails you with status reports. Very good script!

It is not free, but I have also had good results with EMC/Dantz retrospect. They used to make a raq client but probably dont anymore. I would assume that any most linux clients would work as it is quite a simple program.

Install and Configure a GUI on your Linux VPS

This seems to be a topic that appears often on the VPS forum, so I thought I would get around to posting a simple instruction set for getting a GUI (GNOME or KDE) working on your VPS.

These instructions are aimed towards the Fedora distribution, but should work fine with CentOS or any other Linux distro (except maybe RHEL, which has some extra steps):


Firstly, make sure that you have YUM installed, if not, you have to go find the RPM for YUM via google or rpmfind.net, and do an "rpm -Uvh <file.rpm>" once you get it. YUM works off python, so it's not a binary just a bunch of scripts (so arch. doesnt matter).


Now that YUM and its required libraries are installed (python, sqlite, etc) execute as root on your VPS command line:


"yum -y groupinstall kde" for KDE or "yum -y groupinstall gnome" for GNOME.


and then:


"yum -y install vnc vnc-server firefox x11-xorg" to install the remaining neccessary applications (VNC, FireFox, X11 libraries, etc).


If your on OpenVZ you might have to: "yum -y remove dummy-selinux-vz" or "yum -y remove vzdummyfc4" first. Oh, also make sure that you have "gpgcheck" disabled in /etc/yum.repos.d/fedora.repo, otherwise the KDE installation will fail. KDE is by far the easiest to install, but if you want GNOME you'll have to do some other advanced tricks after the "yum -y groupinstall gnome" step.


Start up VNC server like so: vncserver


This will ask you for a password, and then create your ~/.vnc directory (if running as root, it will be in /.vnc or /root/.vnc or /home/root/.vnc). It is advisable to start up VNC/your GUI as a non-root user, but hey it's your VPS
.
Running 'vncserver' will also start up VNC Server and create some temp sockets.

Now, you'll see VNC server is running by executing: "ps -ef |grep vncserver" -- good. Now kill the VNC process like so: "pkill -9 vnc" and then delete the temp sockets by: "rm -rf /tmp/.X1*" -- be careful when running rm -rf as root, you could have a typo and do rm -rf / by accident and destroy your VPS!


At this point you have to go into the /.vnc directory, edit the xstartup file and delete the last line (usually has twm & or something), and replace it with: "startkde &" (without the quotes) -- this tells VNC to startup KDE instead of the default window manager, twm (or whatever the last line was).


Your pretty much done at this point, go ahead and execute the command 'vncserver' again, and VNC will startup, using the password specified earlier and create a default VNC instance on VNC port 1.


Give it a few minutes, depending on your VPS specs, to let KDE start up for the first time. Start up your RealVNC client on your PC, and put in <youripaddress>:1, and it should ask for your password that you put in earlier. If you dont see the KDE desktop, check your xstartup file again in /.vnc and make sure the last line is 'startkde &'.


You can automate the entire process just by stringing along all of the commands in a simple script. This should get you up and running with a nice GUI for your Linux VPS. Keep in mind you need at least 256 MB of guaranteed RAM, do not rely on your "burstable" rate because having a GUI running WILL cause processes/services inside your VPS to be killed because of a lack of memory. If your running a control panel such as cPanel or Plesk on the same VPS, make sure you have at least 512 MB of guaranteed RAM.


If anyone wants to add to the instruction set or has some extra tips or tricks for getting a GUI working properly on a VPS, please share!


-Sean

How to Restore/Extract Full VPS backup

I've seen many people asking that how they can restore full VPS backup. Because some times due to any prob we got kicked out of our host and we are left nothing (except our backup)

Ask your host to give your full VPS backup in .tar format.


If its big like 50+ GB then it will be hard for you to upload and download, you must ask them to put it on their servers so that you can wget it easily.


Now that you've backup located remote location like ->
http://domain.com/backup.tar

Get a fresh new box and install cpanel on it.


now go to ssh.


and put following command -> wget
http://domain.com/backup.tar

After transferring full backup, you need to extract it.


Now put following command to extarct your backup -> If its in tar format, then first re-install OS at your new box.

reinstall cPanel.

Now go to SSH, and wget your backup (wget
http://backup.domain.com/backup.tar)

after getting it on new machine you need to extract files from it.


Use this command to extract files -> tar tvf file.tar (In place of file put the name of backup)


Now wait for it to get restored.


hope it helps.

experience looking for a cloud provider

Due to a series of projects I'm working, I have been watching the operation with multiple vendors, support and quality of service offered by each of them, which I take for my opinions indicaros dureante try after some time the cloud that they offered me.

DINAHOSTING


For: She offered me a good service, machines updated, have good reputation.

Cons: proprietary control panel, although hourly billing, accounts by the end of the year goes by a peak
My experience with the test: if you are a VPS, but the software is castrated, does not let you do what you please, the machine is quick, but I do not compensate the price with the service but this is good.


INTERDOMINIOS


For: Since Cirt changed positions, seems to work better.

Against: The call is not there, the people you serve is not placed on the subject, and whenever they do a question a little unusual, then leave you on hold and after 10 minutes you answer.
My experience with the test: I left a VPS for a day to perform all the tests I wanted, as caracterisitca 1.6 processor, 1024MB RAM and 50GB of disk, the machine does not go, but if I diĆ­o enough problems in the network because seperdian 5 or 6 packs in 30 approx. I think they are a bit green on the topic, and it was clear that using a similar caractrisiticas others, the machine was very Flounder.



VPS.NET


Pros: everything is amazing how it works, they have good prices and the machine that you get is tremendous.

Against: I think the only point that I can put it down to this supplier is not complying with the Data Protection Act.
My experience with the tests: The day I had to try thanks to a good friend was brutal, to give you the same you think the machine or virtual machines as you like characteristics dividing contracted, we provide a pile after pile of imagesnes to perform installation of our systems. I find using the system OnApp for cloud, and the truth is a joy. sorry for not complying with the Data Protection Act.



1AND1


Pros: Has very good prices

Against: A service lousy, the person who serves, seems more a person to screen calls than anything else.
My experience with the tests: I really think it's better not to speak, only I've tried for half a day, the machine gave me some problems, and almost the end, a person who served me told me that is that the Cloud VPS system was in evidence and clear, it is normal to have bugs.


SOLOGIGABIT


Pros: I can only say that it is the same as VPS.net, yes, yes, I at first I believed it but it is so well used as VPS.net OnApp, in fact when they give you access to configure your machine OnApp there is pure and simple, is great and also in Spain. The best part is that being in Spain, so that they comply with the Data Protection Act

Against: The truth, say that I have not found any hits, what surprised me most is that you can golde a VPS from 1 € per day.
My experience with the tests, say that was a pleasant surprise to me that over the previous suppliers, offering a unique fueel Internet pipe 1GB and not 100MB as I have given in previous suppliers, which surprised me and I really liked. They have very good prices, and above all, I was stunned to be a provider with prices similar to VPS.NET and Spain. My advice is to give him a look, my truth is that I was not disappointed.



I have also tried many other suppliers as gravitynet or Hostalia, which are already starting, did not fulfill my espactativas to not be a cloud as they offered me, besides the price was considerably more expensive.


With that finally I can say that I hired a Cloud VPS Sologigabit where by 295 € a year I have:


Dedicated Xeon 1.8 GHz CPU

Dedicated Core 3
Virtual Machine up to 3
Dedicated 750 MB RAM
30 GB SAN Storage Dedicated
750 GB Bandwidth
Full-duplex 1Gbps
3 IP Addresses
AutoBackups / Templates 4

CloudLinux Hosting vs. Cloud Hosting

CloudLinux is simply a variant of Linux. Aside from the name, it has very little to do with true cloud.

True Cloud has High Availability (one or more servers can fall out of service and the overall cloud does not crash) with failover and is rapidly scalable.

CloudLinux is just an 'improved' version of CentOS for hosting companies, also it isn't free.

CloudHosting is normally just hosting that's configured to be highly available.

Bootstraping WordPress/Nginx/PHP/MySQL on a Cheap VPS with lowendscript

One constantly posted question on LowEndBox and LowEndTalk is — how to get the same setup as LowEndBox, a WordPress site that runs on cheap VPS with 80MB of memory? Instead of doing a step-by-step explanation (damn I hate writing long blog posts), I decided to wrap it into a bash script that does it all.
Nginx PHP
WordPress MySQL
It is based on my previous script here, and it has been tested on both Debian 5 “Lenny” and Ubuntu 10.04 “Lucid Lynx”. Sorry no other distributions are supported. It is currently hosted at github so feel free to branch it and tune it to your heart’s desire.

Usage

Here is a quick step by step on how to set up a WordPress blog running on Nginx, PHP/FastCGI and MySQL on a low end box. Let’s assume that you are going to set up a blog on hostname “blog.example.com“.
  1. Go and buy a cheap VPS. Yes, you know where to find cheap virtual servers under $7/month, don’t you? :) I am using my 6 pound/year RackVM VPS with 128MB memory to test this script, and the performance turns out to be quite good. YMMV.
    Make sure it is either a Debian or a Ubuntu distro though.
  2. After gaining root access to your VPS,
    # wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh
    ...
    # bash setup-debian.sh system
    ...
    # bash setup-debian.sh exim4
    ...
    # bash setup-debian.sh nginx
    ...
    # bash setup-debian.sh mysql
    ...
    # bash setup-debian.sh php
    ...
    # bash setup-debian.sh wordpress blog.example.com
    ...
  3. Now altering your DNS entry to point blog.example.com to your new VPS (or alter your local /etc/hosts entry). Navigate to it from your browser, and you should be presented with WordPress set up page. Fill in your blog’s name, admin’s password and contact email, and your new WordPress is online!
    Just repeat the last step (running bash setup-debian.sh wordpress <hostname>) to set up more blogs on the same box.
That’s it!

Software Stack

It’s pretty similar to my own stack that runs LowEndBox.com.
  • dropbear to replace openssh. Invoked from xinetd.
  • inetutils-syslogd to replace rsyslog.
  • exim4 to replace sendmail (if installed). Re-configured to allow Internet delivery.
  • cron
  • nginx
  • mysql. Re-configured to remove innodb support, remove query cache and reduce key buffer size.
  • php with built-in FastCGI interface. Running only 1 child process and respawn after 5,000 requests.
The lowendscript is also
  • Removing some commonly bundled applications that should not be there in the first place for a minimal distro (apache2, sendmail, bind9, samba, nscd, etc).
  • MySQL root is given a new password (which can be found in ~root/.my.cnf)
  • Installing each WordPress site under /var/www/<hostname>. It will create appropriate database, users and password for the site.
I have to say that it is still “work in progress”, but if you want to figure out the internals please check the source code of that bash script.

Memory Usage

I am testing the same script on the following 3 systems:
  • Ubuntu 10.04 64bit (RackVM)
  • Debian 5 64bit (RackVM)
  • Debian 5 32bit (VPSGuy)
They are all showing different memory usage. I am taking the snapshot of memory usage AFTER 10 page loads on the WordPress blog that has been created to ensure PHP process is fully loaded.

Ubuntu 10.04 64bit

root@ubuntu64:~# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.5  23300  1536 ?        Ss   06:58   0:00 init
root     10124  0.0  0.5  23576  1496 ?        Ss   07:34   0:00 dropbear -i
root     15742  0.0  0.7  17880  1944 pts/0    Ss   07:35   0:00 -bash
root     15754  0.0  0.4  14960  1084 pts/0    R+   07:35   0:00 ps aux
root     24290  0.0  0.3  12508   788 ?        S    07:22   0:00 /usr/sbin/syslo
root     24524  0.0  0.3  21064  1004 ?        Ss   07:22   0:00 cron
root     25689  0.0  0.3  19512   972 ?        Ss   07:22   0:00 /usr/sbin/xinet
mysql    26346  0.0  4.2  61812 11248 ?        Ssl  07:23   0:00 /usr/sbin/mysql
www-data 27920  0.0  2.6  87768  7048 ?        Ss   07:23   0:00 /usr/bin/php-cg
www-data 27922  0.5 15.0 122460 39432 ?        S    07:23   0:04 /usr/bin/php-cg
103      30162  0.0  0.3  44356  1000 ?        Ss   07:24   0:00 /usr/sbin/exim4
root     30267  0.0  0.3  28104   932 ?        Ss   07:24   0:00 nginx: master p
www-data 30268  0.0  0.8  28744  2196 ?        S    07:24   0:00 nginx: worker p

root@ubuntu64:~# free
             total       used       free     shared    buffers     cached
Mem:        262144     100500     161644          0          0          0
-/+ buffers/cache:     100500     161644
Swap:            0          0          0
Memory Usage: 98.1MB

Debian 5 64bit

debian64:~# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2  10304   740 ?        Ss   12:22   0:00 init [2]
106       1414  0.0  0.3  42708  1004 ?        Ss   12:26   0:00 /usr/sbin/exim4
www-data  1655  0.0  2.5  72028  6560 ?        Ss   12:26   0:00 /usr/bin/php-cg
www-data  1657  0.9 11.7  98500 30928 ?        S    12:26   0:03 /usr/bin/php-cg
www-data  3126  0.0  0.7  28380  1912 ?        S    12:29   0:00 nginx: worker p
root      7668  0.1  0.5  23340  1528 ?        Rs   12:31   0:00 dropbear -i
root      7831  0.0  0.6  17472  1716 pts/0    Ss   12:32   0:00 -bash
root      7836  0.0  0.3  14720   980 pts/0    R+   12:32   0:00 ps aux
root     20169  0.0  0.3  18540   936 ?        Ss   12:22   0:00 /usr/sbin/cron
root     24462  0.0  0.2  12236   732 ?        S    12:25   0:00 /usr/sbin/syslo
root     25637  0.0  0.3  19256   952 ?        Ss   12:25   0:00 /usr/sbin/xinet
root     25694  0.0  0.5  28380  1552 ?        Ss   12:25   0:00 nginx: master p
root     32427  0.0  0.2   3872   588 ?        S    12:26   0:00 /bin/sh /usr/bi
mysql    32466  0.0  3.0  50420  8124 ?        Sl   12:26   0:00 /usr/sbin/mysql
root     32468  0.0  0.2   3772   592 ?        S    12:26   0:00 logger -p daemo

debian64:~# free
             total       used       free     shared    buffers     cached
Mem:        262144      61008     201136          0          0          0
-/+ buffers/cache:      61008     201136
Swap:            0          0          0
Memory Usage: 59.6MB

Debian 5 32bit

debian32:~# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1   1980   688 ?        Ss   23:34   0:00 init [2]
root     14064  0.0  0.1   1704   512 ?        S    23:52   0:00 /bin/sh /usr/bi
mysql    14119  0.0  1.7  20056  6968 ?        Sl   23:52   0:00 /usr/sbin/mysql
root     14120  0.0  0.1   1628   536 ?        S    23:52   0:00 logger -p daemo
www-data 15968  0.0  1.2  16352  4996 ?        Ss   23:53   0:00 /usr/bin/php-cg
www-data 15971  0.5  4.7  29436 18576 ?        S    23:53   0:01 /usr/bin/php-cg
root     16040  0.0  0.3   2700  1464 ?        Rs   23:53   0:00 dropbear -i
root     16119  0.0  0.1   1880   684 ?        S    23:44   0:00 /usr/sbin/syslo
root     16133  0.0  0.3   2780  1536 pts/0    Ss   23:54   0:00 -bash
root     17728  0.0  0.2   2352   896 ?        Ss   23:45   0:00 /usr/sbin/xinet
www-data 17758  0.0  0.3   5004  1488 ?        S    23:54   0:00 nginx: worker p
root     27834  0.0  0.3   4548  1236 ?        Ss   23:47   0:00 nginx: master p
root     28146  0.0  0.2   2296   896 pts/0    R+   23:57   0:00 ps aux
102      32065  0.0  0.2   6104   900 ?        Ss   23:49   0:00 /usr/sbin/exim4

debian32:~# free
             total       used       free     shared    buffers     cached
Mem:        262144      44272     217872          0          0          0
-/+ buffers/cache:      44272     217872
Swap:            0          0          0
Memory Usage: 43.2MB
So to put that in summary form
  • Ubuntu 10.04 uses significantly more memory than Debian 5 (PHP5.3/MySQL5.1 vs. PHP5.2/MySQL5.0). So pick your distro wisely and maybe you don’t need the latest and greatest if your application does not need it.
  • 32bit also uses quite a bit less than 64bit, running exactly the same version of stack. That pretty much confirms what I posted before.
And hopefully the above script is useful for your next WordPress splog farm :P