> php教程 > php手册 > php 连接oracle:php oracle

php 连接oracle:php oracle

WBOY
풀어 주다: 2016-06-21 08:51:48
원래의
1065명이 탐색했습니다.

are you ready to start using php to talk to an oracle database? let's walk through the steps required to install the oracle database, apache http server, and php as an apache module on windows. we will be using windows xp professional for this example.
software requirements:





















software version url
oracle database 10g express edition 10.2 http://www.oracle.com/technology/products/database/xe/
apache http server 2.0.58 http://httpd.apache.org/download.cgi
php hypertext processor 5.1.3 http://www.php.net/downloads.php

installing oracle
you have a choice here. you may either install the database locally on this windows machine, or you may decide to use an oracle server located on another machine on your network. if your database is remote, jump to the article on installing php and the oracle 10g instant client for linux and windows.
otherwise, if this is your first time with oracle, installing the oracle database 10g express edition only takes a few minutes. download the express edition (commonly known as "xe") self-extracting executable oraclexe.exe and simply double-click this file to run the installation wizard.
starting and stopping oracle
oracle xe will be running after installation. you can test it by opening your browser to the database home page http://localhost:8080/apex/. use the username "system" and the password you chose during installation.
note: you may need to replace "localhost" with the ip address 127.0.0.1 or your machine's dns name if you are behind a firewall or if localhost does not resolve for some other reason.
if you need to restart the database at any time use the start database and stop database items on the windows start menu.
don't forget to register for the free oracle xe forum by following the "forum registration" link on the database home page.
installing apache http server
the easiest way to install apache on windows is to download the microsoft windows installer apache_2.0.58-win32-x86-no_ssl.msi package from apache windows binaries. to install on this machine, double-click the file and follow the wizards. i chose to install "for all users, on port 80" because the "only for the current user" alternative would clash with oracle xe's default port 8080. i installed apache under c:\program files\apache group, however any other directory will also work.
starting and stopping apache
as part of installation, the server will be started. you should now test on your machine by opening your web browser to http://localhost/
your system tray has an apache monitor control that makes it easy to stop and re-start the http server when needed. alternatively use the apache options added to your windows start menu.
installing php
download the php 5.1.3 zip package (not the "installer" package, which does not contain necessary extensions). you will notice that the installation instructions here are very similar to those found in the install.txt file contained within the php archive that you downloaded. feel free to use that as a guide; the instructions here are just a subset of the information it contains.
installation steps
uncompress the php package to a directory called "c:\php-5.1.3-win32".
copy php.ini-recommended to c:\program files\apache group\apache2\conf\php.ini
edit php.ini and perform the following:
change extension_dir to "c:\php-5.1.3-win32\ext", which is the directory containing php_oci8.dll and the other php extensions.
uncomment (remove the semicolon from the beginning of the line) the line extension=php_oci8.dll
for testing it is helpful to set display_errors to on so you see any problems in your code.
edit the file httpd.conf and add the following lines. make sure to use forward slashes '/' instead of back slashes '\':
#
# this will load the php module into apache
#
loadmodule php5_module c:/php-5.1.3-win32/php5apache2.dll
#
# this next section will call php for .php, .phtml, and .phps files
#
addtype application/x-httpd-php .php
addtype application/x-httpd-php .phtml
addtype application/x-httpd-php-source .phps
#
# this is the directory containing php.ini
#
phpinidir "c:/program files/apache group/apache2/conf"
restart the apache http server
you must now restart the apache server so that you can test your php installation. use the start menu option to start apache. this opens a console window showing any error messages. they may also be recorded in c:\program files\apache group\apache2\logs\error.log
if you have errors, double check your httpd.conf and php.ini and correct any problems.
testing apache and php with oracle
testing php with oracle is easy. you simply need to place a php file into your htdocs directory; normally c:\program files\apache group\apache2\htdocs.
here are two files, the first is used to test basic php installation. open it in a browser with http://localhost/phpinfo.php. if php is installed you should see a large page full of php configuration information.
phpinfo.php
phpinfo();
?>
check there is a section titled "oci8". 本文链接http://www.cxybl.com/html/wlbc/Php/20120531/27129.html



관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