Linux Web Hosting

I get asked a lot which web host company to go with and if I have any recommendations for Linux hosting. I can only recommend what I have personally used over the years. As of today I am affiliated with these companies and got offered to be rewarded for spreading the word out.

First of all, since this is a Linux blog, I do have a dedicated Linux server on ServerPronto. I have used them for many years now and original reason I went with them was the price. I have found them to be the cheapest for a starter server and signed up to play with my new lower-end dedicated Linux box. They do offer cheap VPS hosting as well, but I just wanted my own. There are plenty of bad reviews about support, however, I have never had issues. I had my box rebooted a number of times over the years and had a network card replaced once without any issues. I, personally, have nothing to complain about. Cheap and works for me.

As for this site, it is a pretty small wordpress blog. There is no need to have it on a dedicated box and I host it on cheap shared host Bluehost along with a dozen other small and mid-size sites. They were the first host I signed up with 6-7 years ago and I now have a few accounts with them. I did have an issue with having a site that grew in traffic once and they asked me to move it, which is when I had to get a dedicated server as my site got way too much traffic, enough to get to top 15,000 in alexa and stay there for quite a bit. :) Other than that, had no issues with their customer service. They even helped me troubleshoot php code on one of the sites back when I was a script newbie and had an issue.

I did a lot of php contract work and quite a few clients used HostGator. They are a cheaper option if you only plan to host one site. Their customer service is great as well and they seem to be one of the most popular services around, at least from my experience.

The last server I have purchased is at GoDaddy. It is pretty cheap as well since I am only hosting one site on that account. I have bought the website and was too lazy to transfer to another host, so I transferred complete sellers account to mine. I am not a big fan of the user interface, however, I believe they now offer other commonly used user interface options. They do have dedicated servers, as linked above, which I also looked into. If you do decide to go with them, I do recommend to chat with sales first. Back when I was looking into it, they dropped the price quite a bit, its just that ServerPronto had a special that was priced lower. I do use GoDaddy as a domain registrar and quite happy with their service.

Anyways, these are the reviews of the hosting companies I have had a pleasure dealing with in the past few years.

P.S. I have purchased Web Hosting Deals site several years ago, just couldn’t get to it yet. Still in it’s original form. I am planning to redo the whole site at some point, sign up with more hosting companies and do complete feature reviews. It is, by the way, hosted on the same Bluehost account as this site. :)

Please feel free to comment and let us know which Linux hosts you use and why.

How to fix flashing screen after nvidia driver update in Ubuntu

Just tried updating to the latest nvidia drivers and the screen was flashing after reboot. I have tried reinstalling drivers from other repositories but nothing worked. Had to use nouveau to get back to boot and still looking for a solution to get my desktop back to previous state. Anyhow, here is how to switch to nouveau:

At the flashing screen press “Ctrl + Alt + F1″ to get to terminal at Ubuntu log in screen.

Log in using your credentials.

Stop X11 by entering this command:

sudo stop lightdm

Remove all nvidia packages by entering this command:

sudo apt-get purge nvidia-*

Install nouveau package by entering this command:

sudo apt-get install xserver-xorg-video-nouveau

Restart:

sudo reboot

or

sudo shutdown -r now

Hope it helps!

How to find files within daterange in Ubuntu

I got a virus that hit all php files on one of my servers and had to find all the files that got affected withing the date of the attack. There are a few methods that you can use:

1) To find the files modified within the last day, type:

find /directory_path -mtime -1 -print

where -1 is 24 hours, -2 – 48, and so on.

2) To find the files within modified date range is trickier. You have to create 2 files with start and end dates like listed below, just replace 20111110 and 20111120 with needed dates.

touch -t 201111101059 /tmp/file1
touch -t 201111201200 /tmp/file2
find . -newer /tmp/file1 -a ! -newer /tmp/file2

That’s it.

How to install gitweb in Ubuntu

After being told that I live in the stone age for using svn, I decided to try out git. Finally I got some time to continue learning git and setting the new environment. As a step one, we learned how to install git on Ubuntu. Then, I decided that I wanted to host my own repositories and we learned how to set up gitosis on Ubuntu. Now, after updating to Ubuntu 11.10 – Oneiric Ocelot, I am ready to continue setting up everything I need to start conveniently using git. So, in this post, I will be setting up the gitweb and documenting the process.

Gitweb is a convenient GUI that allows us to quickly see the project and diffs right in the browser. Before we move on to installing git web, make sure you have installed apache. Now, lets move on to installing gitweb:

sudo apt-get install gitweb

Now lets look in our /var/www folder:

cd /var/www

ls

I didn’t have gitweb folder here, so I created it:

sudo mkdir /var/www/gitweb

gitweb files should be in /usr/share/gitweb and we need them in our /var/www/gitweb, so lets create a symbolic link that will point to the files:

cd /var/www/gitweb

sudo ln -s /usr/share/gitweb/* .

To check if these are symbolic links, you can type:

ls -l

it should show what these files are linked to.

Next, locate the path to your git repositories. As per our install, we have it in /home/git/repositories. So, lets edit gitweb config to point to the right directory:

sudo gedit /etc/gitweb.conf

and replace:

$projectroot = "/var/cache/git";

to our path to git repositories, /home/git/repositories in my case to:

$projectroot = "/home/git/repositories";

Save the file and lets move on to next step – editing apache configuration. Open apache config for gitweb:

sudo gedit /etc/apache2/conf.d/gitweb

And edit it as follows (replace the paths if yours are different):

    RewriteEngine on
    RewriteRule ^/gitweb/([a-zA-Z0-9_\-]+\.git)/?(\?.*)?$ /cgi-bin/gitweb.cgi/$1 [L,PT]

    Alias /gitweb /home/git/repositories

    Options Indexes FollowSymlinks ExecCGI
    DirectoryIndex /cgi-bin/gitweb.cgi
    AllowOverride None

and save. Now its time to restart apache to apply the changes:

sudo /etc/init.d/apache2 restart

I got an error at first saying:

Syntax error on line 1 of /etc/apache2/conf.d/gitweb:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!

Which was because I needed to add rewrite package to apache:

sudo a2enmod rewrite

This time apache started with no errors.

Now you should be able to go to http://localhost/gitweb and see the gitweb page. If you have no public repositories yet, you may see “404 – No projects found” notice. To test it out, I went to my repo folder:

cd /home/git/repositories/

and changed the permissions on my gitosis-admin.git:

sudo chmod -R 755 gitosis-admin.git

Refresh the localhost/gitweb and ta-da! It shows a repository where I could click around and check things out. Since I didn’t want this repo to show publicly, I had to change the permissions back to:

sudo chmod -R 750 gitosis-admin.git

This is it for now. In the next git series posts I will try to go over creating new repositories, adding users, general git usage, installing redmine for project management and anything else I may find useful.

How to restore Unity when it disappears in Ubuntu 11.10

Well, after playing around the compizConfig Setting Manager I somehow screwed up the whole system. Unity along with any kind of menu was gone. Terminal Windows did not come up when pressing ALT+F# and even ctrl+alt+delete were not working. The only way terminal was able to come up was by pressing Ctrl+Alt+T . I did

unity --reset

but it did not work. What worked for me was typing:

ccsm

and enabling it again, disabling everything else that was conflicting. Hope this helps in case you are looking for the solution. :)

How to configure Unity in Ubuntu 11.10

I have been poking around the new Unity settings in Oneiric Ocelot.

First, check if you have compizconfig settings manager. If not, install by typing the following command in the terminal window:


sudo apt-get install compizconfig-settings-manager

Then go to unity dash and start typing compiz – it should show you the settings manager. Click it and go to “Desktop” options. I guess unity is a part of compiz now and this is where you can find “Ubuntu Unity Plugin” settings to edit the appearance.

I am kind of upset to see that there is no option to move the dock around. :(

Ubuntu Oneiric Ocelot – 11.10 review

Ububtu Oneiric Ocelot - 11.10

Ububtu Oneiric Ocelot - 11.10

As you all may know, the new version of Ubuntu was released on October 13, 2011, which is just over a week ago as of the time of writing this post. I wanted to upgrade right away, but decided to wait a bit for the user response as upgrades don’t always go smooth. Well, this one worked like a charm for me.

It took a little over an hour to perform the full upgrade. I made a backup just in case, which I also recommend doing. So far just a few programs need to be reinstalled. A ton of packages got deleted, but it’s mostly because they have a newer and improved versions.

As for the changes, the first thing I noticed was the desktop. It does look a lot better due to improved unity shell. I remember how much I hated it with the last upgrade when it just got added to Ubuntu and I am still not a big fan of it. It is, however, a lot more convenient and clean. I went from “definitely removing” to “may be I’ll poke around and keep it for a while”. I also don’t like the dock sitting on the right side, but I still have to look if I can relocate and change the size of it. The dash interface became a lot more usable too.

There are a few other small, but noticeable improvements, such as a new gnome login screen, login manager now uses LightDM.  Overall performance got slightly improved. Default mail client is now mozilla Thunderbird. Ubuntu now has a better support of 32 bit apps on 64 bit systems. It has a new backup client, which I still have to look into as it looks like they give you 5gb of online storage for free. Improved software center looks a lot better. These are just a few changes that I was pleased with.

There are other changes, but I think these are the biggest ones, at least for me. I like where it is going and will be waiting patiently for the next release. I want to see more improvements to unity as it looks like they put more focus on it now and it is here to stick.

How to install gitosis on Ubuntu

In the previous post we went over installing git on Ubuntu, we are now installing a package called gitosis so we can host git repositories.
First, make sure you have python-setuptools package installed since gitosis needs python. Open the terminal window and type:

sudo apt-get install python-setuptools

Now we need to get gitosis, type these commands one after another to create src folder in your user directory, clone the source and install it:


cd ~/
sudo mkdir src
cd src/
sudo git clone git://eagain.net/gitosis.git
cd gitosis/
sudo python setup.py install

Next, lets create a user that will own the repositories.


sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git

Now we need a public ssh key, we’ll create a local one, it will ask you for a passphrase, enter the one you like:


ssh-keygen -t rsa

Now we need to let the git user use this key:


cp ~/.ssh/id_rsa.pub /tmp/
sudo -H -u git gitosis-init < /tmp/id_rsa.pub

Now lets change the permission on on post-update hook:


sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

Now lets clone gitosis-admin repository (you can get the hostname by typing hostname command in the terminal), navigate to the folder you want the repository to reside in and type:


sudo git clone git@YOUR_SERVER_NAME:gitosis-admin.git

That’s it, you got a local gitosis-admin repo with a config file and a keydir directory.

I will post how to use git and will try to install gitweb (convenient web interface) next.

Edit: I wrote another post on how to install gitweb in Ubuntu if you wish to move on to the next step. :)

How to install git on Ubuntu

As I finished installing svn server, I was given and advice to use git instead. So I started to look into it and decided to give it a try. This post is a start of a process.

You need git first. So, lets start installing it. Open the terminal and type:


sudo apt-get install git-core

Thats’s it. Short and up to the point. You can now check the version to make sure it is installed:


git --version

At the time of writing I have 1.7.1.4 :)

In case you need a server, move on to the next point – installing gitosis on Ubuntu.

svn post-commit hook in Ubuntu

So, I’ve been messing around the scripts in Ubuntu. It’s fun… 2 am here and I finally got the post-commit hook to work the way I wanted it to. Had to learn quite a bit about bash scripts and php calling the bash scripts. :)

As I started in previous post – adding svn hooks in Ubuntu, this is a part 2 of that post. I am using SVNManager, and loading these hooks in the same /repo-templates folder I created in previous post.

To start, remove previous post-commit file from the folder if you created one as I made a new one. Then, lets create the files and make them executable:


sudo touch post-commit
sudo touch post-commit-email
sudo touch post-commit-send
sudo chmod +x post-commit post-commit-email post-commit-send

Lets start editing the post-commit file first:


sudo gedit post-commit

Here is what I got:

#!/bin/sh
 
REPOS="$1"
REV="$2"

$REPOS/hooks/post-commit-email $REPOS $REV

Next, I created post-commit-email file in php, change the path to php if needed (to get the path, type ‘which php’ in terminal). Also, make sure you get the right database connection and password:

sudo gedit post-commit-email

#!/usr/bin/php
<?php
$repos = $argv[1];
$rev = $argv[2];

$repos_name = basename($repos);

$con = mysql_connect("localhost","svnmanager","mypassword");

mysql_select_db("svnmanager", $con);

$result = mysql_query("SELECT DISTINCT usr.id, usr.email FROM repositories as rep
            LEFT JOIN groupprivileges as grppr ON grppr.repositoryid = rep.id
            LEFT JOIN groups as grp ON grp.id = grppr.groupid
            LEFT JOIN usersgroups as usrgrp ON usrgrp.groupid = grp.id
            LEFT JOIN users as usr ON usr.id = usrgrp.userid
            WHERE rep.name = '".$repos_name."' AND usr.email IS NOT NULL");

while($row = mysql_fetch_array($result)) {
  $email_addr = $row['email'];
  $email_id = $row['id'];
  $arr[$email_id] = $email_addr;
}

$result = mysql_query($q = "SELECT DISTINCT usr.id, usr.email FROM repositories as rep
            LEFT JOIN userprivileges as usrpr ON usrpr.repositoryid = rep.id
            LEFT JOIN users as usr ON usr.id = usrpr.userid
            WHERE rep.name = '".$repos_name."' AND usr.email IS NOT NULL");

while($row = mysql_fetch_array($result)) {
  $email_addr = $row['email'];
  $email_id = $row['id'];
  $arr[$email_id] = $email_addr;
}


$emails = "";
$flag = 0;
foreach ($arr as $key => $val) {
  if($flag) {
	$emails .= ',';
  }
  $emails .= $val;
  $flag = 1;
}

mysql_close($con);

exec($repos.'/hooks/post-commit-send '.$repos.' '.$rev.' '.$repos_name.' '.$emails.'');

?>

At last, post-commit-send file:


sudo gedit post-commit-send

#!/bin/sh

REPOS="$1"
REV="$2"
REPOSNAME="$3"
SENDTO="$4"
SENDFROM=root@localhost

LIMITDIFF=200
CHANGELOG=`svnlook log -r $REV $REPOS`
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGED=`svnlook changed -r $REV $REPOS`
DIFF=`svnlook diff -r $REV $REPOS | head --lines=$LIMITDIFF`
DATE=`date`
TMPFILE=/tmp/svn$REV-$RANDOM.message
	 
SUBJECT="New SVN Commit By $AUTHOR On $REPOSNAME, Revision #$REV"
echo "-------------------- SVN Commit Notification --------------------
Repository: $REPOSNAME
Revision:   $REV
Author:     $AUTHOR
Date:       $DATE
	 
-----------------------------------------------------------------
Log Message:
-----------------------------------------------------------------
$CHANGELOG
	 
-----------------------------------------------------------------
Changes:
-----------------------------------------------------------------
$CHANGED
 
-----------------------------------------------------------------
Diff: (only first $LIMITDIFF lines shown)
-----------------------------------------------------------------
$DIFF
" > $TMPFILE

#echo $SENDTO >> $REPOS/hooks/error_log 
	 
# Send email
cat $TMPFILE | mail -r "$SENDFROM" -s "$SUBJECT" "$SENDTO"
 
# Cleanup
rm $TMPFILE

Change the email if needed and make sure that the backtick character is correct as it may change when you copy from this page. I got the last file from this post and modified it a bit.

Let me know if this worked for you. :)