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