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.
Next: Executing MS SQL Server Procedures from PHP >>
More PHP Articles
More By Jack Zhang