Archive for August, 2010

How to install and configure Trac on Debian GNU/Linux to track your software development

Friday, August 20th, 2010

1. Install trac debian package

debian:~# apt-get install trac

2. Create trac project directories in /var/www/

debian:~# mkdir /var/www/trac
debian:~# mkdir /var/www/trac/project
...

If you have more than one repositories in Subversion then add as many /var/www/trac/project1, /var/www/trac/project2 as you like.
3. Initialize the base environment for a new track project and set proper permissions

debian:~# trac-admin /var/www/trac/project initenv
debian:~# find /var/www/trac/project -type f -exec chmod 660 {} ;

debian:~# find /var/www/trac/project -type d -exec chmod 2770 {} ;

When you type the trac-admin command you will have to fill in some very basic data concerning the new track project.

You will be prompted for things like project name , project sql type ,
repository type etc.
The most vital thing to enter here is the repository type and path to your repository.
Thanksfully by default trac uses svn so you just press enter when you’re prompted for repo type.

Afterwards you will have to fill in the path to your svn repository in my case it was
/var/svn-repos/project

4. Deploy the track cgi scripts with trac-admin

debian~:# trac-admin /var/www/trac/project /tmp/deploy
debian:~# mv /tmp/deploy/* /var/www/trac
debian:~# rm -rf /tmp/deploy

5. Install trac-spamfilter package to prevent spam on your Trac tickets

debian:~# apt-get install trac-spamfilter

6. Install support for MySQL as a default Trac data storage
If you’re about to go with MySQL in favour of the default sqlite, (though I personally choose not to use it) issue command:

debian:~# apt-get install python-mysqldb

Edit and add to your /etc/apache2/sites-available/default the following variables:
Alias /trac "/usr/share/trac/htdocs"
ScriptAlias /trac/project /usr/share/trac/cgi-bin/trac.cgi
<Location "/trac/project">
SetEnv TRAC_ENV "/var/www/trac/project"
</Location>

It’s a good idea also to add authentication to your trac to prevent any unwanted visitors to download your project source.

Again in your /etc/apache2/sites-enabled/default add something similar to:

<Location "/trac">
AuthType Basic
AuthName "Trac project"
AuthUserFile /etc/apache2/trac.htpasswd

Require valid-user
</Location>

7. Edit your /var/www/trac/project/conf/trac.ini

Some of the values I changed here and you might find it handy as well are:

By default attachment max_size was pretty low max_size = 262144 I decided to incrase it to max_size = 2621440

I’ve also changed src = site/logo.png to the exact path of my project logo. Changing this will make your project logo appear in the head of your new trac installment.

Something else I changed was the footer var which by default had a link pointing to trac’s webpage I changed it to point to my project website, so you might consider doing same too.
I believe this is all I did to have a running installation of trac.
Few things to mention is that this installation uses the slower trac.cgi instead of the way faster and recommended trac.fcgi, however lest my many attempts to make the trac.fcgi as explained in Trac Guide I did not succeeded in starting apache to serve trac via trac.fcgi script.

It’s really odd that the default steps explained in Trac On Debian as followed literally as described in the documnetation wouldn’t get you anywhere and you will end up with an installation that is not really working, for some strange reason the documentation misses the trac cgi deploy step as I explain in above.

We also need to create the /etc/apache2/trac.htpasswd .htaccess file. To do so issue:

debian:~# htpasswd -c /etc/apache2/trac.htpasswd passwd
password:

Place your password of choice
Be sure to also comment any existing declarations that say something like:

ScriptAlias
or
<Directory "/usr/lib/cgi-bin">

Any user feedback is very welcome, any suggestions or problems with the described install are about to be fixed asap as I have a user feedback.

How to configure .vimrc for PHP syntax highlighting – Download nicely configured .vimrc that can improve your daily vim text edit experience

Thursday, August 19th, 2010

The latest php.vim as of time of writting is from 2008 and is two years newer than the php.vim that comes with the latest vim package for Debian Testing/Unstable.

To install the newer version of php.vim on my Debian desktop I issued the following commands:

