database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Tutorials 23521 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 23521
Installation of SAP-DB including ODBC Support for PHP and Apache with Linux
작성자
정재익(advance)
작성일
2002-08-08 10:54
조회수
9,570

Installation of SAP-DB including ODBC Support for PHP and Apache with Linux

 

This is just a rough translation of my german tutorial. Perhaps you might take a look on the original text (http://homepages.fh-giessen.de/~hg7494/usefull/laps_german.html).

 

This 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:

http://www.sapdb.org

 

Files:

ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-srv-7.3.0.8-1.i386.rpm

ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-ind-7.3.0.8-1.i386.rpm

ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-web-7.3.0.8-1.i386.rpm

ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-callif-7.3.0.8-1.i386.rpm

 

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: http://www.apache.org

File: http://httpd.apache.org/dist/httpd/apache_1.3.20.tar.gz

 

PHP

PHP 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: http://www.php.net

File: http://www.php3.de/distributions/php-4.0.5.tar.gz

 

OpenSSL & mod-ssl

The 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

File: http://www.openssl.org/source/openssl-0.9.6a.tar.gz

 

Homepage: http://www.modssl.org

File: http://www.modssl.org/source/mod_ssl-2.8.4-1.3.20.tar.gz

 

Step 2: Installation of SAP-Database

 

Let's go! First, change to the directory where the following files are located:

sapdb-ind-7.3.0.8-1.i386.rpm

sapdb-srv-7.3.0.8-1.i386.rpm

sapdb-web-7.3.0.8-1.i386.rpm

sapdb-callif-7.3.0.8-1.i386.rpm

 

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

rpm -i sapdb-srv-7.3.0.8-1.i386.rpm

rpm -i sapdb-web-7.3.0.8-1.i386.rpm

rpm -i sapdb-testdb-7.3.0.8-1.i386.rpm

rpm -i sapdb-callif.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 system

 

Now 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

ln -s sapdb rc2.d/S45sapdb

ln -s sapdb rc2.d/K45sapdb

ln -s sapdb rc3.d/S45sapdb

ln -s sapdb rc3.d/K45sapdb

 

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 break

 

To 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

PATH=$PATH:$SAPDBROOT/indep_prog/bin

. /opt/sapdb/indep_prog/demo/FirstSteps/sapdbenv.sh >/dev/null

export LD_LIBRARY_PATH=/opt/sapdb/web/lib

 

That's it! Now let's test the database server. Start SAP-DB with the following command:

 

/etc/init.d/sapdb start

 

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.

When the "right" answer is shown by the database, we can do a safe reboot. This gives you a chance to see if your SAP-DB startscripts are working correctly - and by the way you can use the restart for a little break.

 

Step 5: Setting up a simple database

 

In 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

. sapdbenv.sh

cd /opt/sapdb/testdb

./create_demo_db.sh

 

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:

 

"x_server not startet": Don't panic! This error sounds more bad than it is. It just says that the SAP-DB server is not started correctly. By the way: The SAP x_server has absolutly nothing to do with the XFree Project or any other GUI stuff. It's just a little confusing name from SAP.

Well, but what has to be done? Start the server direct - perhaps something in "Step 3" went wrong. Just try:

 

/etc/init.d/sapdb start

 

If you got something like "vserver started" you have to check "Step 3" again.

 

"create_database not found": Are you really in the right directory? Please take a look at "Step 5" and type all three commands exactly in your system - this should solve your problem.

 

"file not found" while "create_database" runs: Perhaps your Linux distribution requires to run the create-database-script as root. Give it a try.

 

"/etc/init.d/sapdb: /sbin/fuser: no such file or directory": Perhaps the program can be found somewhere else on your system. Try this command, maybe it helps:

 

ln /bin/fuser /sbin/

 

"Something else went wrong and I want to remove everything": No problem - I need to reinstall some packages too. To remove nearly the whole SAP-DB use the following commands:

 

rpm -e --force sapdb-web-7.3.0.8-1.i386.rpm

rpm -e --force sapdb-srv-7.3.0.8-1.i386.rpm

rpm -e --force sapdb-ind-7.3.0.8-1.i386.rpm

rpm -e --force sapdb-testdb-7.3.0.8-1.i386.rpm

rpm -e --force sapdb-callif-7.3.0.8-1.i386.rpm

 

Step 6: Starting the TST database

 

The "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.

 

Be carefull: Do not add anything between "dbm,dbm" - you have to type it exactly in this way. Also note that the normal "start_testdb.sh" script from SAP will set the TST-DB only on "db_cold". You won't be able to work with the database just by executing this script. Use the second command from this step to activate the database.

 

To start the database after a reboot automaticly, just go go /etc/init.d/sapdb and add the the two "dbmcli" commands. That's how I did it:

RETVAL=1 
case "" in 
    start) 
        echo -n "Starting sapdb services: " 
        if [ ! -z "$X_SERVER" ]; then 
            $X_SERVER start 
            RETVAL=0 
        fi 
        touch /var/lock/subsys/sapdb 

        # Add the following two lines to your sapdb file 

        /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dbm,dbm db_cold 
        /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dmb,dmb db_warm 
        ;; 
    stop) 
        echo -n "Shutting down sapdb services: " 
        if [ ! -z "$X_SERVER" ]; then 

            # Add the following two lines again 
            /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dmb,dmb db_cold 
            /opt/sapdb/indep_prog/bin/dbmcli -d TST -u dmb,dmb db_offline -immediate 
            # Be carefull! All running transactions will be stopped if dbmcli is called 
            # with parameter "-immediate". I just add this 
            # command to make sure that the database is really shutting down 
            # when the server needs to reboot. 

            $X_SERVER stop 
            RETVAL=0 
        fi 
        rm -f /var/lock/subsys/sapdb 
        ;; 
    status) 
        [...]

 

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.

 

To start the server, just type:

 

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

http://<Linuxmachine>:9999/websql

 

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 TST

 

To 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://<Linuxrechnername>: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')

insert into customer values (2,'Walter','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 packages

 

After 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

mkdir /usr/src/laps/tarballs

 

mv apache_1.3.20.tar.gz /usr/src/laps/tarballs

mv mod_ssl-2.8.4-1.3.20.tar.gz /usr/src/laps/tarballs

mv openssl-0.9.6a.tar.gz /usr/src/laps/tarballs

mv php-4.0.5.tar.gz /usr/src/laps/tarballs

 

cd /usr/src/laps

 

tar -xzf tarballs/openssl-0.9.6a.tar.gz

tar -xzf tarballs/php-4.0.5.tar.gz

tar -xzf tarballs/mod_ssl-2.8.4-1.3.20.tar.gz

tar -xzf apache_1.3.20.tar.gz

 

Step 10: Preparing the SSL-Modul

 

Our 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

./config --prefix=/usr/local/openssl/0.9.6a

 

make

make test

make install

 

ln -s /usr/local/openssl/0.9.6a /usr/local/openssl/current

 

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 webserver

 

The 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

./configure --with-apache=../apache_1.3.20 --with-ssl=../openssl-0.9.6a --prefix=/usr/local/apache/1.3.20 --datadir=/usr/local/apache/htdocs --enable-module=so --enable-shared=max --enable-module=ssl

 

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

make

 

Step 12: Creating an SSL-Certificate

 

Before 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

Country Name: "DE"

 

State or Province: "Hessen"

 

Localty Name: "Giessen"

 

Organization Name: "Fachhochschule Giessen-Friedberg"

 

Organizational Unit Name: "TR-CA"

 

Common Name: "Technische Redaktion-CA"

 

Email Address: "andreas.ditze@gmx.de"

 

Certificate Validity: "365"

 

Certificate Version: 3

 

Now we build the real webserver certificate:

 

Country Name: "DE"

State or Province: "Hessen"

 

Localty Name: "Giessen"

 

Organization Name: "Fachhochschule Giessen-Friedberg"

 

Organizational Unit Name: "Technische Redaktion"

 

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"

Email Address: "andreas.ditze@gmx.de"

 

Certificate Validity: "365"

 

Certificate Version: 3

 

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 break

 

Let'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

ln -s /usr/local/apache/current/httpd.conf /etc/httpd.conf

 

Now take a little break before we go to PHP.

 

Step 14: Compiling PHP

 

Well, let's build our own PHP with SAP-DB support:

 

cd /usr/src/laps/php-4.0.5

./configure --with-apxs=/usr/local/apache/current/bin/apxs --with-ftp --enable-versioning --enable-tracking-vars=yes --enable-url-includes --enable-sysvshm=yes --enable-sysvsem=yes --with-config-file-path=/etc --without-mysql --with-sapdb=/opt/sapdb/interface/odbc

 

make

 

Schritt 15: Installing PHP

 

To 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

cp /usr/src/laps/php-4.0.5/php.ini-dist /etc/php.ini

 

Step 16: Start- and stopping the Apache webserver

 

We 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:

 

cd /etc/init.d/rc2.d

 

ln -s ../apachectl S20apachectl

ln -s ../apachectl K20apachectl

cd /etc/init.d/rc3.d

ln -s ../apachectl S20apachectl

ln -s ../apachectl K20apachectl

 

If you are using a RedHat-Distribution, use these links instead:

 

cd /etc/init.d/rc2.d

ln -s ../apachectl S20apachectl

cd /etc/init.d/rc3.d

ln -s ../apachectl S20apachectl

cd /etc/init.d/rc5.d

ln -s ../apachectl S20apachectl

cd /etc/init.d/rc0.d

ln -s ../apachectl K20apachectl

cd /etc/init.d/rc6.d

ln -s ../apachectl K20apachectl

 

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

rm K20apache

 

Step 17: Starting SSL by default

 

Here'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)

 

if [ $RUNNING -eq 1 ]; then 
   echo " $ARG: httpd (pid $PID) already running" 
   continue 
fi 
if $HTTPD ; then 
   echo " $ARG: httpd started" 
   else 
   echo " $ARG: httpd could not be started" 
   ERROR=3 
fi 
;;

Now remove line 

$HTTPD ; then
   and replace it with 
if $HTTPD -DSSL; then
  Well done. That's it!. 

 

Step 18: Modifing the Apache configuration file

 

Now 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

group nogroup

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 configuration

 

Like 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]

