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

Create a Bootable USB Flash Drive

Insert a USB flash drive into a running computer.

    Open a Command Prompt window as an administrator.

    Type diskpart.

    In the new command line window that opens, to determine the USB flash drive number or drive letter, at the command prompt, type list disk, and then click ENTER. The list disk command displays all the disks on the computer. Note the drive number or drive letter of the USB flash drive.

    At the command prompt, type select disk <X>, where X is the drive number or drive letter of the USB flash drive, and then click ENTER.

    Type clean, and the click ENTER. This command deletes all data from the USB flash drive.

    To create a new primary partition on the USB flash drive, type create part pri, and then click ENTER.

    To select the partition that you just created, type select part 1, and then click ENTER.

    To format the partition, type format fs=ntfs quick, and then click ENTER.
   

    Type active, and then click ENTER.

    Type exit, and then click ENTER.

    When you finish preparing your custom image, save it to the root of the USB flash drive.

Installing Apache2 With PHP5 And MySQL Support On CentOS 6.4

The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/html/info.php

<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):





As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have MySQL support in PHP5 yet.


6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

yum search php

Pick the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and Xcache. It is strongly recommended to have one of these installed to speed up your PHP page.

APC can be installed as follows:

yum install php-pecl-apc

Now restart Apache2:

/etc/init.d/httpd restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:



7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases.

First we enable the RPMforge repository on our CentOS system as phpMyAdmin is not available in the official CentOS 6.4 repositories:

Import the RPMforge GPG key:

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

On x86_64 systems:

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

On i386 systems:

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

phpMyAdmin can now be installed as follows:

yum install phpmyadmin

Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the <Directory "/usr/share/phpmyadmin"> stanza):

vi /etc/httpd/conf.d/phpmyadmin.conf

#
#  Web application to manage MySQL
#

#<Directory "/usr/share/phpmyadmin">
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#</Directory>

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Next we change the authentication in phpMyAdmin from cookie to http:

vi /usr/share/phpmyadmin/config.inc.php

