Shell Script To Build And Install PHP Xcache Opcode Cache Extension

#!/bin/bash
# A simple shell to build and install xcache Opcode Cache as module for 
# PHP under # CentOS, Fedora and RHEL / Redhat Enterprise Linux servers.
# ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/>
# (c) 2008 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Home page: http://www.hardened-php.net
# Last updated: 15/June/2010
# ----------------------------------------------------------------------------
# Home page: http://xcache.lighttpd.net
VERSION="${2:-1.3.0}"
URL="http://xcache.lighttpd.net/pub/Releases/${VERSION}/xcache-${VERSION}.tar.gz"
vURL="http://xcache.lighttpd.net/pub/Releases/${VERSION}/xcache-${VERSION}.tar.gz.md5.txt"
FILE="${URL##*/}"
vFILE="${vURL##*/}"
DLHOME="/opt"
SOFTWARE="xcache"
DEST="${FILE%.tar.gz}"
 
[[ $(id -u) -ne 0 ]] && { echo "$0: You must be root user to run this script. Run it as 'sudo $0'"; exit 1; }
 
getsoftware(){
	wget $URL -O "${DLHOME}/$FILE"
        wget $vURL -O "${DLHOME}/$vFILE"
}
 
buildsoftware(){
        [[ ! -f "${DLHOME}/$FILE" ]] &&  getsoftware
        cd "${DLHOME}"
        tar -zxvf $FILE
        cd "$DEST"
	phpize --clean && ./configure --enable-xcache && make && read -p "Update in $SOFTWARE [Y/n] ? " answer
	shopt -s nocasematch
	[[ $answer =~ y|es  ]] &&  make install
	shopt -u nocasematch
}
 
verifyfile(){
        cd "${DLHOME}"
	[ ! -f ${DLHOME}/$vFILE ] && getsoftware
	md5sum -c $vFILE
	read -p "Contine to build [Y/n] ? " answer
	shopt -s nocasematch
	case "$answer" in
		y|yes) buildsoftware;;
		*) echo "";
	esac
	shopt -u nocasematch
}
 
case "$1" in
    download) 
	getsoftware 
        ;;
    build) 
	verifyfile
	;;
    verify)
	verifyfile
	;;	
    *) echo "Usage: $0 {download|verify|build|upgrade} version"
esac
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
CategoryList of Unix and Linux commands
File Management cat
Firewall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.