OTN's Oracle & PHP Installguide - for Developer CD v2 (B18183-01) ---------------------------------------------------------------- Installing Oracle 10g (10.1.0.3), Apache(2.0.54), PHP(5.0.4), and Oracle JDeveloper (10.1.2) with the php-addin_1.2 on SLES9 *** This guide for test purposes only - not production *** Installing Oracle 10g Database on SLES9 -------------------------------------- Boot from CDROM - F3 function : SLES9 CD1 disk New Installation Accept all defaults - Copies contents from Disk 1&2 then reboots + Set Root Password Use detected network configuration + skip Internet test Use detected service configuration + Change authentication method to Local (/etc/passwd) + Set up local user eg. todd/welcome ;-) Use detected hardware configuration As Root user System > YAST - Yet Another Setup Tool Use "Software > Install and Remove Software" -------------------------------------------- to install gcc, orarun, openmotif, mozilla, flex and bison: Search gcc /cpp The GCC Preprocessor /gcc The GNU C Compiler and Support Files /gcc-c++ The GNU C++ Compiler /libgcc C Compiler runtime library Check Dependencies x Autocheck /glibc -devel /libstdc++ -devel Search orarun /orarun Environment for running Oracle products Check Dependencies x Autocheck /libaio -devel dev files for async I/O Use the same technique to install /openmotif -- needed for installing 10g DB /mozilla -- web browser to use with EM to manage DB /flex Fast Lexical Analyzer Generator (ver 2.5.4a-293.1) /bison The GNU Parse Generator (ver 1.875-51.1) # flex & bison are needed to build PHP /libxml2 /libxml2-devel # libxml2 are needed to configure PHP5 /perl # perl 5.0.3 or later is needed for PHP5 Use "Security and Users > Edit and create users" ------------------------------------------------ shows local user 'todd' use 'set filter' to display the System Users highlight and edit the 'oracle' user that was created by the orarun package - change password - select detail and add oracle user to dba group - enable login shell by changing /bin/false to /bin/bash + In a root shell update Oracle's home directory and SID by editing: vi /etc/profile.d/oracle.sh ORACLE_SID=orcl # orarun sets the SID to mydb by default ORACLE_HOME=$ORACLE_BASE/product/10gR1 + Set the kernel parameters by running /usr/sbin/rcoracle start + Switch to oracle user # default home set by orarun is /opt/oracle + Insert Oracle 10g (10.1.0.3) CD My Computer > DVD > runInstaller - follow the installer instructions - use password mgmt to unlock DBuser scott & set password 'tiger' + open http://linux.site:5500/em in a browser or As root # vi /etc/oratab change :N to :Y # cp /etc/oratab /var/opt/oracle/oratab + This enables the oracle user to dbshut, dbstart and lsnrctl start Installing Apache, PHP, JDeveloper, and the PHP Extension on Linux ------------------------------------------------------------------ For the sake of simplicity, we recommend that you use the "oracle" user account to install. (You won't have to switch users at all this way.) $HOME = /opt/oracle. Apache 2.0.54 -- http://httpd.apache.org/ 1. Login as Oracle user. 2. Copy/download httpd-2.0.54.tar.gz (to $HOME) 3. tar -zxf httpd-2.0.54.tar.gz 4. cd httpd-2.0.54 5. Configure: ./configure --enable-so --prefix=$HOME/apache2 --with-port=8888 6. Build: make 7. Install: make install 8. Start Apache: $HOME/apache2/bin/apachectl start 9. Go to a browser and check that http://localhost:8888/ returns the default Apache page. 10. Stop Apache: $HOME/apache2/bin/apachectl stop PHP 5.0.4 -- http://www.php.net/downloads.php *** Make Sure 'flex' and 'bison' packages are installed *** 1. Copy/download php-5.0.4.tar.gz 2. tar -zxf php-5.0.4.tar.gz 3. Set ORACLE_SID & ORACLE_HOME environment variables 4. Set environment variable LD_LIBRARY_PATH to $ORACLE_HOME/lib:${LD_LIBRARY_PATH} #steps 3.and 4. will most likely have been done during the database install 5. cd php-5.0.4 6. Configure (make sure to enter this as one long line): ./configure --prefix=$HOME/php --with-apxs2=$HOME/apache2/bin/apxs --with-config-file-path=$HOME/apache2/conf --with-oci8=$ORACLE_HOME --enable-sigchild 7. Build: make 8. Install: Make install 9. cp php.ini-recommended $HOME/apache2/conf/php.ini 10. vi $HOME/apache2/conf/httpd.conf and add: AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 11. Restart Apache 12. vi $HOME/apache2/htdocs/phpinfo.php and insert the text: 13. In a browser load http://localhost:8888/phpinfo.php. Check that the OCI module is listed. 14. Stop Apache JDeveloper 10.1.2 (latest versions available at http://otn.oracle.com/java ) 1. Create an install directory -- mkdir $Home/jdev1012 2. Insert your "Oracle Developer CD - Java, Web Services, and PHP" disk (B18183-01). 3. All the software is in password zipped files locate the password by clicking on the 'Install Now!' button on the 'Start_Here.html' page and agree to the license. 4. Remember the password: '*******' 5. Copy jdev1012.zip to installdir -- cd $HOME/jdev1012 -- cp /media/dvd/JDev/jdev1012.zip . -- unzip -P ******* jdev1012.zip 6. Fix permissions: -- cd $HOME -- chmod -R g+r -- cd /jdev/bin -- chmod +x jdev 7. Run JDeveloper : -- ./jdev 8. Enter the full path to your JDK ( eg. /opt/oracle/product/10gR1/jdk). 9. Choose Yes to create the working directory. 10. Choose No to migrate existing data. 11. Navigate to Tools->Preferences->Web Browser and Proxy and set the "Browser Command Line" to your browser, e.g. /usr/bin/mozilla Note: You'll have to do steps 10-11 only once. create a desktop shortcut.. - rightclick on desktop 'Create New>File>Link to Application' - application command is /opt/oracle/jdev1012/jdev/bin/jdev PHP Extension for JDev1012 1. cd $HOME/jdev1012 2. cp /media/dvd/PHP/php-addin_1.2.zip . 3. unzip -P ******* php-addin_1.2.zip 4. mv php-addin.jar jdev/lib/ext -- moves the addin to JDev's extension library 3. Restart JDeveloper: 4. Navigate to Tools->Preferences->PHP and set the command line executable to /opt/oracle/php/bin/php Putting it Altogether --------------------- 1. If you didn't already unlock the database user "scott", run sqlplus system/ and do: alter user scott account unlock; exit 2. Run JDeveloper. 3. In the Applications Navigator select Applications. 4. Navigate to File->New. Expand the General node and select Workspaces. In the right hand pane select Workspace and click OK. 5. In the "Create Workspace" pane choose a new name: MyWS. Un-check Add a New Empty Project and click OK. 6. In The Applications Navigator, right click on your new workspace, MyWS. Choose New. 7. Expand the General node and select Projects. In the right hand pane select PHP Project and click OK. 8. In the PHP Project Wizard: 1. Choose a new name, MyP, and click Next. 2. Ignore the URL Mapping page and click Finish. 9. In the Applications Navigator, right click on MyP. Choose New. 10. Expand Web Tier and select PHP. In the right hand pane select PHP File and click OK. 11. Change the file name to myoci.php and click OK. 12. In the new file, insert the following code, changing "MYSID" to the actual SID (service name) of your database (eg.orcl). \n"; echo "Connected as ".ORA_CON_UN. "
\n"; echo date('Y-m-d H:i:s')."