[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
[...]

Restart Apache:

/etc/init.d/httpd restart

Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:

Reset Forgotten windows password

Hiren's BootCD From USB Flash Drive (USB Pen Drive) :

Step 1

Connect USB Pen Drive (1GB or more)
Step 2
Download and Run USB Disk Storage Format USB Disk Storage Format USBFormat.zip (34KB)


 Step 3
Download grubinst_gui Grub 4 Dos grub4dos.zip (179KB) and Run as Administrator

Step 4
Insert the BootCD (10.3 or newer) in the CD Drive and Copy everything from CD to USB Flash Drive

Step 5
Copy grldr and menu.lst from grub4dos.zip (or from HBCD folder) to the usb drive




Make sure you set your computer to boot from USB Flash Drive

To Enter the BIOS press the "Del" button on your keyboard. Alternatives are "F1", "F2", "Insert", and "F10". Some PC's BIOS might even require a different key to be pressed. Commonly a PC will show a message like "Press [Del] to enter Setup" to indicate that you need to press the "Del" key. Some AMI BIOS require you to enable the option "USB Keyboard Legacy support"!

Find files in Linux

find folder size ----- > du -sh <folder-name>
find file        ----- > $ find /usr/local -type f -name xxx.txt
files modified between now and 1 day ago  --> find /var/... -mtime 0
find files modified less than 1 day ago   --> find /var/... -mtime -1
find files modified between 24 and 48 hours ago --> find /var/... -mtime 1
find files modified more than 48 hours ago --> find /var/... -mtime +1
delete svn ----> rm -rf `find . -type d -name .svn`



It will find all backups older than 30 days and delete them.
0 3 * * * find $HOME/db_backups -name "db_name*.sql" -mtime +30 -exec rm {} \; >> $HOME/db_backups/purge.log 2>&1

Older than 30 days :
find /path-to-file/ -name "test-*".tar.gz  -mtime +30 -exec rm {} \;
find /path-to-file/ -name "test_*".sql  -mtime +30 -exec rm {} \;

Files older than 25days : find /path-to-file/ -name "test-*".tar.gz  -mtime +25; 
Find and copy : find /path-to-file/xxx-*  -mtime +30 -exec cp {} /path-to-file \;

svndump command

For complete Repo : 

svnadmin dump c:\repository  > c:\tmp
 
For Single project in Repo :

svnadmin dump c:\repository | svndumpfilter include project > c:\tmp

Grant accesses in Linux


    Grant read access (r) to a file to all members of your group (g):
    chmod g+r file-name
    Grant read access to a directory to all members your group:
    chmod g+rx directory-name
    Note that "execute" permission is required in order to read a directory.
    Grant read permissions to everyone on the system to a file which you own so that everyone may read it: (u)ser, (g)roup and (o)ther.
    chmod ugo+r file-name
    Grant read permissions on a directory to everyone on the system:
    chmod ugo+rx directory-name
    Grant modify or delete permissions to a file which you own for everyone in the group:
    chmod ugo+rw file-name
    Note: In order for modify and delete permissions to be useful, one must be able to modify the directory in which the file is located: chmod ugo+rwx ./
    Deny read access to a file by everyone except yourself:
    chmod go-r file-name
    Allow everyone in your group to be able to modify the file:
    chmod 660 file-name

Keystore Genaration

keytool -genkey -v -keystore /var/www/../xxxxxxxxxx.keystore -alias alexkey -validity 10000 -keysize 1024

Adb + Ubuntu 12.04

Code:

sudo gedit /etc/udev/rules.d/99-android.rules

Code:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0cec", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0cec"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"

Code:

sudo chmod a+rx /etc/udev/rules.d/99-android.rules

Code:

reboot

Code:

~$ adb devices
List of devices attached
SH24SW405437    device
s

If this not work add

Code:

sudo gedit /.android/adb_usb.ini

Code:

0bb4

Code:

reboot

How To Setup Android SDK with Eclipse on Ubuntu 12.04 LTS Precise Pangolin

System requirements:
You need to install Java Development Kit (JDK) to get the stuff work. Simply run the following command to install it:

        sudo apt-get install openjdk-6-jdk

1. Android SDK for Linux
First thing first, you need to download Android SDK for Linux here. It's around 80MB so it might take a while to download. Once downloaded, run the following commands:

        sudo cp -r android-sdk_r20.0.1-linux.tgz /opt
        cd /opt
        sudo tar xvzf android-sdk_r20.0.1-linux.tgz
        sudo chmod -R 755 /opt/android-sdk-linux


Then run the SDK Manager to download necessary libraries and APIs:

        cd /opt/android-sdk-linux/tools
        sudo ./android sdk

Well, if you want to develop Android application for Android 2.3.3 then you should Android 2.3.3 (API 10).

2. Eclipse

For developing Android application, Eclipse 3.6 is recommended. You can download it here. Optionally, you can put the downloaded Eclipse into system folder so other users can use it:

        sudo cp -r eclipse-java-helios-SR2-linux-gtk.tar.gz /usr/local
        cd /usr/local
        sudo chmod a+x eclipse-java-helios-SR2-linux-gtk.tar.gz
        sudo tar xvzf eclipse-java-helios-SR2-linux-gtk.tar.gz
        #create Eclipse shortcut on Desktop
        cd ~/Desktop
        ln -s /usr/local/eclipse/eclipse


3. Installing ADT Plugin for Eclipse
In order to communicate with Android SDK Tools, Eclipse needs a plugin so called ADT plugin. Please open your Eclipse IDE, navigate to "Help > Install New Software ...", click "Add" in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:

        http://dl-ssl.google.com/android/eclipse/

And then click OK. In the Available Software dialog, check the "Developer Tools" checkbox, click Next and follow on-screen instruction.
4. Configuring ADT Plugin
The last step you need to do is locating the Android SDK Tools to work with Eclipse. In Eclipse menu, select "Window > Preferences...", select "Android" from left panel, in the "SDK Location" click "Browse" and locate your Android SDK Tools (in this example: /opt/android-sdk-linux).



Now you are ready to develop Android application on Linux.

'Arial' is not available to the JVM. See the Javadoc for more details

Solution
Step1:Check whether font "Arial" is already installed on the box :
#ERROR!
log in with any user name and type the following command :
fc-list | grep Arial
if found no need to install the font.
Step2:Install the font "Arial" if not available on the box:
#ERROR!
1)log in as root
2)move to /usr/share/fonts and create a folder with name as "truetype".
3)copy the font file "Arial.ttf" (found in windows/fonts on WinXp) into the folder "truetype".
4)run the command following command to see whether the font is installed properly
fc-list | grep Arial

