Tuesday, 17 January 2017

No memory cache has been configured.


To fix this error make sure you have latest php5-apcu installed:

sudo apt-get install php5-apcu

edit config.php

sudo vi /nextcloud/config/config.php

add the following line in your directive

'memcache.local' => '\OC\Memcache\APCu',

restart the webserver

sudo service nginx restart

php does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.

To fix this error edit php5-fpm config file

sudo vi /etc/php5/fpm/pool.d/www.conf

uncomment the following line


env[PATH] = /usr/local/bin:/usr/bin:/bin

and restart php5-fpm

sudo service php5-fpm restart

Thursday, 29 December 2016

RPI - Dynamic IP address

Create your own website using a Free Dynamic DNS service ( I used NoIP)

Once registered and installed the client on your Raspberry Pi you can create a startup script to automatically restart the client after a RPI reboot


  • Create a script in /etc/init.d/noip

# sudo vi /etc/init.d/noip

      copy and paste the following:

#! /bin/sh
# /etc/init.d/noip

### BEGIN INIT INFO
# Provides:     noip
# Required-Start: networking
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start noip at boot time
# Description: Start noip at boot time
### END INIT INFO

# . /etc/rc.d/init.d/functions  # uncomment/modify for your killproc

DAEMON=/usr/local/bin/noip2
NAME=noip2
NOIP=`ps -ef|grep -q [n]oip2`
STATUS=$?

test -x $DAEMON || exit 0

case "$1" in
    start)
    echo -n "Starting dynamic address update: "
    start-stop-daemon --start --exec $DAEMON
    echo "noip2."
    ;;
    stop)
    echo -n "Shutting down dynamic address update:"
    start-stop-daemon --stop --oknodo --retry 30 --exec $DAEMON
    echo "noip2."
    ;;

    restart)
    echo -n "Restarting dynamic address update: "
    start-stop-daemon --stop --oknodo --retry 30 --exec $DAEMON
    start-stop-daemon --start --exec $DAEMON
    echo "noip2."
    ;;

    status)
        if [ ${STATUS} -eq "0" ];then
        echo "noip2 running..."
        else
        echo "noip2 Not running..."
        fi
    ;;

    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
esac
exit 0
  • Set exec permissions
# sudo chmod 755 /etc/init.d/noip
  • Add script to Startup/Shutdown
# sudo update-rc.d noip defaults

Raspberry Pi - quick update script


Quick and easy script to upgrade Raspberry Pi
#! /bin/bash

if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
exit 1
fi

#First Clean Up
echo "First Clean Up old downloaded and no longer required packages......."
apt-get clean
apt-get -y autoremove
echo "Clean Up Done"
echo ""

#Update package list
echo "Update your system's package list....."
apt-get update
echo "Package list updated"
echo ""

#Upgrade all installed packages
echo "Update all installed packages to latest versions....."
apt-get -y dist-upgrade

echo "Update Completed rebooting system...."
reboot

Monday, 19 May 2014

Find....

  • Find and compress files older then X days
find /path/to/files/ -type file -mtime 1 -exec gzip {} \;

1 means 24 hours old
-1 means less than 24 hours old
+0 means more than 24 hours old
+1 means more than 48 hours old

  • Find and compress files older then 5 days and exclude files already compressed (ext .gz)

find /path/to/files/ \( ! -name *.gz \) -type file -mtime +5 -exec gzip {} \;

Wednesday, 24 October 2012

How to create LVM on HP-UX

HP-UX


  • Create a new LVM
  • Extend an existing LVM

Create a new LVM


         STEPS:

      • Create the Physical Volume
      • Create the Volume Group
      • Create a Logical Volume
      • Create the File System


1.Check the list of devices, look for a new disk. The new devices will have a hardware path, but no device file associated with it  (no /dev/dsk/c*t*d* /dev/rdsk/c*t*d*)

# ioscan - fnkc disk

2.Create the device special file for the new hardware path

# insf

3.Check the list of devices to very the special files have been created

# ioscan -fnkC disk

4.Create the PV

# pvcreate /dev/rdsk/c*t*d*    (use -B to have a PV boot capable)

5.Create the Volume Group directory

# mkdir /dev/vgXX

6.Create the group file

Determine the minor number to use:

# ls -l /dev/*/group | sort +5

Choose the next unused number (0x0X0000)

# mknod /dev/vgXX/group c 64 0x0X0000

7.Create the volume group

# vgcreate -s 16 /dev/vgXX /dev/dsk/cxtxdx /dev/dsk/cxtydx

# vgextend /dev/vgxx /dev/dsk/cxtzdx

8.Create the Logical Volume

Check the space available on the VG

# vgdisplay -v vgXX ( Multiply the "Free PE" by "PE Size (MBytes)" to get spare capacity in MB of the volume group )

create the LV

# lvcreate -L 100 -n LVname /dev/vgXX

check the created LV

# vgdisplay -v LVname 

9.Create the FileSystem

# mkfs -F vxfs -o largefiles /dev/vgXX/LVname

10.Create the Mount Point

# mkdir -p <full path to mountpoint>

11.Set the proper ownership and permissions on the mount point

# chown owner:group /<mount point>
# chmod XXX /<mount point>

12.Mount the File System

Edit /etc/fstab using vi and add the proper entry

/dev/vgXX/LVname  /mountpoint vxfs rw,suid,largefiles 0 2

# mount /mountpoint

Check everything is ok

# bdf

DONE



Extend an existing LVM

          STEPS:
      • Add a disk to VG
      • Extend the LV
      • Extend the FS

1.Any devices that are on the ioscan, but are NOT on the vgdisplay are available for use

To get the list of devices:

# ioscan -fnC disk | sed 1,2d | xargs -n 10 | grep HITACHI

To get the list of disks used in the VG's

# vgdisplay -v | grep  "PV Name"

Compare the two and find unused disks 

2.Add unused disks to VG

# pvcreate /dev/rdsk/unused_cxtxdx

# vgextend /dev/vgxx /dev/dsk/unused_cxtxdx


3.Extend the Logical Volume

# lvextend -L XXXMb /dev/vgXX/LVname

4.Extend File System

First kill all process locking the FS then unmount the FS finally extend the FS and mount again the FS

# fuser -ku /dev/vgXX/LVname
# umount /dev/vgXX/LVname 
# extendfs /mountpoint
# mount /mountpoint


DONE




Monday, 22 October 2012

Install Tomcat 7


CentOS 5.7 - Tomcat 7.0.27 - JDK 7u4


  • Install Java
  • Install Tomcat


1.Download JDK

http://www.oracle.com/technetwork/java/javase/downloads/index.html

jdk-7u4-linux-i586.tar.gz


2.Download Tomcat

http://tomcat.apache.org/index.html

apache-tomcat-7.0.27.tar.gz


3.Install Java

a.create /usr/java

# mkdir  /usr/java

b.extract jdk-7u4-linux-i586.tar.gz in it

# tar xzf jdk-7u4-linux-i586.tar.gz

c.set JAVA_HOME in  ~/.bashrc or ~/.bash_profile

JAVA_HOME=/usr/java/jdk1.7.0_04  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  

d.reload .bash_profile

# source .bash_profile


4.Install Tomcat

a.copy tomcat in /usr/share

cp /root/tomcat/apache-tomcat-7.0.27.tar.gz /usr/share

b.extract tomcat

cd /usr/share
tar xzf apache-tomcat-7.0.27.tar.gz


c.Run tomcat with tomcat user

groupadd tomcat
useradd -s /bin/bash -g tomcat tomcat
chown -Rf tomcat.tomcat /usr/share/apache-tomcat-7.0.27/

d.create a startup script

# cd /etc/init.d/

# vi tomcat

---------------------------------------------------------------------
#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/java/jdk1.7.0_04  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=/usr/share/apache-tomcat-7.0.27  
  
case $1 in  
start)  
/bin/su tomcat $CATALINA_HOME/bin/startup.sh  
;;   
stop)     
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh  
;;   
restart)  
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh  
/bin/su tomcat $CATALINA_HOME/bin/startup.sh  
;;   
esac      
exit 0  
---------------------------------------------------

e.Change file permission for execution

# chmod 755 tomcat

f.Configure tomcat to automatically start

# chkconfig --add tomcat  
# chkconfig --level 234 tomcat on 

g.Test the script

# service tomcat start
# service tomcat restart
# service tomcat stop

h.Check the logs

# more /usr/share/apache-tomcat-7.0.27/logs/catalina.out

i.Start tomcat and connect to web

# service tomcat start
# http://yourIPaddress:8080


l.Configure access to Tomcat Manager gui

# vi $CATALINA_HOME/conf/tomcat-users.xml

m.Manage Memory Usage Using JAVA_OPTS : set our inital heap size, Xms, and our maximum heap size, Xmx, to the same value of 128 Mb

# vi Catalina.sh

JAVA_OPTS="-Xms128m -Xmx128m" 


DONE