\n"; $query = 'select * from emp'; $stid = OCIParse($conn, $query); OCIExecute($stid, OCI_DEFAULT); print "\n"; while ($succ = OCIFetchInto($stid, $row, OCI_RETURN_NULLS)) { print "\n"; foreach ($row as $item) { print '\n"; } print "\n"; } print "
'; print isset($item)?htmlentities($item):' '; print "
\n"; OCILogoff($conn); ?> 13.When JDeveloper "runs" this file, it will start up your browser with an "http://" URL associated with the file. Apache needs to know the URL-to-file mapping, and JDeveloper needs to know what URL to use. Edit httpd.conf and add the following lines: Alias /MyWS/MyP/public_html/ "/opt/oracle/jdevhome/mywork/MyWS/MyP/public_html/" Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all and restart Apache. 14. In the Applications Navigator, right click on MyP and select Project Properties. 1. Select PHP Script Execution Settings. 2. Add the port number 8888 to the URL, making it http://linux.site:8888/MyWS/MyP/public_html/ 3. Click Test URL. There should be four lines of output, each testing a variation of the URL. The final row with the full URL should show Success. Click OK. 15. In the Applications Navigator, right click on MyP and select Run. Browse the Run Target and use your new file, myoci.php. Unclick 'Attempt to run active file before default' and then Click OK. A new browser should open up showing the results of the query. If you have any questions on this install guide, or about Oracle and PHP in general, please post them in the PHP Discussion Forum http://www.oracle.com/technology/forums/php.html Note: For detailed install guides relating to specific tasks, see the PHP Developer Center -- http://otn.oracle.com/php and the OTN Linux Center -- http://otn.oracle.com/linux