Tuesday, 29 July 2008

Installing Apache2 server with PHP and MySQL support

Today I wanted to try out and start learning PHP scripting language a bit. PHP is server-side scripting language so for it to work I need a server that supports it. Apache web server is widely used with PHP so I'm going for that combo. Also, I would like to have a MySQL database support.
Here's how I did that on Ubuntu 8.04 LTS. Googling around I found that the wanted combo is named LAMP (Linux-Apache-MySQL-PHP) task and it can be installed using tasksel command:
sudo tasksel install lamp-server


But unfortunately it gave me an error:
tasksel: aptitude failed (100)


Is it a bug or something wrong with my machine? Anyone has an answer please comment.
So I turned to the good old apt-get:
sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql


After the installation you'll be asked for MySQL 'root' user password. Enter it and don't forget! :) Now, the Apache server can be started with:
$ sudo /etc/init.d/apache2 start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName


To hide this strange "Could not... " message you need to create a file /etc/apache2/conf.d/fqdn and put this line in it:
ServerName localhost


Now to check functionality create a 'test.php' in the /var/www/ directory with the line:
<?php phpinfo();?>


Open up your browser and type http://localhost/test.php in the address bar. If you get something like this:



you did it!
For configuring databases, user privileges etc. there is an application called "phpmyadmin" that really ease the job.

Wednesday, 9 July 2008

Mounting bin/cue files in Linux

It's impossible to mount .bin/.cue files in Linux with the 'mount' command. Bin/cue files always come in pairs; bin file is the raw image of a cd, and the cue file specifies the mode in which a cd is written and the number of bytes per sector in the image (bin) file.
There are two methods for mounting bin/cue files. First is to convert bin/cue file to iso than burn it, and the second is to try mounting it directly with some other software tools.

Converting to iso with bchunk

One of the commands for converting bin/cue image to .iso image is bchunk. If you don't have it installed already type:
sudo apt-get install bchunk

Now, to convert it to iso type:
bchunk -v image.bin image.cue <basename>

And now, when the conversation is done mount an iso file:
mount -o loop,ro -t iso9660 <filename>.iso <mountpoint>

Some other tools

CDfs - download - cdfs is a file system kernel module. You can use it instead of iso9660 when you mount cds. It will show all the tracks on a cd as files in the mounted directory, i.e. A data cd may show a single .iso file, an audio cd will show some .wav files, and a mixed cd may show an .iso file and an apple hfs image, and some .wav files.

cdemu - homepage - Userspace CDEmu is a CD/DVD-ROM device emulator for linux, licensed under GPL v2 or later.

Enjoy!

Thursday, 3 July 2008

Symbolic Links vs. Hard Links

Many times, it is required that two or more applications have access to the same file somewhere on the file system. Microsoft users are familiar with those kinda files named icons that point to another directory or a file physically written on disk so when users run it, they actually run the file that icon points to. Links in Linux function that way, as a pointer to physical data. There are two kinds of links in Linux: hard links and symbolic links.
On most system all file names are hard links. The name of the file is just a name that refers to the actual data stored on the disk. It is possible to create multiple names (hard links) for the same data stored on the disk, so the data stored on the disk can be modified from different locations. Simply put, if one hard link is modified, all hard links (including the original file) is modified. Hard links on Linux are made with the ln command. If the file '.myconf' allready exists, to create a hard link named '.conf' we'll write:
ln /path/to/.myconf /path/to/.conf

If '.conf' is modified, '.myconf' is modified as well. All hard links pointing to same original file have same characteristics of that file such as, amount of disk space used, file permissions and so on. Drawback of hard link is that it is hard to make a difference between it and the real file because they show all real file characteristics. Also, all hard links need to be located on the same filesystem.
Symbolic links serves the same purpose as hard links, but they only contain a path to original file, not all characteristics of a file, so they are easy to differentiate. To create symbolic link type:
ln -s /path/to/original/file /path/to/symlink

Symbolic links are more used than hard links.