Linux + Apache + Php + Oracle Basic Environment setup, apacheoracle
Every system may be more or less different if it fails to pass the code 100% at a time. If some dependent packages are missing, please forgive me. 1. To install Apache, compile and install the packages, download Pcre, Apr, Apr-Util from various official websites 2. Compile and install Apache :. /configure -- prefix =/usr/local/apache -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util --- 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. package to be installed for PHP installation (1) YUM installation, 163 source yum install libxml2-devel curl-devel libpng-devel freetype-devel libjpeg-devel-y (2) Build method installation, download the Libiconv and libmcrypt (3) RPM installation methods from various software official websites, download the oracle-instantclient11.2-basicoracle-instantclient11.2-develoracle-instantclient11.2-sqlplus from the ORACLE official website 4, the environment variable to be updated export ORACLE_HOME =/usr/lib/oracle/11.2/client64 # connection ORACLE session location export LD_LIBRARY_PATH = $ ORACLE_HOME/lib # LIB location export NLS_LANG = AMERICAN_AMERICA.AL32UTF8 # Show non-garbled characters in Chinese. 5. Add the host name 127.0.0.1 BJ-NQ-V-xxx in/etc/hosts. 6. Compile and install 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. Test the PHP connection to ORACLE Code # The test code is reproduced in: http://blog.chinaunix.net/uid-20438355-id-61148.html
$ Db_server = "localhost"; # oracle ip Address
$ Db_user = "atyu30"; # ORACLE user name
$ Db_pass = "atyu30"; # ORACLE Password
$ Db_sid = "atyu30"; # SID of ORACLE
$ 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 "Connect ";
Echo "DB server:". $ db_server;
Echo "User:". $ db_user;
Echo "Password:". $ db_pass;
Echo "SID:". $ db_sid;
Echo "Success \ n ";
If (OCILogOff ($ dbconn) = true)
{
Echo "the connection is closed successfully! ";
}
}
Else
{
Echo "connection failed ";
}
?>