Friday, December 27, 2013

500 internal server error while uploading files bigger then 100kb - mod_fcgid problem

For no special reason Drupal sites on our server (CentOS 5 with cPanel/WHM) started to make problems with file upload. Because Drupal 6/7 has use Ajax for file uploading the only thing that happens is that browser just hangs until timing out. Quick playing with different file sizes revealed that files that are less then 100kb are OK, but bigger files are creating problem. Of course php post_max_size and upload_max_filesize are set to 20mb so that was not causing problems. Strange...

Actually the biggest problem here was finding out what the hell is happening. I quickly created small html/php script with file upload form, and when testing with files bigger then 100kb I immediately got 500 internal server error - OK, that is something but still not telling much. Most annoying thing was fact that php error_log and apache logs that I was getting from Cpanel and WHM were error empty.

Yes in CentOS (managed with cPanel) you have logs all over the place. Finally founded master apache log that I needed and there was explanation

[Fri Dec 08 13:39:14 2013] [warn] [client 1.1.1.1] mod_fcgid: HTTP request length 132356 (so far) exceeds MaxRequestLen (131072), referer: http://www.test.com/.../upload.html

So MaxRequestLen from mod_fcgid (and we are running fast cgi for PHP) is limiting request length to only 130kb - If the size of the request body exceeds this amount, the request will fail with 500 Server Error. Fix is easy you just need to add in your httpd.conf next lines

# Work around annoying fcgid limitations
<IfModule mod_fcgid.c>
  # 20MB should be enough
  MaxRequestLen 20000000
</IfModule>

Friday, December 20, 2013

Upgrading oracle Java on Ubuntu Linux

This document is intended to assist with the upgrade of the many new release versions of Oracle Java JDK/JRE on Ubuntu Linux. Every so often, due to bug fixes and security issues Oracle releases updates to their version of the Java JDK/JRE.

1 Download the new Oracle Java binaries make sure you select the correct updated Java JDK/JRE binaries of Oracle Java, for your Ubuntu Linux system architecture, either 32-bit or 64-bit, the Oracle Java binaries end in( tar.gz ) such as:

    jdk-7u45-linux-i586.tar.gz (32-bit)
    jre-7u45-linux-i586.tar.gz (32-bit)
    or
    jdk-7u45-linux-x64.tar.gz (64-bit)
    jre-7u45-linux-x64.tar.gz (64-bit)


Method 1 of 4: 32-bit Oracle Java instructions:

    1 Become root user and copy the new compressed Oracle Java binaries from our download directory to /usr/local/java
        Type/Copy/Paste: cd /home/"your_user_name"/Downloads
        Type/Copy/Paste: sudo cp -r jdk-7u45-linux-i586.tar.gz /usr/local/java
        Type/Copy/Paste: sudo cp -r jre-7u45-linux-i586.tar.gz /usr/local/java
        Type/Copy/Paste: cd /usr/local/java

    2 Next we are going to unpack our new version of Oracle Java binaries, in the directory /usr/local/java
        Type/Copy/Paste: sudo tar xvzf jdk-7u45-linux-i586.tar.gz
        Type/Copy/Paste: sudo tar xvzf jre-7u45-linux-i586.tar.gz

EditMethod 2 of 4: 64-bit Oracle Java instructions:

    1 Become root user and copy the new compressed Oracle Java binaries from our download directory to /usr/local/java
        Type/Copy/Paste: cd /home/"your_user_name"/Downloads
        Type/Copy/Paste: sudo -s cp -r jdk-7u45-linux-x64.tar.gz /usr/local/java
        Type/Copy/Paste: sudo -s cp -r jre-7u45-linux-x64.tar.gz /usr/local/java
        Type/Copy/Paste: cd /usr/local/java

    2 Next we are going to unpack our new version of Oracle Java binaries, in the directory /usr/local/java
        Type/Copy/Paste: sudo tar xvzf jdk-7u45-linux-x64.tar.gz
        Type/Copy/Paste: sudo tar xvzf jre-7u45-linux-x64.tar.gz

    3 At this point you should have two new uncompressed binary directories in /usr/local/java for the Java JDK/JRE listed as:

jdk1.7.0_45
jre1.7.0_45


Along with:

jdk1.7.0_40
jre1.7.0_40