1. Download newest version of vim.php from vim.org noah:~# cd /usr/share/vim/vim72/
noah:/usr/share/vim/vim72 # mv /usr/share/vim/vim72/syntax/vim.php /usr/share/vim/vim72/syntax/vim.php.orig
noah:/usr/share/vim/vim72 # lynx http://www.vim.org/scripts/download_script.php?src_id=8651
# Now press D and Choose save to Disk in Lynx
noah:/usr/share/vim/vim72 # tar -zxvf php.tar.gz
-rw-r--r-- peter/peter 278277 2008-05-07 00:44 syntax/php.vim

This will have installed newest php.vim syntax highlighting rules. Now we will also need to copy a nicely configured .vimrc ready to be used for PHP highlighting, along with the PHP highlighting the .vimrc we are about to install is well configured for all kind of vim edits, so you will certainly benefit out if it if you’re a vim user just like me.

2. Download a properly nicely configured .vimrc for all kind of syntax highlighting including php editing and many other vim capabilities enabled

noah:~/usr/share/vim/vim72 # cd ~
noah:~# wget https://www.pc-freak.net/files/.vimrc

You might also want to set the same .vimrc for all other users except root, I’ll leave this up to you.

Speeding up your Apache hosted website through mod_deflate on Debian / How to compress css and (js) javascript

Tuesday, August 17th, 2010

People who run websites which aim at top responce times, are quite familiar with mod gzip and mod deflate .
Both Apache modules mod deflate and mod gzip are used for the very same purpose. They add a standard gzip compression to the files that Apache transfer to your Webserver clients.

Its said mod_gzip is the more powerful and more configurable module, however most people nowadays stick to the more straigh forward and easier to set up mod_deflate

I personally also adhere to mod_deflate since it’s documentation on Apache’s website is quite complete.

In this article I’m gonna explain you how I quickly added support for mod_deflate gzip compression to a Webserver I’ve recently had to configure for a website.

Doing so reduced the access time to the website from 6-7 seconds as reported by Yahoo’s Yslow to 3-4 secs.

These days people are constantly looking for a ways to improve their web site opening times in order to improve the end user experience, so the reduce to about 3 seconds in a website access time is quite a good achievement.

Some time ago I’ve blogged about How to enable http gzip compression on CentOS 5.x to speed up Apache

However I’ve realized I haven’t blogged how the same thing is achieved on a Debian Linux so therefore I decided it might be interesting to somebody out there to explore how same thing is achieved on Apache server running on top of Debian.
Anyways enough jabberish, here is the exact steps I took on a Debian Lenny server to configure properly an Apache 2.x webserver gzip compression through the mod_deflate module.

1. Open up /etc/apache2/mods-available/deflate.conf and place the following configuration directives within the file:

<IfModule mod_deflate.c>
# AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml application/rss+xml application/json text/css text/javascript application/javascript application/x-javascript
# Insert filter
#SetOutputFilter DEFLATE

# Netscape 4.x has some problems
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

# Don’t compress already compressed stuff !
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</IfModule>

Note that above configuration has an extra configuration directives to AddOutputFilterByType DEFLATE which are gonna instruct it to also gzip compress content of the CSS and Javascript (js) files as well.

2. Shut off Etags in /etc/apache2/apache2.conf the quickest way to do it would be:

debian-server:~# echo "FileEtag none" >> /etc/apache2/apache2.conf

3. Enable mod_deflate in your Apache server

debian-server:~# ln -sf /etc/apache2/mods-available/deflate.conf /etc/apache2/mods-enabled/deflate.conf
debian-server:~# ln -sf /etc/apache2/mods-available/deflate.load /etc/apache2/mods-enabled/deflate.load

Now you need to restart your Apache server for the changes to take affect.

debian-server:~# /etc/init.d/apache2 restart

This changes are also about to include the common suggestion by Yahoo Yslow that warns about the following message:
Grade D on Compress components with gzip

There are x plain text components that should be sent compressed

Thus the aforementioned changes to your Apache would guarantee you also a good compression status in Yslow web site slowness test.
After the changes the returned message by Yslow would be:

Grade A on Compress components with gzip

