Pages

Welcome to My Blog

This is to share my IT experience with friends all around the world.
I have been working in Linux Fedora Systems for more than 8 years. Its fun to share knowledge and learn..
As everyone knows when a problem arises in your systems "googling" is the way that many depend on..

All the posts here are my working experiences during my working life.. So you can count on it..

I have added the references where I got help in solving IT issues


Thursday, November 1, 2012

Set Timeout value for a mysql Connection

Due to bad handing of mysql connections (Not properly closed the connections ) there will be several already used open mysql connections waiting to close. By default the connection waiting timeout and the interactive time out values are 8 hours (28800 seconds).
Times set in your mysql server can be observed using following commands;

mysql> show variables like "%timeout%";


It will list down several timeout settings including interactive_timeout and  wait_timeout

If you want to set these values according to your requirement edit your my.cnf (Default location is /etc/my.cnf) and add following setting under mysqld.

[mysqld]
interactive_timeout=3360
wait_timeout=3360


As given above I have set the value to 3360 ( which is 1 hour)

Then restart the service and it will effect the new connections.

Good reference:
http://stackoverflow.com/questions/4284194/terminating-idle-mysql-connections
http://dba.stackexchange.com/questions/1558/how-long-is-too-long-for-mysql-connections-to-sleep

Tuesday, October 30, 2012

Localizing ownCloud

We thought of installing ownCloud as a file/media/calendar sharing system and it was very easy to install it by just following the given instructions available at ownCloud itself.

While using the system we wanted to localized it to our own languages (si_LK - Sinhala- Sri Lanka, ta_LK - Tamil- Sri Lanka). As given in the instructions we created 2 projects at https://www.transifex.com and started translations on .po files. During the translation process it was required to view them on the installed ownCloud system. I followed several links and referred documentations but failed to make it. Finally, I used the following method to get it done.

1. Download all translated .po files for the required language;
As transifex allowed to download all kinds of .po files related to the language, I was able to collect all .po for si_LK

2. Create a folder with the language name inside the l10n folder at the document root of the ownCloud installation
In my case I create a folder si_LK at /var/www/html/owncloud/l10n 

3 Place all translated .po files in to the language folder and change the ownership of the folder to web server user (e.g. apache, www-data )

4. Visit to 'core/l10n' folder at the document root (var/www/html/owncloud/core/l10n in my case) and there will be several locales ( uk.php, th_TH.php etc) available for your owncloud installation.

5. Create a locale file for your language 
In my case I created si_LK.php ( Just copy an existing .php file as si_LK.php). The name of the file should be identical to the folder created at l10n.

6. Run the script available at l10n folder at the document root.
perl l10n.pl read
perl l10n.pl write
 
Now login to the ownCloud system and under the settings--> personal you will be able to select newly created locale as your language.


 

Sunday, June 17, 2012

Eleminate PHP Header Information Warning

In some instances we need to set header information inside the <body> section.
E.g. Redirecting to other page according to a condition.
Example code:
If ($a = "Yes")

header("location:ok.php"); 


It may gives a warning and code will stop at run time displaying a warning "Warning: Cannot modify header information - headers already sent by (output started at location) in /page on line xyz)"

Edit php.ini in your apache server and modify as "output_buffering = On"
To stop this warning and allow to add header information at to send header lines (including cookies) even after you send body content.
 

Friday, March 30, 2012

Add secondary IPv6 addresses to one NIC in Fedora

Sometimes you may need to add several global ipv6 addresses to the same interface card. This is allowed in IPv6 in almost all the OSs. In fedora it can be done in several ways. I have tried it in following way and succeeded.

Example:
You already have IPv6 enabled in your Fedora server and need to add another global IPv6 to the interface eth0

Edit the ifcfg-eth0 and add the following special key word with the IPv6 address you want to add as the secondary. IPV6ADDR_SECONDARIES=200x:yyyy:xxxx::1/64

Then restart the network and you will notice that the given IPv6 is also got configured.

Sample ifcfg-eth0 file after adding the secondary IPv6

DEVICE=eth0
ONBOOT=yes
NETWORKING_IPV6=yes
IPV6INIT=yes
IPV6ADDR=2xxx:xxxx:xxxx:xxxx::a
IPV6_DEFAULTGW=2xxx:xxxx:xxxx:xxxx::ffff
IPV6ADDR_SECONDARIES=2yyyy:yyyy:yyy::b/64 


Check the configurations by ifconfig command

References:
http://www.cyberciti.biz/faq/redhat-centos-rhel-fedora-linux-add-multiple-ip-samenic/


Wednesday, February 29, 2012

Access Control in Apache with mod_authz_host and mod_access

In Apache web server, access to a website can be controlled to users in several ways. Enable user authentication is one such mechanism. User authentication can  be implemented in the site by it self with the PHP or any other language you used to develop the site OR server administrator can configure the web server to handle user authentication.


The directives provided by mod_authz_host are used to control access to particular parts of the server. From Apache 2.2, mod_access is renamed as mod_authz_host.

Access can be controlled based on the client hostname, IP address, or other characteristics of the client request, as captured in environment variables. The Allow and Deny directives are used to specify which clients are or are not allowed access to the server, while the Order directive sets the default access state, and configures how the Allow and Deny directives interact with each other.

It is done under the <Directory> directive with the AuthUserFile and AuthTypeThe format of a apache based authentication is as follows;


This will allow accesses for the contents in the settings folder to the users who has the login credentials in users_password_file
 
<Directory "/var/www/html/your-site/settings">
        AllowOverride AuthConfig FileInfo Indexes Limit Options
        AuthUserFile /etc/httpd/users/users_password_file
        SSLRequireSSL
        AuthName "Secure Users"
        AuthType Basic
        require valid-user
</Directory>

How you can allow accesses for the above folder from specific IP addresses. That is much easier. By just defining the 'allow from' parameter, it can be achieved.

Following given the format for that setup;

<Directory /var/www/html/your-site/settings> 
    Order Deny, Allow
    Deny from all
    Allow from aaa.bbb.ccc.dddd/netmask
</Directory>


I have used both control mechanisms, with password authentication and IP address filtering.


Thursday, January 5, 2012

Static Routers in Linux

Adding a static route in Linux is a basic but essential requirement. We need to do this in 2 situations.
One is just adding a static route to the Kernel's IP routing table through the command line. This is mainly for testing purposes.
The commands that  can be used are;
    1. ip route add
    2. route add

I have tested the second one 'route add' with following format.
    route add -net <destination_network_ipblock> netmask <subnet_mask> gw <gateway_interface_ip>
    e.g.    route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.200.254

The above given example will add a route to 192.168.2.0/24 network via 192.168.200.254. The important thing here is, a route to 192.168.200.254 should already be installed in the Kernel's routing table (i.e. the server you are configuring static routes, should know how the communicate with 192.168.200.254)

More details related to the second method can be observed with 'man route' command;

The other situation is to install static routes permanently in to the kernel's routing table.
This can be achieved with static-route file.
I have used it in several servers. You need to create a file with the name 'static-routes' at /etc/sysconfig directory.

The static routes you with to apply should be given in line by line. Format of a routing line is as follows;
any net <destination_network_ipblock> netmask <subnet_mask> gw <gateway_interface_ip>
e.g
any net 192.168.2.0 netmask 255.255.255.0 gw 192.168.200.254

The example shows an entry related to the same routing described above.
When the OS is loading, this file will be executed and routing will be applied to the kernel.

Good reference:
http://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html