Linux+Apache+Php+Oracle 基础环境搭建

时间:2021-07-30 03:47:45
前言:
          
           不能保证100%一次通过,每个系统都会或多或少有区别,如果缺少某些依赖包的话,还请见谅
 
1、安装Apache需要编译安装的包,各官方网站下载
 
Pcre、Apr、Apr-Util
 
2、编译安装Apache:
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-mpm=prefork --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atormics --enable-mods-shared=most --enable-so
 
 
3、安装PHP需要安装的包
 
(1)YUM方式安装,163的源
 
yum install libxml2-devel curl-devel libpng-devel freetype-devel libjpeg-devel -y
 
(2)编译方式安装,各软件官网下载
 
Libiconv、libmcrypt
 
(3)RPM方式安装,从ORACLE官网下载
 
oracle-instantclient11.2-basic
oracle-instantclient11.2-devel
oracle-instantclient11.2-sqlplus
 
 
4、需要更新的环境变量
 
export ORACLE_HOME=/usr/lib/oracle/11.2/client64   #连接ORACLE会话的位置
export LD_LIBRARY_PATH=$ORACLE_HOME/lib           #LIB的位置
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8     #让中文显示非乱码
 
 
5、在/etc/hosts中添加主机名
127.0.0.1 BJ-NQ-V-xxx
 
 
6、编译安装PHP
 
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --enable-sockets --with-gettext --with-oci8=instantclient --with-pdo-oci --with-iconv=/usr/local/libiconv --enable-opcache=no
 
 
7、测试PHP连通ORACLE代码
#测试代码转载于:

$db_server = "localhost";  #ORACLE的IP
$db_user = "atyu30";        #ORACLE的用户名
$db_pass = "atyu30";       #ORACLE的密码
$db_sid = "atyu30";          #ORACLE的SID
$dbconn=OCILogon($db_user,$db_pass,"(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=127.0.0.1)(PORT = 1521))(CONNECT_DATA =(SID=$db_sid)))");

if($dbconn!=false) 

echo "连接"; 
echo "DB服务器:".$db_server;
echo "用户:".$db_user;
echo "口令:".$db_pass;
echo "SID:".$db_sid;
echo "成功\n";
if(OCILogOff($dbconn)==true) 

echo "关闭连接成功!";


else 

echo "连接失败"; 

?>