By the way it took me quite a lot of time to search for a solution to the annoying yslow issue where the .css and .js scripts failed to be compressed with gzip nevertheless the mod_deflate module was active.
I therefore hope this post will help somebody else issuing the Yslow css and javascript not being compressed issues to get solved.

How to anonymize Skype on Linux / Use anonymous skype through tor

Monday, August 16th, 2010

I’ve recently worked on anonymizing as many of my applications as I could in that spirit.
I looked for a practical way to anonymize my Skype. Skype communication is so essential this days,
it’s very likely that a huge part of skype communication is being monitored by skype corp, it’s not impossiblethat some malicious installed trojan in skype would report about which IP address you’re using to connectto Skype.
Therefore proxifying skype could be a step further to at least prevent for following your skype traffic route.
Of course passing Skype traffic via tor is not a guarantee for anonimity since it’s probably very easy for Skypeowner company to keep record of Skype users, where do they people originate from, full log of people comminicationvia skype based on their user login.
As skype is a closed software and we have no access neither to the protocol specs neither to program source code, it’s almostimpossible to know if communication via skype is secure in sense of privacy.

It appeared that proxifying skype is a piece of cake and comes just to a proper instalating of Tor + polipo caching proxy and further installing proxychains

Proxychains is a rather interesting software, it’s able to carry any application TCP and DNS traffic through a proxy server (http and socks).
Therefore proxychains is able to run any program through proxy server and hence hide your real IP.

Interesting fact is that proxychains is the Unix equivalent for Window’s Freecap“Program based on universal DLL injection in alien process (works on all Windows from Win95 to Longhorn), which hooks Winsock API, redirecting connect requests to the SOCKS server.

So if you intend to proxify your Skype application on a Windows host you will have to use Wincap.

Back to the main topic of “what is the way to proxify” skype on Linux, so here is how I did it:

1. Install proxychains (available on a Debian host directly as a deb package)

debian:~# apt-get install proxychains

2. Install skype from source on Debian Testing/Unstable (Lenny / Squeeze / Sid). I personally use skype_static-2.0.0.72.tar.bz2

debian:~# cd /root

debian:/root# wget https://www.pc-freak.net/files/skype_static-2.0.0.72.tar.bz2
debian:/root# tar -jxvf skype_static-2.0.0.72.tar.bz2
debian:/root# mkdir /opt/Skype/
debian:/root# mv skype_static-2.0.0.72 /opt/Skype/

Also place a skype startup script to instruct skype that it will have to use the pulseaudio for a sound server.

Crete the /usr/local/bin/skype file.
It should contain the following

#!/bin/sh
export SDL_AUDIODRIVER=pulse;
/usr/bin/proxychains /usr/bin/linux32 /opt/Skype/skype_static-2.0.0.72/skype
#/usr/bin/torify /usr/bin/linux32 /opt/Skype/skype_static-2.0.0.72/skype

Now simply startup skype by either typing /usr/local/bin/skype from a terminal or either create a shortcut towards skypeor edit the existing shortcut added in either GNOME or KDE menus and set it to use /usr/local/bin/skype as a skype starter.

Even better proxychains can be used to proxify via a tsocks proxy any other application on your BSD or Linux.

I’ve also noticed that tor deb is also equipped with a program called torifytorify – wrapper for tsocks and tor

I’m not quite sure if torify is also able to torify skype along with the other applications for which it can be used to torify traffic, so if any of the readers of this article can give some feedback if they have tried that would be really nice 🙂

The terrible impuldent Google Chrome Linux package default behaviour (Chrome overwritting default configurations without even asking)

Sunday, August 15th, 2010

Recently I issued some kind of upgrade and have noticed Google Chrome is spit off the message you read below:

update-alternatives: warning: forcing reinstallation of alternative /usr/bin/google-chrome because link group gnome-www-browser is broken.

I think this kind of insolent behaviour from Google’s Linux Chrome version is notable.
How come that the browser indulges itself to tamper with my default gnome-www-browser?
For the KDE users I feel indebted to mention that by default gnome-www-browser is linked to Epiphany
which itself is cross linked from /etc/alternatives/gnome-browser to /usr/bin/epiphany

