Centos 5.6 Oracle10g + apache2 + php5.3 安裝手記
##php + mysql + oracle
##perl + mysql + oracle
#安裝套件確認
確認以下套件是否安裝!
若未安裝可用 yum 進行安裝
yum install pdksh
yum install libXp
yum install libXpm-devel
#OS 環境設定
#建立帳號及Group
groupadd -g501 oinstall
groupadd -g500 dba
useradd -g oinstall -G dba oracle
chown oracle.oinstall -R /oracle
##修改參數
vi /etc/sysctl.conf
#oracle
kernel.sem=250 32000 100 128
fs.file-max=65536
net.ipv4.ip_local_port_range=1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
#令參數生效
sysctl -p
##安裝 JDK
下載並安裝
http://www.oracle.com/technetwork/java/javase/downloads/index.html
我是安裝在 /opt/jdk1.6.0_23 並在 /opt/ 下建立一個 java 連結
# ln –s /opt/jdk1.6.0_23 /opt/java 方便使用
./jdk-6u23-linux-i586.bin
mv jdk1.6.0_23/ /opt/
cd /opt/
ln -s jdk1.6.0_23 java
/opt/java/bin/java -version
會顯示目前 java 版本表示OK
#編輯一個環境變數檔
vi oracle.env
export DBNAME=testora.test.com.tw
PATH=/opt/java/bin:/ap/bin:/oracle/app/oracle/product/10.2.0/db_1/bin:$PATH
export ORACLE_BASE=/oracle/app
export TMP=/tmp
export TEMP=/tmp
export TMPDIR=/tmp
export DISPLAY=:0.0
export ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1/
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/opmn/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/network/lib:/$ORACLE_HOME/lib:/$ORACLE_HOME/lib32:/usr/lib64
NLS_DATE_FORMAT=YYYY/MM/DD;export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.AL32UTF8;export NLS_LANG
export ORACLE_TERM=vt220
#資料庫軟體安裝
##install oracle database
cpio -idvm < 10201_database_linux_x86_64.cpio
cd database/
./runinstall
安裝過程會出現作業系統版本不符的問題而無法安裝!
處理方式有二:
(1) 修改 /etc/redhat-release 中的文字,改為 Red Hat Enterprise Linux AS release 4
(2) ./runinstall –ignoreSysPrereqs #跳過 OS VERSION CHECK
安裝時先不要 create database ,請選擇僅安裝資料庫軟件,如此是為了方便由 10.2.0.1 升級至 10.2.0.4
若順利的話會提示以 root 執行以下二個程序
/oracle/app/oraInventory/orainstRoot.sh
/oracle/app/oracle/product/10.2.0/db_1/root.sh
##升級至 10.2.0.4
##patch to 10.2.0.4 將 oracle
unzip p6810189_10204_Linux-x86-64.zip
cd disk1
./runinstall
/oracle/app/oracle/product/10.2.0/db_1/root.sh
### 若要建立新的資料庫可使用 dbca 指令
### 建立 tnsnames.ora
Vi $ORACLE_HOME/network/admin/tnsnames.conf
TESTORA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.10 )(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = ORCL)
)
)
##create tablespace
CREATE TABLESPACE "DATA_DB"
NOLOGGING
DATAFILE '/oracle/data/data_db.dbf' SIZE 128M REUSE AUTOEXTEND
ON NEXT 4096K MAXSIZE 1024M EXTENT MANAGEMENT LOCAL
/
##create user
create user testuser identified by XXX default tablespace data_db temporary tablespace temp;
grant connect,resource to testuser;
##create table
create table empl (
employee_no CHAR (5) NOT NULL,
name VARCHAR2 (12)
)
storage ( initial 128K next 128K )
tablespace data_db
;
alter table empl add constraint emp_PK PRIMARY KEY (employee_no) using index tablespace data_db;
### ORACLE資料庫軟件安裝完成
##MYSQL僅安裝軟件
tar -zxvf mysql-5.0.27.tar.gz
cd mysql-5.0.27
export CFLAGS=-fPIC
cd ..
rm -rf mysql-5.0.27
rm -f mysql-5.0.27.tar.gz
tar -zxvf mysql-4.1.21.tar.gz
cd mysql-4.1.21
./configure --without-server --prefix=/usr/local/mysql --enable-thread-safe-client
make
make install
##安裝 Apache2 & PHP
## PHP 安裝前的準備
##http://libpng.sourceforge.net/index.html
cd /usr/local/src
tar jxvf /tmp/libpng-1.4.1.tar.bz2
cd libpng-1.4.1/
cd ..
mv libpng-1.4.1/ libpng
cd libpng
cp scripts/makefile.linux Makefile
make;make install
# http://www.ijg.org/
cd /usr/local/src
tar zxvf /tmp/jpegsrc.v8.tar.gz
mv jpeg-8 libjpeg-8
cd libjpeg-8
./configure --enable-shared --enable-static
make
mkdir -p /usr/local/man/man1
make install
cp -r ./.libs lib
cd /usr/local/src
# http://sourceforge.net/projects/freetype/files/freetype2/
tar jxvf /setup/php/freetype-2.3.12.tar.bz2
mv freetype-2.3.12 freetype2
cd freetype2
./configure
make;make install
## http://www.boutell.com/gd/
tar jxvf /setup/php/gd-2.0.36RC1.tar.bz2
mv gd-2.0.36RC1 gd2
cd gd2
./configure --with-png=../libpng --with-freetype=../freetype2
vi gd_png.c
##libpng-1.4以後,make若碰到./.libs/libgd.so: undefined reference to `png_check_sig'
修改gd_png.c
將if (!png_check_sig (sig, 8))改成if (png_sig_cmp (sig, 0, 8))解決
make
make install
cp -r ./.libs lib
tar -jxvf /setup/php/php-5.3.4.tar.bz2
cd php-5.3.4/
./configure --with-pdo-oci=/oracle/app/oracle/product/10.2.0/db_1
--with-mysql=/usr/local/mysql
--with-apxs2=/ap/web/bin/apxs --with-config-file-path=/ap/web/conf --with-zlib --enable-mbstring=all --with-bz2 --with-ldap --enable-sigchild --enable-inline-optimization --enable-static --disable-debug --with-gettext --with-gd=/usr/local/src/gd2 --with-jpeg-dir=/usr/local/src/libjpeg-8 --with-png-dir=/usr/local/src/libpng --with-freetype-dir=/usr/local/src/freetype2 --disable-rpath --with-xpm-dir=/usr/lib64
make
##修改 /ap/web/build/libtool
# if test "$inst_prefix_dir" = "$destdir"; then
# $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
# exit $EXIT_FAILURE
# fi
## 否則make install 時會出現錯誤
make install
###PHP + oracle TEST
##vi /php/opendb.inc
<?
$dbh = new PDO("oci:dbname=ORCL", "", "PASSWD");
?>
##vi test.php
<?
require_once("/php/opendb.inc");
$sql="select * from tab";
$stmt=$dbh->prepare("$sql");
$stmt->execute()||die("mug_plan,mfg 讀檔錯誤");
while(list($tab_list)=$stmt->fetch()) {
echo “$tab_list\n”;
}
?>
##應該會顯示目前user 下的table 或 view list
###Perl + oracle + mysql
下載http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.616.tar.gz
http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.28.tar.gz
##DBI
cd /tmp
tar -zxvf DBI-1.616.tar.gz
cd DBI-1.616
perl ./Makefile.PL
make
make test
make install
cd ../
#DBD-ORACLE
. oracle.env :請看前面說明
tar -xvf DBD-Oracle-1.28.tar
cd DBD-Oracle-1.28
perl ./Makefile.PL
make
make install
##Perl + MYSQL -- DBD-mysql
http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.019.tar.gz
tar -zxvf DBD-mysql-2.9007.tar.gz
cd DBD-mysql-2.9007
perl Makefile.PL \
--libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz" \
--cflags=-I/usr/local/mysql/include/mysql
make
make install
##Perl + ORACLE TEST
##vi oracle.pl
sub opendb {
DBI->connect( "dbi:Oracle:orcl", 'testuser','XXXX',) || die "Database connection not made: $DBI::errstr";
}
##vi test.pl
#!/usr/bin/perl
use DBI;
require "oracle.pl";
$db=opendb();
$sql=$db->prepare("select * from empl ");
$sql->execute();
print "Oracle\n------------------------\n";
while(($employee_no,$name)=$sql->fetchrow_array()){
print "$employee_no,$name \n";
}
##perl + mysql test
#vi mysql.pl
sub myopendb { DBI->connect('DBI:mysql:database=public;host=10.0.0.11;port=3306','username','passwd') };
#vi testmy.pl
require "mysql.pl";
$mydb=myopendb();
$sql = “update …”;
$mysql = $mydb->prepare("$sql");
$mysql->execute();
$err = $mydb -> errstr;
後記:
請參考另一份件 http://jason0615.pixnet.net/blog/post/68611791 為你的 web server 加上流量壓縮功能
留言列表