歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Linux+Apache+Php+Oracle 基礎環境搭建

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代碼
#測試代碼轉載於:
http://blog.chinaunix.net/uid-20438355-id-61148.html
$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 "連接失敗"; 
} 
?>

 


Copyright © Linux教程網 All Rights Reserved