Install latest Skype 4.1 in Ubuntu 12.10/12.04/Linux Mint 14/13 (New Release)

To install skype in Ubuntu/Linux Mint open Terminal (Press Ctrl+Alt+T) and copy the following commands in the Terminal:
Terminal Commands:
wget -O skype.deb http://download.skype.com/linux/skype-ubuntu-precise_4.1.0.20-1_i386.deb
sudo dpkg -i skype.deb
sudo apt-get -f install;

rm skype.deb

Setup SVN (Subversion) Access Control with Apache

Setup SVN (Subversion) Access Control with Apache and mod_authz_svn
1. Change root user

su -
## OR ##
sudo -i


2. Add SVN (Subversion) users

Use following command:

## Create testuser ##
htpasswd -c -m /etc/svn-auth-users testuser
New password:
Re-type new password:

Adding password for user testuser

## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password:
Re-type new password:

Adding password for user testuser2

Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.
3. Create SVN Access Control file

On this guide, I use following /etc/svn-access-control file.

## Open /etc/svn-access-control file with your favourite editor ##
nano -w /etc/svn-access-control

Add following type content to file:

[groups]
testgroup = testuser1, testuser2
testgroup2 = testuser3, testuser4, testuser5
testgroup3 = testuser6, testuser7

[/]
* = r
@testgroup = rw
testuser4 = rw

[testrepo:/]
@testgroup2 = rw
testuser6 = rw

[testrepo2:/trunk]
@testgroup3 = rw
testuser5 = rw

[testrepo2:/tags]
@testgroup3 = r
testuser5 = rw


4. Add AuthzSVNAccessFile to subversion server config

Previously created /etc/httpd/conf.d/subversion.conf file:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>


Add AuthzSVNAccessFile row to config:

AuthzSVNAccessFile /etc/svn-access-control

Finally /etc/httpd/conf.d/subversion.conf file should look something like following:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   AuthzSVNAccessFile /etc/svn-access-control
   Require valid-user
</Location>

5. Restart Apache Web Server

/etc/init.d/httpd restart
## OR ##
service httpd restart

Install SVN (Subversion) Server on Fedora 19/18, CentOS/Red Hat (RHEL) 6.4/5.9

What is SVN (Subversion)?

Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.

Install SVN (Subversion) Server on Fedora 19/18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9


1. Change root user
 su -
## OR ##
sudo -i


 2. Install needed packages (mod_dav_svn and subversion)

yum install mod_dav_svn subversion

Note: If you don’t have Apache installed already, this command installs it also. Read more about installing Apache and PHP >>

3. Modify Subversion config file /etc/httpd/conf.d/subversion.conf

Add following config to /etc/httpd/conf.d/subversion.conf file:


LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>


 4. Add SVN (Subversion) users

Use following command:


## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password:
Re-type new password:
Adding password for user testuser

## Create testuser2 ##

htpasswd -m /etc/svn-auth-users testuser2
New password:
Re-type new password:
Adding password for user testuser2

Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.


5. Create and configure SVN repository

mkdir /var/www/svn
cd /var/www/svn

svnadmin create testrepo
chown -R apache.apache testrepo


## If you have SELinux enabled (you can check it with "sestatus" command) ##
## then change SELinux security context with chcon command ##


chcon -R -t httpd_sys_content_t /var/www/svn/testrepo

## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

Restart Apache:

/etc/init.d/httpd restart
## OR ##
service httpd restart

Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:
 Enter SVN Subversion username and password

