Installing LAMP on Kubuntu or Ubuntu

This post represents a small guide of how to setup your LAMP (Linux-Apache-MySQL-PHP) under Kubuntu (this works also for Ubuntu).

Usually LAMP tutorials guide you to install one by one all the applications, that looks something like this:

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install mysql-server

There is one more easy solution, and the only difference is that it installs all + some other packages for LAMP.

sudo apt-get install lamp-server^

When installation of new packages finishes you have you own LAMP setup! Test it entering http://localhost in your browser it should say It works!

Tip #1

For adding PhpMyAdmin execute the following command in console:

sudo apt-get install phpmyadmin

It is possible when you type in your browser http://localhost/phpmyadmin/ that phpmyadmin don’t runs. Then you have to create a link in your www directory:

sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

After doing this http://localhost/phpmyadmin/ should work now!

Tip #2

To have permissions to your www directory do following:

sudo chown username:username /var/www

Tip #3

Enable Apache mod_rewrite module and restart Apache for taking effects:

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

You can enable or disable some other modules like this.

Now you have your LAMP up and the work can start :)

Clone VirtualBox vdi Image

virtualbox clone vdi imageFew words about VirtualBox

VirtualBox is an open source virtualization product for home and enterprise use. It gives you the power to work on some other OS than you’re running (Windows, Linux, Macintosh and Solaris as hosts), and it supports a great number of guest operating systems.

How to clone?

Let’s suppose you setup you guest OS, installed some applications, made updates, and now you wish to backup it if something goes wrong. The easiest solution will be to find directory where is your vdi file and copy it somewhere as backup, but that isn’t the good solution. You have to clone it!

There are few solutions how to do it, this one is when the host is a Windows OS. Run command prompt and enter the directory where is your VirtualBox applications installed (usually program files) and than execute a command.

C:\Program Files\Sun\VirtualBox>VBoxManager.exe clonevdi "source" "destination"

Suppose your vdi image is located on D: drive under directory VBox and named ubuntu910 and you want to make a vdi image clone named bckup_ubuntu910 on D: drive. That will look like this:

C:\Program Files\Sun\VirtualBox>VBoxManager.exe clonevdi "d:/VBox/ubuntu910.vdi" "d:/bckup_ubuntu910.vdi"

After execution of command you’ll see a percentage number of cloning status in command prompt, when it reaches 100% your vdi clone is ready. Clone has got new UUID (Universal Unique Identifier), so there will be no conflict if you decide to use both (original and the cloned one).

Using Multiple Firefox Profiles

firefoxTime since I discovered this little trick, I use it always. I like that I can have two Firefox profiles run at the same time, but they are totally different. They have separate directories created for profiles and as that they can have totally different extensions installed than each other. So, I have created recently one more profile for web developing, which contains all the extensions I need for it like Firebug, Web developer toolbar, some validators, etc. Now I have the default profile which is used for surfing over Internet with own extensions, browsing history, bookmarks, and web development profile with it own extensions.

How to create Firefox profile?

I won’t make a full descriptions of steps how to do it, I rather redirect you to some places where I also got knowledge about this. Just shortly, after you created your new Firefox profile you can make a shortcut for it, only what you have to do is to add few parameters in the target field. In my case it looked like the following line.

"C:\Program Files\Mozilla Firefox\firefox.exe" -P WebDev -no-remote

As you can suppose from the line above, my new profile name was “WebDev” before which is a parameter “-P” which means profile, so we call profile named “WebDev” and “-no-remote” parameter is which enables to run multiple profiles!

For further read I suggest to visit following links which explains in more details how goes the profile creation part and all together.

I think this is very handy, how about you?

How to Compress JavaScript Code

how to compress javascriptIn past few months and recently I did some JavaScript coding. The whole source code wasn’t so big, around 15kB, but it may be growing more, and there are also other JavaScript files which are included in the page and maybe I merge them. To reduce amount of data and in hope to little speed up loading of the page I was looking for some options to compress (minify) the source code.

What means to minify JavaScript?

One more term which is used for reducing the size of code is minification or minify.

Minification (very often just minify, and sometimes also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code, without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments and sometimes block delimiters; which are used to add readability to the code, but are not required for it to execute. – wikipedia.org

Why to compress/minify?

In putting to a simple way the whole quote above, compress (minify) the code to load it faster! Beside that you’ll reduce the bandwidth consumption of website, and number of HTTP requests if you combine several JavaScript files in one.

Tools for compress/minify

Searching over Internet I found several tools which are commonly used for compressing JavaScript code, these tools for compress are:

JSMin – is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.

Dojo compressor – in the design of the the Dojo compressor,  instead of brittle regular expressions, the Dojo compressor is based on Rhino, a JavaScript engine from the Mozilla project.

Packer v3.0 – some features of it are respect Microsoft conditional terms, new option to shrink variable and argument identifiers, removed the special chars feature (except the ;;; feature which people seem to like) etc.

Google minify -  is a PHP5 app that helps you follow several of Yahoo!’s Rules for High Performance Web Sites. It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers.

YUI compressor – The YUI Compressor is a JavaScript compressor which, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This obfuscation is safe, even when using constructs such as ‘eval’ or ‘with’ (although the compression is not optimal is those cases) Compared to JSMin, the average savings is around 20%.

Note: it’s possible to make gzip compression of code, which are supported natively by modern web browsers, and also shrink previously minified JavaScript file.

Which one to use?

Well that’s a personal decision, I read some posts and articles over Internet and most of them suggests YUI compressor, but it don’t means that you have too.

On web page called JavaScript CompressorRater you can found details and analyzes how successful are different compression tools in action. Compression is done on popular JavaScript libraries. I recommend to visit it, at least you can get some view on their success in action.

Online compress tools

Here are some online compress tools for beginning:

In some of next posts I’ll try to explain how to make it done on your computer, not with an online compress tool. Happy compressing!