ServerDB = TST

 

ServerNode = localhost

Driver = /opt/sapdb/interfaces/odbc/lib/libsqlod.so

Description = My first database test

 

Schritt 20: Test it

 

Let'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:

<?

echo "<b>Establishing database connection.</b>";

 

$conn = odbc_connect("saptest","dba","dba") or die ("Connection failed.");

 

echo "<br>Connection established.<br><br>";

 

echo "Reading usertable from database...<br>";

 

$result = odbc_do($conn,"select * from users");

 

odbc_result_all($result);

 

echo "<br>Reading everything from TST...<br>";

 

$result = odbc_do($conn,"select * from customer");

 

odbc_result_all($result);

 

odbc_close($conn);

 

echo "<br><b>Connection closed</b>";

 

?>

 

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.

At very last I'd like to thank J&ouml;rg Baach and Andreas Wildner for their websites and Oliver Rahn for his Premium Linux Support. Without their knowledge this tutorial wouldn't have come to an end. Thanks!

[Top]
No.
제목
작성자
작성일
조회
23524Installing and Upgrading the Database Server: SAP DB 7.3
정재익
2002-08-08
9065
23523Installing SAP DB 7.3
정재익
2002-08-08
9153
23522standardjaws type mapping using SAPDB
정재익
2002-08-08
7021
23521Installation of SAP-DB including ODBC Support for PHP and Apache with Linux
정재익
2002-08-08
9570
23520SAPDB (Debian) Linux Quickstart Howto
정재익
2002-08-08
8265
23303Inside the MySQL
이경환
2005-03-14
10019
23265Inside the MySQL [시작과 종료]
이경환
2005-03-08
20448
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.021초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다