TutorialInstallation of SAP-DB including ODBC Support for PHP and Apache with LinuxThis tutorial describes how to set up the open source database SAP-DB and how to use it with PHP and ODBC. This tutorial requires that you know how to handle Linux in general - no special SAP knowledge is required. I tested everything on SuSE 7.1 Linux using Kernel 2.4. If nothing else is said you should use the "root"-User for all installation works. Step 1: Downloading everything we need!As it's said above, we want to make SAP-DB, PHP, ODBC and the Apache Webserver work together. To make it as easy as possible, I listed the needed packages below including a deep link to the file I used for this tutorial. If a deep link may be lost just try a newer version of the needed software. Linux:Maybe you've got a very fast internet connection - so you are able to download a full Linux distribution. Otherweise go out and buy the distribution of your choice. This tutorial works with SuSE Linux, but should also work on RedHat. Perhaps you have to correct one or two "path"-settings but in general this tutorial is compatible to most Linux distributions. Please make sure that your distribution includes the packages "flex" and "bison". They are required for compiling some programs. You should also remove (or not install) any versions of the Apache webserver. SAP-DB:To make SAP work we need the "normal" database, the webinterface, some enviromentals and the ODBC support package. I think it's easier to use RPM's instead of compiling everything on your own, so I just gave deep links to the RPM files. Homepage: www.sapdb.org Apache:Usually a normal configured standard Apache should work with a self compiled version of PHP. Unfortunatly my Apache from SuSE 7.1 didn't work with my PHP version - so I included a description of how to compile your own Apache in this tutorial. Homepage: www.apache.org PHPPHP supports SAP-DB over ODBC but this support is turned off by default. By compiling our own version, we'll enable the build-in support and disable some other useless features. To make it as easy as possible again I recommand using PHP4.0.3 or higher (I used 4.0.5). Older versions of PHP are not supported by this tutorial. Homepage: www.php.net OpenSSL & mod-sslThe SAP-DB is a very powerfull database build for the real business. Using a business database over the web requires a minimum of security. For this reason I included SSL support in this tutorial. SSL should be the first step to protect your business data but it's not the end of the way! I used SSL just for demonstration - don't think your server is secure just by doing everything that is written below. Homepage: http://www.openssl.org
Homepage: http://www.modssl.org Step 2: Installation of SAP-DatabaseLet's go! First, change to the directory where the following files are located:
Now you have to install the files in this order. Just type in these commands: rpm -i sapdb-ind-7.3.0.8-1.i386.rpm What has happend? The software is now installed on your computer. The files can be found under /opt/sapdb. As it's a part of the installation procedure, you will found a new user called "sapdb" in your system. The password for this new user is "sapdb". Don't forget to change this password due to security reasons. Step 3: Establishing the database in the systemNow we do some changes on the system to start the database after the system has restart. SuSE users should add the following line in /etc/rc.config: START_SAPDB=yes After you add the line, don't forget to run SuSEconfig Some symbolic links have to be created until the database really starts on their own: cd /etc/init.d You need the S-Links for starting SAP-DB in runlevel 2 (Terminalmode) and 3 (GUI-Mode). The K-Links are used for shuting down the database in both runlevels. Step 4: Configuring the shell, restart and a little breakTo make some scripts work, we need so set some path-variables. Please add these lines in /root/.bash_profile (if you can't find this file, just create it on your own): SAPDBROOT=/opt/sapdb That's it! Now let's test the database server. Start SAP-DB with the following command:
If nothing went wrong, the database answers "Starting sapdb services: INFO
10004: Vserver started". In every other case you should check step 3 and
4. Step 5: Setting up a simple databaseIn this step we will set up a simple database in SAP-DB. Please type the following commands as user "sapdb": cd /opt/sapdb/indep_prog/demo/Firststeps If nothing goes wrong, the script will set up a database called TST. If you need some troubleshooting, just have a look on the next four hints. Otherwise go to the next step. I've found these problemes:
Step 6: Starting the TST databaseThe "create_database" Script created a database called TST, but the new database is still not active - allthough the SAP-DB itself is started already (the vserver, you remember?). Now let's start the database: /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dbm,dbm db_cold /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dbm,dbm db_warm In this example the database is first set on "cold" and next on "warm". Both
operations are done by user "dbm" with password "dbm". "dbm" is a standard user
created by SAP-DB. After the database is set on warm, it can be used by other
(normal) users. To start the database after a reboot automaticly, just go to /etc/init.d/sapdb and add the the two "dbmcli" commands. That's how I did it: RETVAL=1 Step 7: Using the SAP-DB webinterface quick and dirty.SAP provides an own webserver which helps you to work on your database.
Instead of the SAP server you can use Apache - but in this tutorial we will do
our work with the SAP server. In my system the "administration-webserver" is
only started when it's really needed. cd /opt/sapdb/web/pgm ./wahttp& In your terminal you should see some processes starting to work. When the list stops, you can try to access the database in your browser. Now go to the following URL: http://LINUXMACHINE:9999/webdbm
The first URL takes you to the administration GUI from SAP-DB. Here you can start or stop databases, create them or build some backups. To log in, please use user "dba" with password "dba". Take a look around and then leave the GUI - the next step takes you to the second URL. Step 8: Putting some data in TSTTo get familiar with the WebSQL-Interace we'll put some information in the database. Please don't skip this step - we need the information inserted here at the end of the tutorial for testing. Please go to the following URL: http://LINUXMACHINE:9999/websql Again you have to log in as "dba" with password "dba". The database name is TST, of course. Now put these commands in the textfield to the right and confirm each command by pressing the "Execute" button: create table customer ( cust_id fixed(4) key , name char(12), firstname char(12) ) insert into customer values (1,'Ditze','Andreas') The database contains two entries. To see the whole table, just type select * from customer in the textfield. That's enough for now with SAP - now let's take a look on Apache and PHP. Step 9: Extracting the .tar.gz packagesAfter SAP-DB works fine, let's take a look on the webserver stuff. First we have to move the tarballs to a special directory (/usr/src/laps/tarballs) and second we'll extract them. mkdir /usr/src/laps Step 10: Preparing the SSL-ModulOur compiling tour has to start with the open-ssl software, which is needed for mod_ssl. Start compiling with these commands: cd /usr/src/laps/openssl-0.9.6a After these commands, you'll find openssl in /usr/local/openssl/0.9.6a. To handle future updates as easy as possible I linked the "current" openssl with the directory /usr/local/openssl/current. All other programs will take openssl from the "current" directory. Should you need to update the software, you just have to relink the "current" directory to your new software package. Step 11: Building the Apache webserverThe server will be build with DSO support. DSO is used to include different modules (like PHP) without recompiling your server again and again. cd /usr/src/laps/mod_ssl-2.8.4-1.3.20 Please type everything exactly as it's written here. Remember that the "./configure" command is one(!) command. Do not split it in two parts. Now let's compile: cd /usr/src/laps/apache_1.3.20 Step 12: Creating an SSL-CertificateBefore we can create our own SSL-Key, we have to build a certificate for our Certification Authority: make certificate TYPE=custom Der Make-Befehl fragt nun nach den Informationen, die Ihr Zertifikat tragen soll - tragen Sie hier Ihre(!) Daten ein: Signature Algorithm: R Now we build the real webserver certificate: Country Name: "DE" We nearly got it already. Now just type in the name, on which your server will be available in the net: Common Name: "testserver.mni.fh-giessen.de" At last you have to decide wether your certificates should become local-encrypted - or not. The difference between both options is simple: Encrypted files requires a password everytime you start your webserver. Unencrypted files work everytime! Decide on your own, what's the best for you. Step 13: Installing Apache and take a little breakLet's establish the webserver in the system. Use command make install to do this. As described in "Step 10", the webserver gets linked with a "current" directory to make updates easier again. ln -s /usr/local/apache/1.3.20 /usr/local/apache/current Now take a little break before we go to PHP. Step 14: Compiling PHPWell, let's build our own PHP with SAP-DB support: cd /usr/src/laps/php-4.0.5 Schritt 15: Installing PHPTo establish the software in your system, use the "make install" command again. Next you have to copy the "php.ini"-file to the /etc directory. make install Step 16: Start- and stopping the Apache webserverWe did already work on the Apache but some details have still to be done. First, set the file permission on the webserver a little more restrictive:. chmod 700 /usr/local/apache/current/bin/apachectl As already shown on "Step 3", we have to set up some symbolic links: ln -s /usr/local/apache/current/bin/apachectl /etc/rc.d/init.d/apachectl If you are using a SuSE-Distribution, please build the following symbolic links:
If you are using a RedHat-Distribution, use these links instead:
Perhaps you had an old version of Apache webserver installed before. In this case, take a look on the directories rc2.d and rc3.d and watch out for Apache start- and stopp-links (perhaps. "S20apache oder K20apache"). If you find them, just use the remove commands: rm S20apache Step 17: Starting SSL by defaultHere's another detail in the "apachectl" file. Usually apachectl is started with parameter "start". This means, that normal "http" connections are available - but nothing more. If you want to make SSL-connections available by default, we have to modify the apachectl-script a little bit. Open the file /etc/init.d/apachectl and search the following lines: start) Now remove line $HTTPD ; then and replace it with if $HTTPD -DSSL; then Well done. That's it!. Step 18: Modifing the Apache configuration fileNow we have to do some work on /usr/local/apache/current/conf/httpd.conf. First, search the line #AddType application/x-httpd-php .php and remove the comment char ("#"). If you plan to update your Apache, you should also replace all directory entries with "/usr/local/apache/1.3.20" thru "/usr/local/apache/current". Now go and search again - look out for: user nobody Please replace "user nobody" with: user sapdb Why doing so? The home directory of the webserver-user is the place where we have to place the ODBC configuration file. You can put any user you want in here - but a real home directory including a file called ".odbc.ini" is required in any case. I recommand using user "sapdb" in this tutorial. Step 19: The ODBC configurationLike I said above, you have to create a file named ".odbc.ini" in the home directory of the webserver-"user". Please create /home/sapdb/.odbc.ini with the following lines: [saptest] Schritt 20: Test itLet's go for a test. First, start the webserver: /etc/init.d/apachectl start If everything works right, create the file /usr/local/apache/htdocs/test.php containing these PHP-commands:
Now just take your browser and go for "test.php": http://LINUXMACHINE/test.php If you put some data in the database on "Step 8", you should see them now. Congratulations - that's it! At the end...So you did it. Congrats again! Be happy about a compact webserver, a pretty
good programming language and a real professional database. To my delight I
heard some days ago that SAP-DB becomes part of the SuSE Linux distribution.
This shows that Linux and SAP seems to be a good combination in the future.
andreas.ditze@gmx.de Giessen, 25.06.2001 Falls etwas nicht hierher gehören sollte, ein Beitrag vermisst wird oder die Webseite einfach nur gefallen hat, bitte ich um Lob und Kritik im Gästebuch. |
||||