Configuring VirtualHost and Host alias on Ubuntu 10.04 Development Box

On my ubuntu 10.04 box, I have apache2 webserver running. Since I get involved in different project over the time, it felt rather awful to access each project via http://localhost/projectname. I configured virtualhost and hosts file on my ubuntu machine to achieve host alias so that I could run the project via host alias like http://projectname/. I will describe how I achieved this.

First I edited httpd.conf located at /etc/apache2/ (Location of httpd.conf may vary. Please figure out the the path to httpd.conf for your system configuration)

I added following lines to httpd.conf file.

<VirtualHost *:80>
ServerName projectname.local
DocumentRoot /path/to/your/project/root
<Directory /path/to/your/project/root >
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

Next I edited /etc/hosts file and added the following line to it.

127.0.1.1       projectname.local projectname

Now I restarted the apache server by executing

sudo /etc/init.d/apache2 restart

And now, I could navigate to http://projectname.local/ or http://projectname/.

[Solved] Error executing pear commands “PHP Deprecated: Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0″

I have php5, php5-cli, and php-pear installed on my system. I was trying to install pear package phing from the pear installer. Whenever I tried to run pear commands like

pear channel-discover

I got an error message stating

PHP Deprecated:  Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0

Well, The solution I tried that worked was I edited the mcrypt.ini file located at /etc/php5/cli/conf.d/mcrypt.ini

It contained

# configuration for php MCrypt module
extension=mcrypt.so

I replaced the comment initializer “#” with “;” as in

; configuration for php MCrypt module
extension=mcrypt.so

And it worked just fine!

[Solved] Error Installing Plugins to Eclipse on Ubuntu 10.04

An error occurred while installing the items   session context was:(profile=PlatformProfile, phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Install, operand=null –> [R]org.eclipse.cvs 1.0.400.v201002111343, action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallBundleAction).   The artifact file for osgi.bundle,org.eclipse.cvs,1.0.400.v201002111343 was not found.

I got this error while trying to install PDT after I installed Eclipse platform from the repository in Ubuntu Lucid Lynx. The solution is to install eclipse-pde. In the terminal, type

sudo apt-get install eclipse-pde

You should have no problem in installing the plugins after this.

[How To] Upgrade WordPress automatically on 1and1 Hosting

I host my wordpress blog on my 1and1 hosting account. With new releases of wordpress, the automatic core update didn’t work as expected. It would freeze on the way. The workaround:

WordPress Upgrade script needs php5 for functioning. By default, .php extension is parsed with php4 engine in 1and1 webhosting. Add this line to your .htaccess file located at your wordpress directory.

AddType x-mapp-php5 .php

And that would work quite fine.

[Solved] Error enabling clean-urls in drupal

Well, I was working in a drupal project. I have a hosting account and number of add-on domains. My current project is hosted on one of the add-ons domains. But I have this problem implementing clean urls, which are supposed to look tidy. I checked the .htaccess file, and everything seemed alright. RewriteEngine as on.

Later I found out that since drupal was hosted on a add-on domain, I needed to uncomment

# RewriteBase /

And voila, it worked :)

[Solved] Access denied while browsing through squid

Well, I have a netbook and a desktop. I have Ubuntu 9.04 installed in my desktop box, and Windows XP in the netbook. So I decided to share internet to my netbook through cross cable. But the default installation of squid won’t let me do it. With correct proxy settings in my netbook too, I couldn’t get to browse the internet. Access denied notice as:

Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect

was presented. So the solution:

What I found out was, default squid config will deny all http connections. So in squid.conf file, find the line something like:

# And finally deny all other access to this proxy
http_access deny all

edit this line and make it as

http_access allow all

That will solve your problem for a home network. You may need to restart squid to see the changes.

[SOLVED] High Unviewed Traffic in Drupal site

It had been bugging me for days. Unviewed traffic for my site was pretty high, more than 5 times the viewed traffic. When I checked AWstats in my cpanel, I found that Googlebot had been eating up 4 times more bandwidth than my normal visitors. So how did I solve?
Well, it took me days to figure out what was wrong. Finally, I checked Latest Visitors in my cpanel. I found out Googlebot was looping through Calendar pages. I had installed a calendar module. And each day of  month of years was linked to. So that created floods of traffic from Googlebot to my website. So what did I do?

I added this to my robots.txt file

User-agent: *
Disallow: /calendar/

And that solved my problem :)

SMSoft – Store Management Software

As a C++ Project to be done as a partial fulfillment to C++ syllabus in my campus, I developed a Store Management Software named SMSoft. It is created with Qt – a cross-platform C++ FrameWork. Here is a screenshot of the software under Windows.

SMSoft ScreenShot

SMSoft ScreenShot

Here is the source code for it. It is made with Qt Creator 4.5.2 IDE built with support for MySQL. MySql dump is also available in the zipped file. Here is the download link
http://www.nitesh.com.np/wp-content/uploads/2009/08/SMSoft.zip

Verify Googlebot with PHP

Webmasters maynot be pleased if the content they want to be available to googlebot only is available to any users when they switch their user-agent to Googlebot. But webmaster can easily trackdown this diguised visits.

Here is a simple function in php to verify if the visit claiming to be from Googlebot is a true Googlebot visit.

  1. <?php
  2. function googleBot()
  3. {
  4.  
  5. if(preg_match("/Googlebot/",$_SERVER[‘HTTP_USER_AGENT’]))
  6. {
  7. //robot ip address is assigned to $ipaddress
  8. $ipaddress = $_SERVER[‘REMOTE_ADDR’];
  9.  
  10. //hostname is assigned to $hostname
  11. $hostname = gethostbyaddr($ipaddress);
  12.  
  13. if(preg_match("/googlebot.com/",$hostname))
  14. {
  15. // returns true if googlebot.com is found in hostname
  16. return true;
  17. }
  18. }
  19. return false;
  20. }

This function returns boolean true or false and can be used anywhere in your program to show wanted behavior.

The article is based on Verifying Googlebot

Hello!

Well, few years back, I had my wordpress blog hosted at wordpress.com. I used to write personal stuffs in there. But now, here I have my self-hosted blog. I plan to write technology related stuffs in here. For personal stuffs, I do have my separate private blog :) that serves as my personal diary.