SVN testrepo revision 0:
SVN Subversion Repository Revision 0
 

6. Configure repository
To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:
## Disable anonymous access ##
anon-access = none

## Enable access control ##
authz-db = authz

7. Create trunk, branches and tags structure under testrepo

Create “template” directories with following command:


mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}

Then import template to project repository using “svn import” command:

svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Adding         /tmp/svn-structure-template/trunk
Adding         /tmp/svn-structure-template/branches
Adding         /tmp/svn-structure-template/tags

Committed revision 1.

Check results on browser and see testrepo revision





Wednesday, December 11, 2013

How to Install Oracle Java on Ubuntu 12.04 Linux

1 Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit, open up a terminal and run the following command below.

    Type/Copy/Paste: file /sbin/init
       
Note the bit version of your Ubuntu Linux operating system architecture it will display whether it is 32-bit or 64-bit.


2 Open up a terminal and enter the following command:

        Type/Copy/Paste: java -version

    If you have OpenJDK installed on your system it may look like this:
        java version "1.7.0_15"
        OpenJDK Runtime Environment (IcedTea6 1.10pre) (7b15~pre1-0lucid1)
        OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
    If you have OpenJDK installed on your system, you have the wrong vendor version of Java installed for this exercise.

3 Completely remove the OpenJDK/JRE from your system and create a directory to hold your Oracle Java JDK/JRE binaries. This will prevent system conflicts and confusion between different vendor versions of Java. For example, if you have the OpenJDK/JRE installed on your system, you can remove it by typing the following at the command line:

    Type/Copy/Paste: sudo apt-get purge openjdk-\*
        This command will completely remove OpenJDK/JRE from your system
    Type/Copy/Paste: sudo mkdir -p /usr/local/java
        This command will create a directory to hold your Oracle Java JDK and JRE binaries.

4 Download the Oracle Java JDK/JRE for Linux. Make sure you select the correct compressed binaries for your system architecture 32-bit or 64-bit (which end in tar.gz).

    For example, if you are on Ubuntu Linux 32-bit operating system download 32-bit Oracle Java binaries.
    For example, if you are on Ubuntu Linux 64-bit operating system download 64-bit Oracle Java binaries.
    Optional, Download the Oracle Java JDK/JRE Documentation
        Select jdk-7u40-apidocs.zip
    Important Information: 64-bit Oracle Java binaries do not work on 32-bit Ubuntu Linux operating systems, you will receive multiple system error messages, if you attempt to install 64-bit Oracle Java on 32-bit Ubuntu Linux.

5 Copy the Oracle Java binaries into the /usr/local/java directory. In most cases, the Oracle Java binaries are downloaded to: /home/"your_user_name"/Downloads.

    32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
        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

    64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
        Type/Copy/Paste: cd /home/"your_user_name"/Downloads
        Type/Copy/Paste: sudo cp -r jdk-7u45-linux-x64.tar.gz /usr/local/java
        Type/Copy/Paste: sudo cp -r jre-7u45-linux-x64.tar.gz /usr/local/java
        Type/Copy/Paste: cd /usr/local/java


6 Unpack the compressed Java binaries, in the directory /usr/local/java

    32-bit Oracle Java on 32-bit Ubuntu Linux installation instructions:
        Type/Copy/Paste: sudo tar xvzf jdk-7u45-linux-i586.tar.gz
        Type/Copy/Paste: sudo tar xvzf jre-7u45-linux-i586.tar.gz

    64-bit Oracle Java on 64-bit Ubuntu Linux installation instructions:
        Type/Copy/Paste: sudo tar xvzf jdk-7u45-linux-x64.tar.gz
        Type/Copy/Paste: sudo tar xvzf jre-7u45-linux-x64.tar.gz


7 Double-check your directories. At this point, you should have two uncompressed binary directories in /usr/local/java for the Java JDK/JRE listed as:

    Type/Copy/Paste: ls -a
    jdk1.7.0_45
    jre1.7.0_45