I’m pretty happy with Epipahy most of the time so I decided to switch back my default gnome-www-browser by issuing the cmds:

debian:~# rm -f /etc/alternatives/gnome-www-browser
debian:~# ls -sf ln -sf /usr/bin/epiphany /etc/alternatives/gnome-www-browser

This will reverse back your default Gnome browser to Epiphany
Anyways this kind of behaviour of Google packaging their Google Chrome version to overwrite default configurations without even poping up a promptor something is really passive agressiveness.
Guess the passive agressiveness is an overall politics adopted by Google nowadays.

How to revoke user global privileges in MySQL

Saturday, August 14th, 2010

I’ve recently realized one of the users I have added to one of the MySQL servers I do managehas actually some included a list of some of the global privileges.
This extra privileges the user had was actually something that was to be removed since theuser is not supposed to be able to list all existent databases on the MySQL server and things alike:

You can see below the excact SQL queries I had to issue to revoke the granted global privileges for the username.
Note to change the username before you execute the below queries:

REVOKE ALL PRIVILEGES ON * . * FROM 'username'@'localhost';
REVOKE GRANT OPTION ON * . * FROM 'username'@'localhost';
GRANT USAGE ON * . * TO 'username'@'localhost' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIO

 

How to skip annoying waiting times before download links appear in RapidShare and Megaupload

Thursday, August 12th, 2010

I’ve accidently found Skip screen a firefox plugin that is able to get rid of annoying waiting times before you can manage to your downloads for rapidshare, megaupload etc.
Maybe the plugin description from their website is the best to describe skipscreen

SkipScreen is a free Firefox add-on that skips the clicking and waiting on sites like RapidShare, Megaupload, Mediafire, zShare, and more!Never download music without it. Click here to install skipscreen to your firefox
That’s all no more annoying waitings before you can proceed and download a rare file.

How to solve errors during subversion repository check out svn (Error: URL Error: of existing directory Error: expected URL does not match)

Wednesday, August 11th, 2010

A colleague of mine tried recently to use tortoise because his previous work station (a Mac Book notebook) has a problem with his charging device.
Therefore he is right now forced to use Windows as tortoisesvn is among one of the best if not the best option of a subversion client for the Windows platform naturally he decided to install tortoise and to download one of the subversion repositories stored on our development server.

Till now all went fine for him as he conctacted me in Skype to report he cannot check out from the repo, because his check out operation has suddenly froze up with a message:

Added: C:UsersmyuserapplicationconfigsMygeneral.php Error: URL ‘svn+ssh://someuser@192.168.0.1/var/svn-repos/your_repository/trunk/application/configs/Mine’ Error: of existing directory ‘C:Usersmyuserapplicationconfigsmine’ does not match Error: expected URL

This of course is a very raw version of the error and it wasn’t really gave us any clue on what might be causing the desired svn check out.

After a bit research in Google, a lot of testing and many try catches we got what was causing the check out failures on his Windows XP.

The whole issues were caused by the fact that Windows’s FAT16, FAT32 file system is case insensitive.
On that account when tortoise tried to download and save two directories one called Mine and the other called mine under thesame folder hood in windows it failed, since already Mine directory was present and existing.

It later appeared that the mine directory contained some old garbage which doesn’t have to deal with out source application stored inthe repository so we completely decided to remove it.

However the issues caused and the 30 minutes lost in tracking the issues are a lot of lost time for nothing …
So just to close this post if you get error like:


Added: C:UsersmyuserapplicationconfigsMygeneral.php Error: URL
'svn+ssh://someuser@192.168.0.1/var/svn-
repos/your_repository/trunk/application/configs/Mine' Error: of existing
directory 'C:Usersmyuserapplicationconfigsmine' does not
match Error: expected URL

Be sure to check the files content of your svn repository for duplicate directories with case sensitiveness.

I’m not sure if it’s Windows file case insenstive file system (for not implementing case sensitivity by now), subversion repository software running on the server or the tortoise client fault but I’m sure this is rather ridiculous and needs a soon and timely fix by someone of the three mentioned ones.