• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php 连接oracle:php oracle_php

php 搞代码 3年前 (2018-06-21) 136次浏览 已收录 0个评论

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:

http://www.gaodaima.com/?p=50131php 连接oracle:php oracle_php

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
<?php
phpinfo();
?>
check there is a section titled “oci8”. 本文链接http://www.cxybl.com/html/wlbc/Php/20120531/27129.html

欢迎大家阅读《php 连接oracle:php oracle_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址