Method 3 of 4: Modify your Linux system PATH:

    1 Edit the system PATH file /etc/profile and add the following system variables to your system path. Use gedit, nano or any other text editor, as root, and open up /etc/profile
        Type/Copy/Paste: sudo gedit /etc/profile
        or
        Type/Copy/Paste: sudo nano /etc/profile
    2 Scroll down using your arrow keys to the end of the file and add the following lines below to the end of your /etc/profile file in Ubuntu Linux,at this point you are going to be changing the version numbers from the old Oracle Java to the new version of Java, you will change the versions numbers in the following system PATH file /etc/profile:


Modify the /etc/profile file:

JAVA_HOME=/usr/local/java/jdk1.7.0_25
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.7.0_25
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH


Change to this:

JAVA_HOME=/usr/local/java/jdk1.7.0_45
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.7.0_45
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH



Save the file and exit

Method 4 of 4: Inform your system of the updated Oracle Java version:

    1 Inform your Ubuntu Linux system where your Oracle Java JRE/JDK is located, now you will want to update the system to use Oracle Java 1.7.0_45
        Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_45/bin/java" 1
        Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_45/bin/javac" 1
        Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_45/bin/javaws" 1

    2 Inform your Ubuntu Linux system, that Oracle Java JRE 1.7.0_40 must be the new default Java
        Type/Copy/Paste: sudo update-alternatives --set java /usr/local/java/jre1.7.0_45/bin/java
        Type/Copy/Paste: sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_45/bin/javac
        Type/Copy/Paste: sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_45/bin/javaws

    3 Reload your system wide PATH /etc/profile by typing the following command:
        Type/Copy/Paste: . /etc/profile
        Note your system wide PATH /etc/profile file will reload after reboot of your Ubuntu Linux system
    4 Test to see if the new version of Oracle Java was installed correctly on your system by running the following commands and noting the version number of the new Java update.
        Type/Copy/Paste: java -version
            this command displays the version of Java running on your system
    5 You should receive a message which displays:
        java version "1.7.0_40"

        Java(TM) SE Runtime Environment (build 1.7.0_40-b08)Java HotSpot(TM) 64-Bit Server VM (build build 25.1-b02, mixed mode)
        Type/Copy/Paste: javac -version
        this command lets you know that you are now able to compile java programs from the terminal
            You should receive a message which displays:
        javac 1.7.0_40
    6 Afterwards, you have the option of removing the old Oracle Java JDK/JRE, by simply removing the directory's which hold the old Java JDK/JRE binaries.
        Type/Copy/Paste: cd /usr/local/java
        Type/Copy/Paste: sudo rm -rf jdk1.7.0_40
        Type/Copy/Paste: sudo rm -rf jre1.7.0_40







Wednesday, December 18, 2013

Creating openoffice service

edit registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name

1. Key Name: Parameters
   Class : <leave blank>
   Select the Parameters key.

2. From the Edit menu, click Add Value. Type the following and click OK:


      Value Name: Application
      Data Type : REG_SZ
      String : <path>\<application.ext>

3. service named OpenOfficeUnoServer
      path:  C:\Program Files\OpenOffice.org 2.0\program\soffice.exe
4. Add another value to the Parameters key named AppParameters and set it to -headless -accept=socket,port=8100;urp;
5.start service.
6. replace share\registry\data\org\openoffice\Setup.xcu
office 3.x--> OpenOffice.org 3\Basis\share\registry\data\org\openoffice

        <prop oor:name="ooSetupInstCompleted">
        <value>false</value>
        </prop>
       <prop oor:name="ooSetupShowIntro">
       <value>true</value>
       </prop>
with
       <prop oor:name="ooSetupInstCompleted" oor:type="xs:boolean">
       <value>true</value>
       </prop>
       <prop oor:name="LicenseAcceptDate" oor:type="xs:string">
       <value>2006-07-25T17:34:04</value>
       </prop>
       <prop oor:name="FirstStartWizardCompleted" oor:type="xs:boolean">
       <value>true</value>
       </prop>


7. restart service

verification : netstat -anp tcp
create a folder called "reskit" --> in C drive
put all the .exe files from srvany

C:\>cd reskit
C:\reskit>C:\reskit\instsrv.exe "OpenOfficeUnoServer" C:\reskit\srvany.exe

edit key
key name - application
D:\OpenOffice.org 3\program\soffice.exe
C:\reskit\instsrv.exe "OpenOfficeUnoServer" C:\reskit\srvany.exe