Archive for Gentoo

Apache + PHP + MySQL on Gentoo

This blog is moved to the new location:

You can read the same article at its new location: Apache + PHP + MySQL on Gentoo

Most of the today’s web applications need the combo of Apache, PHP and MySQL packages to be first installed on the system. Installing these software on a Gentoo system should be a straightforward process. Below is the complete procedure.

First add apache2 and mysql to the USE flag in the /etc/make.conf file:

$ emacs -nw /etc/make.conf

USE=”gtk gnome qt kde dvd alsa cdr hal howl imap maildir mysql apache2

emerge the apache package:

$ emerge apache
$ /etc/init.d/apache2 start
$ rc-update add apache2 default

Test the installation by accessing the url http://localhost/ from a web browser. If you get a welcome message from apache, the installation is complete. More info here.

Now emerge PHP4 and the mod_php module for apache:

$ emerge dev-php/php mod_php

Add the configuration directive(-D PHP4) to /etc/conf.d/apache2 file and restart the apache web server:


$ /etc/init.d/apache2 restart

Create a sample php script in the directory /var/www/localhost/htdocs with the following contents and access it from the web browser to test the php installation:


If you see a lot of information displayed about the version of PHP and other related things then PHP is installed and properly configured with the apache web server. Installation of PHP5 is also similar but be warned that still a lot of software runs only on PHP4(Eg: phpBB Bulletin Software). With a little bit of effort you can also run both PHP4 and PHP5 on the same system side by side.

Install MySQL and all the related tools:

Add the following lines to the /etc/portage/package.keywords file:

>=dev-db/mysql-administrator-1.1.5 ~x86
>=dev-db/mysql-query-browser-1.1.17 ~x86
>=dev-cpp/gtkmm-2.8 ~x86
>=dev-cpp glibmm-2.7 ~x86

$ emerge mysql mysql-administrator mysql-query-browser
$ emerge –config mysql-4.1.14
$ /etc/init.d/mysql start

Set a root password for mysql server when prompted by the ’emerge –config’ command. You can administer the mysql server by using either the command line tools or using the graphical tool mysql-adminstrator. Similarly, the command line client mysql can be used to create and view the database schemas or the graphical tool mysql-query-browser can be used. I recommed you give these two graphical applications a try.

Other databases, like PostgreSQL, can be used instead of MySQL whenever the applications support it, but a majority of the applications support only the MySQL database. WordPress for example doesn’t support PostgreSQL.


Comments (7)

A NFS Story on Gentoo

I still carry the habit of storing all the large files in my Windows partitions from my bad old Windows days. That allows me to plug any kind of device into the computer and copy the files to/from it. Gnu/Linux supports all kinds of DVD writers and Pen drives too, but my friends sometimes carry such wierd devices(and mp3 players) that they can be connected to a computer using the Windows operating system only. Accessing files in the Windows OS from a linux partition is a time consuming and inefficient process – I do it using the excellent tool called Explore2FS, but its not an ideal tool for copying large amounts of files and directories. So it suits me well: store the files on the windows partitions and access them easily from both Windows and GNU/Linux(by using a simple mount command).

When I discovered that my old Debian Sarge installation was not detecting the USB port for some reason, and that its DVD-ROM has also died upon me, my only way to transfer some files to it was through the LAN. The files were contained in an ISO file on a Windows NTFS partition on a different machine. This is what I had to do to make the ISO file contents available to my USB-less, DVD-less Debian system:

