Install Oracle, PHP, and Apache on Linux

Source: Internet
Author: User

Are you ready to start talking to the Oracle database using PHP? The following describes how to install the Oracle database, Apache httpd server, and PHP on Linux as an Apache module. In this example, we will use Windows 2000

Software requirements

Software Version URL
Oracle RDBMS 9.2 Http://www.oracle.com/technology/global/cn/software/products/oracle9i/index.html
Apache httpd server 1.3.28 Http://httpd.apache.org/download.cgi
Php-PHP hypertext Processor 4.3.2 Http://www.php.net/downloads.php

Install Oracle

You have two options. You can either locally install the database on a Windows machine or decide to use the Oracle server on another machine on your network. If your database is remote, you only need to install the Oracle client on this machine. If your database is local, you need to install the Complete Oracle RDBMS server.

 

Install Apache HTTP Server

The simplest way to install Apache on Windows is to download the Microsoft software Installer (MSI) package of Apache HTTP Server, suchApache_1.3.28-win32-x86-no_src.msi. To install the machine, double-click the file and follow the instructions in the Wizard. I have installed Apache in the D:/apachehttp directory, but any directory (even in the default location of program files) works normally.

Start Apache

You can start Apache from command shell or install Apache as a service. During the test, I usually start and terminate Apache from the command line.

D:/ApacheHTTPD/Apache>start Apache.exe

You will also see the following message displayed when the new command line shell is opened:

 

Apache/1.3.28 (Win32) PHP/4.3.2 running...

Now you should test whether Apache can be started and run properly on the machine by opening your web browser to connect to the URL http: // localhost

 

Note: If you use a firewall or if localhost cannot be resolved for some reason, you may need to replace "localhost" with the DNS name of the machine.

Now you should terminate Apache HTTP Server. The following command is used:

D:/apachehttpd/Apache> Start apache.exe-K stop

Install PHP

The installation instructions here are similar to those in the install.txt file in the PHP file you downloaded. Use it as a guide. The description here is only a subset of the information contained in this document. Now that Apache has been installed successfully, you can install PHP.

Installation Steps

  1. Decompress the PHP package to your root directory, which will create a file similar"D:/php-4.3.2"Directory.
  2. SetPHP. ini-DistCopy% SystemRoot %/PHP. ini
  3. Edit% SystemRoot %/PHP. iniAnd perform the following operations:
    1. Uncomment the following line (delete the semicolon starting with this line ):Extension = php_oci8.dll
    2. SetDoc_rootSet it to the htdocs directory of Apache (for example:D:/apachehttpd/Apache/htdocs)
  4. Copy the following files to includeApache.exeApplication directory:
    1. D:/php-4.3.2/php4ts. dll
    2. D:/php-4.3.2/extensions/php_oci8.dll
  5. Edit FileHttpd. confAnd add the following lines:

Note:

  1. Replace D:/php-4.3.2 with your PHP installation location
  2. Use the slash '/' to replace the backslash '/'
## This will load the PHP module into Apache.Put this line with other LoadModule lines.#LoadModule php4_module d:/php-4.3.2/sapi/php4apache.dll
## Add this with the other AddModule lines.#AddModule mod_php4.c## This next section will add a handler for .php files, put it with other IfModule lines.#

AddType application/x-httpd-php .php

Start Oracle Database

 

Starting Oracle database and Oracle listener involves using the Services applet in the Management Tools Folder under the control panel. Two services must be started. Start them now.

  1. Oracleserviceorcl
  2. Oracleorahome92tnslistener

Note: service names may be different, but they are extremely similar and it is easy to determine which service is used. Search for "oracleserivce {oracle_sid}" and "Oracle {ORACLE_HOME} tnslistener"

 

Start Apache HTTP Server

Now you must restart Apache server to test PHP installation. Start Apache as before and check whether there are any error messages. If you receive an error message when starting Apache, you can delete it.Apache.exe"Start". You need to open the second command shell to call the close command.

D:/ApacheHTTPD/Apache>Apache.exeApache/1.3.28 (Win32) PHP/4.3.2 running...

If you receive any error, check httpd. conf carefully and correct the error.

 

 

Use Oracle to test Apache and PHP

It is easy to test PHP using Oracle. You only need to put a PHP file into the htdocs directory./Usr/local/Apache/htdocs.

There are two files. The first one is used to test the basic PHP installation. If PHP is installed, you should see a large page with all the above PHP configuration information. The second file displays part of the ename and Sal columns of the EMP table in Scott mode. This requires the Scott mode to be installed, otherwise you will need to change the page.

Phptest. php

 

>

Oci8test. php

 

NOTE: If your Oracle database is not local, edit the second line as follows-MyDatabaseTNSEntryNameReplace the TNS entry for your server.$ Db_conn = ocilogon ("Scott", "Tiger", "mydatabasetnsentryname ");

 

Echo"

/N ";} echo"

         echo "
$ ". Number_format ($ results [" Sal "] [$ I], 2 ).
Number of rows:

Echo"
If you see data, then it works!
/N ";?>

Conclusion

You have installed and configured Oracle database, Apache httpd server, and PHP. Now, you can start learning PHP or writing PHP applications on the Oracle platform.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.