forked from teddysun/lamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoci8_oracle11g.sh
124 lines (115 loc) · 3.58 KB
/
oci8_oracle11g.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
#=========================================================#
# System Required: CentOS / RedHat / Fedora #
# Description: OCI8 for LAMP #
# Author: Teddysun <[email protected]> #
# Visit: https://lamp.sh #
#=========================================================#
if [[ $EUID -ne 0 ]]; then
echo "Error:This script must be run as root!" 1>&2
exit 1
fi
cur_dir=`pwd`
OCIVersion='oci8-2.0.10'
# get PHP version
PHP_VER=$(php -r 'echo PHP_VERSION;' 2>/dev/null | awk -F. '{print $1$2}')
if [ $? -ne 0 ] || [[ -z $PHP_VER ]]; then
echo "Error: PHP looks like not installed, please check it and try again."
exit 1
fi
# get PHP extensions date
if [ $PHP_VER -eq 53 ]; then
extDate='20090626'
elif [ $PHP_VER -eq 54 ]; then
extDate='20100525'
elif [ $PHP_VER -eq 55 ]; then
extDate='20121212'
elif [ $PHP_VER -eq 56 ]; then
extDate='20131226'
elif [ $PHP_VER -eq 70 ]; then
extDate='20151012'
OCIVersion='oci8-2.1.0'
fi
# Download files.
function download_files(){
if [ -s $1 ]; then
echo "$1 [found]"
else
echo "$1 not found!!!download now......"
if ! wget -c -t3 http://lamp.teddysun.com/files/$1; then
echo "Failed to download $1, please download it to ${cur_dir} directory manually and retry."
exit 1
fi
fi
}
# Install oracle instantclient11.2
function install_instant(){
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
else
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.i386.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.i386.rpm
fi
}
# Recompile PHP extension oci8
function compile_oci8(){
echo "oci8 install start..."
cd $cur_dir/untar/$OCIVersion
export PHP_PREFIX="/usr/local/php"
$PHP_PREFIX/bin/phpize
./configure --with-php-config=$PHP_PREFIX/bin/php-config
make && make install
if [ ! -f $PHP_PREFIX/php.d/oci8.ini ]; then
echo "OCI8 configuration not found, create it!"
cat > $PHP_PREFIX/php.d/oci8.ini<<-EOF
[OCI8]
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-${extDate}/oci8.so
oci8.privileged_connect = Off
oci8.max_persistent = -1
oci8.persistent_timeout = -1
oci8.ping_interval = 60
oci8.connection_class =
oci8.events = Off
oci8.statement_cache_size = 20
oci8.default_prefetch = 100
oci8.old_oci_close_semantics = Off
EOF
fi
# Clean up
cd $cur_dir
rm -rf $cur_dir/untar/
rm -f $cur_dir/oracle-*.rpm
rm -f $cur_dir/${OCIVersion}.tgz
# Restart httpd service
/etc/init.d/httpd restart
echo "oci8 install completed..."
exit
}
# Install oci8
function install_oci8(){
download_files "${OCIVersion}.tgz"
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
download_files "oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm"
download_files "oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm"
else
download_files "oracle-instantclient11.2-basic-11.2.0.4.0-1.i386.rpm"
download_files "oracle-instantclient11.2-devel-11.2.0.4.0-1.i386.rpm"
fi
if [ ! -d $cur_dir/untar/ ]; then
mkdir -p $cur_dir/untar/
fi
tar xzf $OCIVersion.tgz -C $cur_dir/untar/
install_instant
compile_oci8
}
action=$1
[ -z $1 ] && action=install
case "$action" in
install)
install_oci8
;;
*)
echo "Usage: `basename $0` {install}"
;;
esac