I use Gentoo as my primary operating system on my personal desktop. The first job for me was to mount the local Windows partition(hda7) that contained the needed ISO file in the Gentoo filesystem.
$ mkdir /mnt/win_d
$ mount /dev/hda7 /mnt/win_d
$ ls /mnt/win_d/*.iso

The ISO file was visible. I tried to export the /mnt/win_d directory using NFS and then tried to mount the ISO file on the Debian system, but it didn't work out that way to me. Not in a mood to loose too much time over it, I mounted the ISO file on my Gentoo System itself and then exported this mounted directory:

$ mkdir /mnt/myiso
$ mount -o loop /mnt/win_d/myiso.iso /mnt/myiso
$ ls /mnt/myiso

All the files contained in the ISO file were visible. The next job is to install the NFS server and the related tools if they are already not available, and then export the /mnt/myiso directory using it.

$ emerge nfs-utils

Put the following line /etc/exports:

/mnt/myiso, no_subtree_check, ro, no_squash_root)

I have specified a range of IP addresses to export the directory to all the machines within the subnet. Only one IP address or a different IP address range can also specified there. Note that there should be NO space between the IP address/IP address range and the opening paranthesis that follows it. To learn more about the different options and their meanings that can be specified in the line, head on to this.

Start the nfs and portmap daemons and add them to the default runlevel(so that they start automatically at the boot time).

$ /etc/init.d/nfs start
$ rc-update add nfs default
$ /etc/init.d/portmap start
$ rc-update add portmap default

If you ever make changes to the /etc/exportfs file, then export all your changes using:

$ exportfs -ra
$ /etc/init.d/nfs reload
$ exportfs

The last command shows you all the directories that are currently exported.

Now go to the other machine(Debian in my case) and use a simple mount command to access the exported directory.

$ mkdir /mnt/remote
$ mount /mnt/remote
$ ls /mnt/remote

You should see all the files from the exported directory. The IP address above is of the host system(Gentoo in my case) which is running the nfs daemon. Now you can use the /mnt/remote directory as any other directory on the local gnu/linux system. If the exported directory were a linux partition or a Windows FAT partition, then the write options could also have been ebabled by using the "rw" option in the /etc/exportfs file in place of the "ro" option. The following line can be added to the /etc/fstab file to mount this directory automatically at the boot time: /mnt/remote nfs ro 0 0

The IP address, as above, is of the host system. You may be interested in this: NFS in Gentoo

Leave a Comment

Direct Server to Server Copy using FXP

FTP is still the best way to upload or download the files/folders from a website. I use gFTP to upload the files to my webspace, and its quite efficient at the job. even if the connection gets interrupted in the middle of a transfer, it automatically reconnects and completes the job. it has many other useful features too. one feature that i thought was lacking in it, is the ability to move a folder from one location to the other, within the same server. other people had complained for its lack of abilitiy to move a file from one server to another server without involving the local machine in the process. though many FTP clients support such a feature(including gFTP, as i discovered later on), i started searching for a dedicated FXP client. but what is FXP? from wikipedia:

File eXchange Protocol (FXP) is a method of data transfer which uses the FTP protocol to transfer data from one remote server to another without routing this data through the client’s connection.

note that FXP transfers need relevant support on the server side too(they must support PASV mode and PORT commands) – otherwise the FXP client can’t do anything about it. to install a FXP client on Gentoo:

  1. Add the following line to the file /etc/portage/package.keywords :
    >=net-ftp/gtkfxp-0.5 ~x86
  2. Emerge the package and run it:
    $ emerge gtkfxp
    $ gtkfxp

click the “Connect” button on the left side and fill the settings of the first server in the popped up dialog box, then click the “Connect” button on the right side and fill out the settings of the second server. you can now start transferring the files in between these two servers without involving your local machine. you can enter the information about the same server in both the dialog boxes if you want to transfer the files within the same server. note that this software is buggy and very crash prone. gFTP too supports FXP transfers but it is seriously lacking in the documentation.

Leave a Comment

Java 1.5 and Eclipse in Gentoo – Part II

This blog is moved to the new location:

You can read the same article at its new location: Java 1.5 and Eclipse in Gentoo – Part II

my previous post discussed the installation of Java on a Gentoo system. its all well as long as you want to run the default supported version of java on the Gentoo system – you install blackdown-jdk 1.4, Eclipse 3.0, and maybe Eclipse CDT too. but if you want to install java 1.5(Tiger), then you need to unmask the package and remember to make blackdown(or sun) jdk 1.4 as the default JVM for the system. you can keep sun jdk 1.5 as the default JVM for the user. the procedure is like this:

$ java-config -L

[sun-jdk-] “Sun JDK” (/etc/env.d/java/20sun-jdk- *
[blackdown-jdk-] “Blackdown JDK” (/etc/env.d/java/20blackdown-jdk-

this shows you all the installed jdks on your system. use the name as given under the brackets to set that particular jvm as your system default:

$ java-config -S blackdown-jdk-
$ /usr/sbin/env-update && source /etc/profile

this sets the blackdown jdk 1.4 as the system jvm, which is the recommended option. you can set the sun jdk 5.0 as the user default jvm though:

$ java-config -s sun-jdk-
$ echo source ~/.gentoo/java-env >> ~./bash_profile
$ source ~/.gentoo/java-env

this sets the sun jdk 1.5 as the user jvm and it is safe this way. but don’t make 1.5 version as the default jvm for the system unless you are ready to break a lot of java applications.

Best way to install Java on Gentoo OS:

but this still is not an ideal setup from my point of view; the installed Eclipse version doesn’t support the Java 1.5 version. if you want to use the latest versions of all the java software without going through all of these hassles, then you need to install everything related to java manaully in the user home directory. this won’t affect your normal portage structure.

first download the latest versions of java sdk and the eclipse ide from the internet and copy them into the home directory.

download sun jdk 1.5.0 update 6 from here and copy it into the home directory. you will have to accept the license to be able to download this. be sure to download the .bin version of the file, and not the rpm version.

download the latest version of the eclipes ide from here and copy it in the home directory. the latest build available currently is Eclipse 3.2M5a. If you plan to use Eclipse CDT plugin to create C++ applications, then you have to be content with the Eclipse 3.1.2 version.

(all the above links are for the gnu/linux, 32-bit operating system. finding similar package files for 64-bit systems shouldn’t be too difficult)

install jdk as a normal user:

$ chmod +x jdk_1_5_0_06-linux-i586.bin
$ ./jdk_1_5_0_06-linux-i586.bin
$ tar xvzf eclipse-sdk-3,1,2-linux-gtk.tar.gz

rename the directory to which the above files are extracted to something simple, like “eclipse”.

now add the following lines to your user profile( eg ~/.bash_profile ):

PATH=~/jdk1.5.0_06/bin:~/jdk1.5.0_06/jre/bin:~/eclipse:$PATH MANPATH=$MANPATH:~/~/jdk1.5.0_06/man

source the profile once and start the eclipse IDE:

$ source ~./bash_profile
$ eclipse

Go to Windows menu and select Preferences from it. Select Java -> Installed JREs from the left pane and click on the “Add” button on the right pane. browse to and select jdk1.5.0_06/jre directory from your home directory. enter “JDK1.5.0_06” in “JRE Name:” field. click on Java -> Compiler item from the left pane and select “5.0” from the “Compiler Compliance Settings:” selection list. Click OK button to dismiss the dialog box.

Now you can create java 1.5 applications on your Gentoo system using the Eclipse IDE.
just extract the Eclipse CDT tar file in the eclipse folder to get the C++ support in Eclipse. (contents of ‘features’ directory from downloaded package should go into the ‘features’ directory in eclipse, and contents of ‘plugins’ directory should go into the ‘plugins’ directory in eclipse).


Comments (1)

Java on Gentoo

The simplest way to get started with Java development in Gentoo is to install the Blackdown JDK-1.4.2 along with the Eclipse IDE:

$ emerge blackdown-jdk eclipse-sdk

if you want to install the sun's version of the jdk, instead of blackdown jdk, you can get the 1.4.2 version of it using:

$ emerge sun-jdk java-sdk-docs

to install the 1.5 version of the jdk, you need to unmask it first. add the following two lines to your /etc/portage/package.keywords file:

>=dev-java/sun-jdk-1.5.0 ~x86
>=dev-java/java-sdk-docs-1.5.0 ~x86

now do the emerge:

$ emerge sun-jdk java-sdk-docs

you can also install both of these versions at the same time, and then make one of them as the default jdk. if you need java support in other applications too(like web browser etc), then make sure to add the relevant keywords in the /etc/portage/package.use file:

=dev-java/sun-jdk- X alsa browserplugin doc examples jce mozilla nsplugin

this also installs the documentation and the examples. change the version number if you are installing the 1.5 version of the jdk.

if you want to use Eclipse IDE to create C++ programs, you need the eclipse-cdt package. first unmask it by placing the following line in /etc/portage/package.keywords file:

>=dev-util/eclipse-cdt-2.0 ~x86

now do the emerge:

$ emerge eclipse-cdt

here is more information on installing java 1.5 and eclipse 3.x on Gentoo OS.

Comments (3)

Installing C++ Boost on Gentoo and Debian/Ubuntu

C++ Boost on Gentoo:

on the shell prompt, type:

$ emerge boost

this should install the latest version of boost available for Gentoo. Currently, the latest version of boost, version 1.33.1, is available for Gentoo. synchronise('emerge –sync') with the gentoo portage if your 'emerge -p boost' shows an earlier version.

C++ Boost on Debian/Ubuntu:

$ apt-get install libboost-date-time1.33.0 libboost-doc libboost-filesystem1.33.0 libboost-graph1.33.0 libboost-program-options1.33 libboost-python1.33.0 libboost-regex1.33.0 libboost-signals1.33.0 libboost-test1.33.0 libboost-thread1.22.0

you can use the following simple command to install every library present in boost that matches a pattern, if you don't want to be selective about which libraries to install:

$ apt-get install libboost.*1.33.*

once the boost package is installed, the C++ programs that make use of boost libraries can be built simply like this:

$ g++ -o first first.cpp

if the program needs to be linked to a library(for eg: filesystem library), then specify the name of the library using the -l switch:

$ g++ -o second second.cpp -lboost-filesystem

will follow up with the installation procedure for Slackware and RPM based distributions.

Comments (1)

C# on Gentoo

.NET developers looking for a similar development framework on gnu/linux operating system should check out the Mono project. its fairly simple to install Mono on most of the gnu/linux environments and start developing applications using the C# language. but beginner programmers would love to have an easy to use IDE which could integrate all the tools required for C# based development in one place. one such tool is MonoDevelop which is fast developing into a useful product. installing it on rpm based distribution was not a satisfactory experience for me however. but i knew it should be easy to install it on Ubuntu and Gentoo operating systems. if you have included Mutliverse and Universe repositories in the apt source list, then MonoDevelop is just one 'apt-get install' away on Ubuntu. it required only a bit more effort on a Gentoo system, so i am documenting it here.

Most of the packages required to get MonoDevelop working on a Gentoo system are in the masked state. put the following lines in the /etc/portage/package.keywords file(create it if it already doesn't exist):

>=dev-dotnet/gtkhtml-sharp-2.4.0 ~x86
>=dev-dotnet/glade-sharp-2.4.0 ~x86
>=dev-dotnet/gconf-sharp-2.4.0 ~x86
>=dev-dotnet/art-sharp-2.4.0 ~x86
>=dev-dotnet/gnome-sharp-2.4.0 ~x86
>=dev-dotnet/vte-sharp-2.4.0 ~x86
>=dev-dotnet/gnomevfs-sharp-2.4.0 ~x86
dev-dotnet/gtksourceview-sharp ~x86
dev-dotnet/gecko-sharp ~x86
dev-dotnet/libgdiplus ~x86
dev-util/monodevelop ~x86
dev-lang/mono ~x86

you can drop ">=" in front of some of the lines above by dropping the version numbers in the same lines.
eg: dev-dotnet/gtkhtml-sharp ~x86
now run 'emerge monodevelop' to get everything installed:
#emerge monodevelop
'emerge mono' will get only the mono environment and all development can be carried out using your favourite editor and command shell.

if you get any problems, first try 'emerge sync' to get everything synchronised, and then rerun 'emerge monodevelop'. if you still get any errors, see if still there are any dependency problems left that are in the masked state. if so, add them too to the '/etc/portage/package.keywords' file and repeat the process.
let me know how this works out for you, as i haven't found much information regarding this on the internet.

Comments (5)