Manual start for Apache, PHP and ORACLE

Manual quick start for Apache, PHP and ORACLE configuration in Windows OS


Once upon a time, in one of the class I attended, the lecturer while tinkering with the laptop, ask us in an off handed manner, if we know why the oracle express she installed cannot be connected to her program. It hit me then that several years back I had had hard time to do that, and just recently “enlighten” that different with other databases, like mysql when you installed its dbms, you can connect it right away from php, this oracle in order for it to be able to connect to the program need to have the client installed in order for php to be able to recognize the oracle.
Now for example, I need to rig this spec:
- windows xp.
- apache+php webserver.
- oracle 8i database is located in remote machine.
so let’s start configuring:
1. INSTALLATION:
WEBSERVER: APACHE
now the with the windows ready we need to install apache. unfortunately, for windows by the time I write this only 2.2.22 is the latest available, the 2.4 is for unix platform only. so to make it easy, just download the binary apache from:
http://httpd.apache.org/download.cgi#apache24
now just run and install the apache, no complicated step just follow the installation instruction like any other programs do.
or if you want a little bit hassle you can use the 2.4 version, but it is not the msi, so you must do manual configuration before it would work, here is the download link:
http://www.apachelounge.com/download/
but just a side note the apache created using visual studio, so you need to install the dependency, microsoft visual C++ redistributable package.
in apache download page you’ll see V6 V9 V10 version, it is representing the version of visual studio the program made: v6 is in legacy mode, v9 is using visual studio 2008 and v10 is using visual studio 2010, the binary version (msi, they’ll try to install the dependency automatically, but if you download the zip version then you need to download and install it separately, like for the v10 version (apache 2.4 v10):
http://www.microsoft.com/en-us/download/confirmation.aspx?id=8328
the above is for 32 bit operating system, if you have 64 bit operating system you need to install the 64 bit redistributable package.
SERVER SIDE PROGRAM: PHP
After that you download the php program from here:
http://windows.php.net/download/
pick the zip or 7zip download.
here you pick the thread-safe version because you’ll install it in apache, for IIS web server use non-thread safe version.
also you’ll see v6 v9 version, so again, you’ll need to install the redistribution package matched with the version you downloaded.
DATABASE CONNECTION: ORACLE INSTANT CLIENT
You can download from here:
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
but in order for you to download it you must create account first (free).
pick 10g version if you work with oracle database 8i to 10g version, the instant client 11 is not supporting the 8i version database.
and since it has dependency, you need to add these to files the where you extract the oracle instant client:
mfc71.dll
msvcr71.dll
2. CONFIGURATION
now that all are in compressed file, to make it easy, just create a folder such as “webserver”, then extract apache, php and oracle client each in separated folder.
open the httpd.conf and edit the values if needed:
ServerRoot “c:/webserver/apache2.4″
This is the folder where you extracted the apache program
Listen 80
This is the port you’re listening to, 80 is the default http port, you can assign other port if for example you want to have multiple web server in your system (like IIS or another apache version).
you can tinker with other option as you please, but make sure the option that configuring the folder path match with where you extract it.
now for apache able to understand php, you need to add a couple of lines in httpd.conf:
LoadModule php5_module “C:/webserver/php5.4.4/php5apache2_4.dll”
AddType application/x-httpd-php .php
PHPIniDir “C:/webserver/php5.4.4″
But the php doesn’t include the apache 2.4 version, so you need to download it in apache website (the same page where you download apache 2.4.
now save the httpd.conf file.
only one step left, configuring the windows environment (right click my computer icon> use properties>go to advanced tab and click environment button.
In system environment, add in path value the php and oracle instant client folder, like for example:
C:\webserver\php5.4.4;C:\webserver\php5.4.4\ext;C:\webserver\instantclient_10_2
add variable ORACLE_HOME and add to its value the folder of oracle instant client, just like above.
now to run apache web server it is easier if you add the apache in windows service, open the command prompt, go the apache bin directory (where the httpd.exe reside) and type this:
httpd.exe -k install
to uninstall the service:
httpd.exe -k uninstall
to start the service:
httpd.exe -k start
to stop the service:
httpd.exe -k stop
Now that you successfully running apache, you can start to configure the php.ini so it can connect to oracle database, to enable the option just remove the semi colon from this value:
extension=php_oci8.dll
and look for this tag: [OCI8], below that tag you can configure the oracle connection properties.
Back to oracle, create a file named tnsnames.ora to map your oracle database, the configuration is like this:
[tns name, it is up to you how to name
it] =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = the name of the host or its IP address)
(Port = 1521)
)
)
(CONNECT_DATA = (SID = the name of the database service)
)
)

Now to test the connection, go to htdocs folder inside apache, create file named index.php, and inside you add code: <?php phpinfo(); ?>
if successful you can see in the page of the php active configuration.
to check to oracle connection, you can use this code:
<?PHP
if ($conn=oci_connect([database user name], [database password], [database tns name])) //if you use tnsnames.ora to map your oracle database
{ echo “connection to database successful”; }
else
{ echo “connection failed, check user name, password and database name in tnsnames.ora file”;}
?>
OK that’s all for quick start, there are tens if not hundred other possible configurations for each of the web server, php and oracle client options.







No comments:

ORA-00059: Maximum Number Of DB_FILES Exceeded in 19C database

When I am adding datafile to my 19C database facing the below error. SQL> alter tablespace DATA  add datafile '/u01/data/data15.dbf...