8 Edit the system PATH file /etc/profile and add the following system variables to your system path. Use nano, gedit or any other text editor, as root, open up /etc/profile.

    Type/Copy/Paste: sudo gedit /etc/profile
    or
    Type/Copy/Paste: sudo nano /etc/profile

9 Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:

    Type/Copy/Paste:

    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


10 Save the /etc/profile file and exit.

11 Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.

    Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_45/bin/java" 1
        this command notifies the system that Oracle Java JRE is available for use
    Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_45/bin/javac" 1
        this command notifies the system that Oracle Java JDK is available for use
    Type/Copy/Paste: sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.7.0_45/bin/javaws" 1
        this command notifies the system that Oracle Java Web start is available for use

12 Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java.

    Type/Copy/Paste: sudo update-alternatives --set java /usr/local/java/jre1.7.0_45/bin/java
        this command will set the java runtime environment for the system
    Type/Copy/Paste: sudo update-alternatives --set javac /usr/local/java/jdk1.7.0_45/bin/javac
        this command will set the javac compiler for the system
    Type/Copy/Paste: sudo update-alternatives --set javaws /usr/local/java/jre1.7.0_45/bin/javaws
        this command will set Java Web start for the system


13 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

14 Test to see if Oracle Java was installed correctly on your system. Run the following commands and note the version of Java:
15 A successful installation of 32-bit Oracle Java will display:

    Type/Copy/Paste: java -version

        This command displays the version of java running on your system
    You should receive a message which displays:
        java version "1.7.0_45"
        Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
        Java HotSpot(TM) Server VM (build 24.45-b08, 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_45


16 A successful installation of Oracle Java 64-bit will display:

    Type/Copy/Paste: java -version

        This command displays the version of java running on your system
    You should receive a message which displays:
        java version "1.7.0_45"
        Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
        Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, 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_45

17 Congratulations, you just installed Oracle Java on your Linux system. Now reboot your Ubuntu Linux system.

Optional: How to enable Oracle Java in your Web Browsers

    To enable your Java plug-in in your web browsers you must make a symbolic link from the web browsers plug-in directory to the location of the Java plug-in included in your distribution of Oracle Java.

Important Note: I would urge caution when enabling Oracle Java 7 in your web browsers, due to the fact there have been many numerous security flaws and exploits. Essentially, by enabling Oracle Java 7 in your web browsers if a security flaw or exploit is discovered this is how the bad guys break in and compromise your system. For more information on security flaws and exploits in Java see the following website: Java Tester

Edit Google Chrome

32-bit Oracle Java instructions:

    Issue the following commands.
        Type/Copy/Paste: sudo mkdir -p /opt/google/chrome/plugins
            this will create a directory called /opt/google/chrome/plugins
        Type/Paste/Copy: cd /opt/google/chrome/plugins
            this will change you into the google chrome plugins directory,make sure you are in this directory before you make the symbolic link
        Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_45/lib/i386/libnpjp2.so
            this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Google Chrome web browser

64-bit Oracle Java instructions:

    Issue the following commands.
        Type/Copy/Paste: sudo mkdir -p /opt/google/chrome/plugins
            this will create a directory called /opt/google/chrome/plugins
        Type/Paste/Copy: cd /opt/google/chrome/plugins
            this will change you into the google chrome plugins directory,make sure you are in this directory before you make the symbolic link
        Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_45/lib/amd64/libnpjp2.so
            this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Google Chrome web browser

Reminders:

    Note: Sometimes when you issue the above command you may receive a message which states:
        ln: creating symbolic link `./libnpjp2.so': File exists
        To correct this issue simply remove the previous symbolic link using the following command:
        Type/Copy/Paste: cd /opt/google/chrome/plugins
        Type/Copy/Paste: sudo rm -rf libnpjp2.so
        Make sure you are in the /opt/google/chrome/plugins directory before you issue the command
    Restart your web browser and go to Java Tester to test if Java is functioning in your web browser.

EditMozilla Firefox

32-bit Oracle Java instructions:

    Issue the following commands.
        Type/Paste/Copy: cd /usr/lib/mozilla/plugins
            this will change you into the directory /usr/lib/mozilla/plugins, create this directory if you do not have it
        Type/Paste/Copy: sudo mkdir -p /usr/lib/mozilla/plugins
            this will create the directory /usr/lib/mozilla/plugins, make sure you are in this directory before you make the symbolic link
        Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_45/lib/i386/libnpjp2.so
            this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Mozilla Firefox web browser

64-bit Oracle Java instructions:

    Issue the following commands.
        Type/Paste/Copy: cd /usr/lib/mozilla/plugins
            this will change you into the directory /usr/lib/mozilla/plugins, create this directory if you do not have it
        Type/Paste/Copy: sudo mkdir -p /usr/lib/mozilla/plugins
            this will create the directory /usr/lib/mozilla/plugins, make sure you are in this directory before you make the symbolic link
        Type/Paste/Copy: sudo ln -s /usr/local/java/jre1.7.0_45/lib/amd64/libnpjp2.so
            this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Mozilla Firefox web browser

Reminders:

    Note: Sometimes when you issue the above command you may receive a message which states:
        ln: creating symbolic link `./libnpjp2.so': File exists
        To correct this issue simply remove the previous symbolic link using the following command:
        Type/Copy/Paste: cd /usr/lib/mozilla/plugins
        Type/Copy/Paste: sudo rm -rf libnpjp2.so
        Make sure you are in the /usr/lib/mozilla/plugins directory before you issue the command
    Restart your web browser and go to Java Tester to test if Java is functioning in your web browser.

Upgrading CentOS 5 from PHP 5.1 to 5.3

 see what is installed (assuming php-mcrypt & php-mhash are installed

yum list installed | grep php | cut -d' ' -f1
typical result:
php.x86_64
php-cli.x86_64
php-common.x86_64
php-devel.x86_64
php-gd.x86_64
php-imap.x86_64
php-ldap.x86_64
php-mbstring.x86_64
php-mcrypt.x86_64
php-mhash.x86_64
php-mysql.x86_64
php-odbc.x86_64
php-pdo.x86_64
php-pear.noarch
php-xml.x86_64
php-xmlrpc.x86_64

 removes the 16 packages above (make sure there is nothing above you want to keep)

 Check that only the packages above are listed before you press yes


yum remove php php-*

    See what php53 provides:

yum search php53 | cut -d' ' -f1 | grep php

    Notice packages missing: php-mhash php-pear (note mhash is deprecated)

yum install php53 php53-cli php53-common php53-devel php53-gd php53-imap php53-ldap php53-mbstring\
 php53-mysql php53-odbc php53-pdo php53-xml php53-xmlrpc php53-mcrypt


    Can install php-pear back in again—it seems this doesn’t have 5.1 dependencies

yum install php-pear

    Have to put back any changes made in /etc/php.ini, e.g.:
        memory_limit = 128M
        post_max_size = 40M
        upload_max_filesize = 20M
    Find the [Date] section, uncomment the timezone line and add something like:
        date.timezone = 'America/Toronto'

service httpd restart

Install mcrypt from source

yum install php53-devel libmcrypt-devel gcc

    first get php version 5.3.6 (above 5.3.6 fails with PHP_FE_END undeclared in devel library)
    Check latest version here: us2.php.net/releases/#5.3.3

ver=php-5.3.6
cd ~
wget http://www.php.net/get/$ver.tar.gz/from/us3.php.net/mirror
tar xf $ver.tar.gz

    now run one line at a time:

cd ~/$ver/ext/mcrypt/
phpize
aclocal
./configure
make
make test #to help make PHP better
make install
echo "extension=mcrypt.so" > /etc/php.d/mcrypt.ini
service httpd restart
rm -Rf ~/$ver

Update APC

yum install pcre-devel
pecl install -f apc


    add extension=uploadprogress.so to /etc/php.ini

Update phpMyAdmin

    If installed by Rimu script, check here: ls /etc/httpd/conf.d/ to see if yum has renamed conf file
    Upgrade to new version here: drup.org/upgrading-phpmyadmin

Useful Links

    This article was very helpful:
        chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
    Other useful links:
        linuxnet.ch/groups/linuxnet/wiki/8457a/