Home arrow PHP arrow Page 7 - Executing Microsoft SQL Server Stored Procedure from PHP on Linux
PHP

Executing Microsoft SQL Server Stored Procedure from PHP on Linux


Learn how to setup, install and configure Apache and PHP on a Linux box to execute MS SQL stored procedures. This extensive article takes you through an in-depth look on how to achieve your ideal environment.

Author Info:
By: Jack Zhang
Rating: 4 stars4 stars4 stars4 stars4 stars / 32
October 20, 2003
TABLE OF CONTENTS:
  1. · Executing Microsoft SQL Server Stored Procedure from PHP on Linux
  2. · Preparation
  3. · Installing the Apache Web Server
  4. · Installing the Apache Web Server, Cont'd
  5. · Installing FreeTDS
  6. · Modify the PHP Source Code
  7. · Modify the PHP Source Code, Cont'd
  8. · Executing MS SQL Server Procedures from PHP
  9. · Conclusion

print this article
SEARCH DEVARTICLES

Executing Microsoft SQL Server Stored Procedure from PHP on Linux - Modify the PHP Source Code, Cont'd
(Page 7 of 9 )

According to the PHP documentation, we need to append  these options to the configure command:

--with-mssql=/usr/local/FreeTDS  --with-apxs2filter =/usr/local/Apache2/bin/apxs

The following is my actual command to configure PHP 4.3.3:

./configure --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i686-redhat-linux-gnu --prefix=/usr/local/php --with-config-file-path=/usr/local/php  --enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath --enable-inline-optimization  --with-db4 --with-dom=/usr --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-gdbm --with-gettext --with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr  --with-png  --with-regex=system --with-xml --with-expat-dir=/usr --with-zlib --with-layout=GNU --enable-bcmath --enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid  --enable-wddx  --with-mssql=/usr/local/FreeTDS --with-pcre-regex    --with-mysql=shared  --enable-memory-limit --enable-bcmath --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal --disable-cli --with-apxs2filter=/usr/local/Apache2/bin/apxs

If there is no error, we can compile PHP4.3.3 by issuing:

make

If there is no error, install PHP 4.3.3 as follows:

make install

Check the /usr/local/ folder, you can see the newly installed php folder there. 
Use an editor to open the Apache configuration file as we did in the beginning of this article:

gedit /usr/local/apache2/conf/httpd.conf

Search the following line:

LoadModule php4_module modules/libphp4.so

After the above line, add the following code:

AddType application/x-httpd-php .php

Then save the file.

Now issue the following command if youíve setup Apache as a service:

service httpd restart

If you havenít set it up as a service, you need to restart Apache by issuing the following command:

/usr/local/apache2/bin/apachectl restart

Now PHP is ready to work!  Letís test it. Open an editor window by issuing the following command:

gedit

Input the following contents:

<?php
phpinfo();
?>

And save as a new file, called test.php in the /usr/local/apache2/htdocs folder.

Now load up your browser and input http://localhost/test.php in the address bar.  You will see the PHP information page.

Scroll down the screen, you will see a section on Microsoft SQL Server.

If you have ever worked with Apache + PHP on Windows, you can compare it with the precompiled PHP thatís installed on Windows.

The difference between PHP on Windows and our compiled PHP on Linux is:

On windows, the MS SQL Server support module is running as a DLL file.  In order to enable the extension, must uncomment the line from the php.ini file (also set the correct path for extensions):

extension=php_mssql.dll

On Linux,  the MS SQL Server support module is compiled into libphp4.so.  There is no need to load it from extensions, but I still highly recommend you to copy php.ini-recommended from the PHP source code folder into /usr/local/php, and rename it as php.ini.
Using php.ini, you can easily control all the parameters for the module as needed, and load third party extension modules in the future.


blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials