Friday 15 March 2013

Setting java path in linux

After installing JDK or JRE on Linux/Unix platform, you have to set PATH environment variable so that you can run the executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type the full path of the command.
 
 Steps to set up java path in linux

1. Create a java.sh file in /etc/profile.d directory with content as follows: 
 
#!/bin/bash
           
JAVA_HOME=/usr/java/jdk1.7.0_17
                    
PATH=$JAVA_HOME/bin:$PATH
                                       
export PATH JAVA_HOME
 
The file contains various shell commands which set and export necessary environment variables for Java. Shell settings from configuration files in the /etc/profile.d directory are gathered by/etc/profile during login, setting up user environment information for every user.  
 
2.  Assign execute permissions:
 
# chmod 755 java.sh

3. You can verify the path  by typing the below command in the terminal

# java -version 

Wednesday 13 March 2013

MySQL: The total number of locks exceeds the lock table size

When you are trying to run an update or insert query in a database which contains huge amount of data (crore) in xampp - MySQL, you might see this error

ERROR 1206 (HY000): The total number of locks exceeds the lock table size

Running out of space for locks usually indicates that the small default size of the InnoDB buffer pool is being used or operations on very large tables are being attempted with a huge number of row locks, perhaps comparing several large tables. The only way to fix it for sure is to adjust innodb_buffer_pool_size and restart MySQL. By default, this is set to only 8MB, which is too small for anyone who is using InnoDB to do anything.

Solution
1. Stop MySQL and open my.cnf file which is located in  /opt/lampp/etc/my.cnf  in Linux
2. increase the values of innodb_buffer_pool_size and innodb-log-file-size
for example :

innodb_buffer_pool_size = 2G
innodb-log-file-size = 512 M

innodb-log-file-size should be 25% of innodb_buffer_pool_size

In a dedicated system you can use up to 80% of the total RAM in the system for the InnoDB buffer pool.   
3. Delete the log files ib_logfile0, ib_logfile1 which is located in /opt/lampp/var/mysql 
4. Start MySQL 

Monday 11 March 2013

New XAMPP security concept:fixed

When you download XAMPP 1.8.0. and got the error at
localhost/phpmyadmin


New XAMPP security concept:

Access to the requested object is only available from the local network.

This setting can be configured in the file "httpd-xampp.conf".

If you think this is a server error, please contact the webmaster.

Error 403

localhost


Solution

1) Open httpd-xampp.conf which is at /opt/lampp/etc/extra/
2) Find <Directory "/opt/lampp/phpmyadmin">
3) Now just add Require all granted before </Directory>

    <Directory "/opt/lampp/phpmyadmin">
    AllowOverride AuthConfig Limit
    Order allow,deny
    Allow from all
    Require all granted
   </Directory>


4) Find  <LocationMatch and change
  Deny from all 
to 
Allow from all

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|
server-status|server-info))">
        Order deny,allow
        Allow from all
        Allow from ::1 127.0.0.0/8 \
                fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
                fe80::/10 169.254.0.0/16

        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.
var
</LocationMatch>


5) restart xampp 

Wednesday 6 March 2013

Configure Tomcat 7 to run Python CGI scripts in windows

Pre-installation requirements
1. Java
2. Python

steps
1. Download latest version of Tomcat (Tomcat 7) from
    http://tomcat.apache.org/download-70.cgi
2. After successful installation of tomcat modify the web.xml file in the  <TOMCAT_HOME>\conf\folder ( eg: C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf)
 uncomment the cgi servlet and its mapping

<servlet>
 <servlet-name>cgi</servlet-name>
 <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
 <init-param>
 <param-name>debug</param-name>
 <param-value>0</param-value>
 </init-param>
 <init-param>
 <param-name>cgiPathPrefix</param-name>
 <param-value>WEB-INF/cgi</param-value>
 </init-param>
 <load-on-startup>5</load-on-startup>
</servlet>

<servlet-mapping>
 <servlet-name>cgi</servlet-name>
 <url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>



3. Add an servlet parameter "passShellEnvironment" and set it to “true” (
 "force" the environment variables to be passed)

<init-param>
          <param-name>passShellEnvironment</param-name>
          <param-value>true</param-value>

</init-param> 
4.  Add an servlet parameter "executable"
<init-param>
          <param-name>executable</param-name>
          <param-value>C:\Python27\python.exe</param-value>
 </init-param> 


so the overall cgi servlet in web.xml is given below
<servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
        <init-param>
          <param-name>executable</param-name>
          <param-value>C:\Python27\python.exe</param-value>
        </init-param>
        <init-param>
          <param-name>passShellEnvironment</param-name>
          <param-value>true</param-value>
        </init-param>
         <load-on-startup>5</load-on-startup>
    </servlet> 


5.  Modify <TOMCAT_HOME>\conf\context.xml  to add a property on <Context>:
 <Context privileged="true">
...
</Context>

6. Create a folder say "test" in <TOMCAT_HOME>\webapps directory . It is the root folder for your application
7. create a WEB-INF folder inside the root folder (test) and create a cgi folder inside WEB-INF folder
8. Create a python CGI script and put in in <TOMCAT_HOME>\webapps\test\WEB-INF\cgi\

hello.py

print "Content-type: text/html\n\n";
print "Hello, world!\n"


9. start the tomcat server and browse the url
http://localhost:8080/test/cgi-bin/hello.py