Traditional Way for Installing PHP(OCI enabled) + Apache on Linux
Actually, the traditional way is compiling source from scratch. Below is information from OTN:
Installing Apache, PHP, JDeveloper, and the PHP Extension on Linux
Apache 1.3
- Login as Oracle user.
- Copy/download apache_1.3.31.tar.gz
- tar -zxf apache_1.3.31.tar.gz
- cd apache_1.3.31
- Configure:
./configure --enable-module=so --prefix=$HOME/apache --with-port=8888
- Build: make
- Install: make install
- Start Apache: $HOME/apache/bin/apachectl start
- Go to a browser and check that http://localhost:8888/ returns the default "Powered by Apache" page.
- Stop Apache: $HOME/apache/bin/apachectl stop
PHP 4.3
Before you proceed, make sure that the packages "bison" and "flex" are installed, because PHP needs them.
- Copy/download php-4.3.9.tar.gz
- tar -zxf php-4.3.9.tar.gz
- Set environment variable ORACLE_SID
- Set environment variable ORACLE_HOME
- Set environment variable LD_LIBRARY_PATH to $ORACLE_HOME/lib:${LD_LIBRARY_PATH}
- Configure (make sure to enter this as one long line):
./configure --prefix=$HOME/php --with-apxs=$HOME/apache/bin/apxs --with-config-file-path=$HOME/apache/conf --with-oci8=$ORACLE_HOME --enable-sigchild
- Build: make
- Install: Make install
- cp php.ini-recommended $HOME/apache/conf/php.ini
- Edit $HOME/apache/conf/httpd.conf and add:
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
- Restart Apache
- create $HOME/apache/htdocs/phpinfo.php as:
1: <?php2: phpinfo();3: ?> - In a browser load http://localhost:8888/phpinfo.php. Check that the OCI module is listed.
Following exactly the steps above, you will get PHP + Apache running on Linux.
NOTES:–with-apxs in step 6 when installing PHP is important, this let the installation process to compile the OCI library for the apache and make it available to Apache.
For testing the OCI support in PHP, create $HOME/apache/htdocs/connect.php as:
1: <?php
2:
3: define('ORA_CON_UN', 'scott');
4: define('ORA_CON_PW', 'tiger');
5: define('ORA_CON_DB', 'MYSID');
6:
7: $conn = OCILogon(ORA_CON_UN, ORA_CON_PW , ORA_CON_DB );
8:
9: if (!$conn) {
10: exit;
11: }
12:
13: echo OCIServerVersion($conn) ."<br>\n";
14: echo "Connected as ".ORA_CON_UN."</br>\n";
15: echo date('Y-m-d H:i:s')."<br><br>\n";
16:
17: $query = 'select * from emp';
18:
19: $stid = OCIParse($conn, $query);
20: OCIExecute($stid, OCI_DEFAULT);
21: print "<table border='1'>\n";
22: while ($succ = OCIFetchInto($stid, $row, OCI_RETURN_NULLS)) {
23: print "<tr>\n";
24: foreach ($row as $item) {
25: print '<td>';
26: print isset($item)?htmlentities($item):'?';
27: print "</td>\n";
28: }
29: print "</tr>\n";
30: }
31: print "</table>\n";
32:
33: OCILogoff($conn);
34: ?>
In a browser load http://localhost:8888/connect.php. Check that the OCI driver works.
