0

Trying to deploy a PHP Azure "App Service" app, which connects to a SQL Server database

I have to add the sqlsrv and sqlsrv_pdo packages by running pecl install pdo_sqlsrv and pecl install sqlsrv`

Other threads have mentioned adding apt-get install unixodbc-dev, I have done so, but it does not help

Here is the error I'm getting below

creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/bash /tmp/pear/temp/pear-build-rootiNpTPo/pdo_sqlsrv-5.10.1/libtool --mode=compile g++ -I. -I/tmp/pear/temp/pdo_sqlsrv -I/tmp/pear/temp/pear-build-rootiNpTPo/pdo_sqlsrv-5.10.1/include -I/tmp/pear/temp/pear-build-rootiNpTPo/pdo_sqlsrv-5.10.1/main -I/tmp/pear/temp/pdo_sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/pdo_sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -I/usr/local/include/php/ext -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/pdo_sqlsrv/pdo_dbh.cpp -o pdo_dbh.lo  -MMD -MF pdo_dbh.dep -MT pdo_dbh.lo
 g++ -I. -I/tmp/pear/temp/pdo_sqlsrv -I/tmp/pear/temp/pear-build-rootiNpTPo/pdo_sqlsrv-5.10.1/include -I/tmp/pear/temp/pear-build-rootiNpTPo/pdo_sqlsrv-5.10.1/main -I/tmp/pear/temp/pdo_sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/pdo_sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -I/usr/local/include/php/ext -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/pdo_sqlsrv/pdo_dbh.cpp -MMD -MF pdo_dbh.dep -MT pdo_dbh.lo  -fPIC -DPIC -o .libs/pdo_dbh.o
In file included from /tmp/pear/temp/pdo_sqlsrv/php_pdo_sqlsrv_int.h:23,
                 from /tmp/pear/temp/pdo_sqlsrv/pdo_dbh.cpp:24:
/tmp/pear/temp/pdo_sqlsrv/shared/core_sqlsrv.h:48:10: fatal error: config.h: No such file or directory
   48 | #include "config.h"
      |          ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:205: pdo_dbh.lo] Error 1
ERROR: `make' failed

I was expecting the pecl package to run... actually I was expecting the Microsoft App Service linux box to support MS Sql Server by default, but you get what I'm saying

Mike Wright
  • 111
  • 1
  • 2

1 Answers1

0

Okay, after 3 days of messing around with this, I found a solution

Azure doesn't have sudo command... but in order to install pecl packages, you MUST run su -

su -
pecl install pdo_sqlsrv
pecl install sqlsrv

cp /home/site/wwwroot/azure/custom_php.ini /usr/local/etc/php/conf.d/;

exit;
service nginx reload;

The contents of my custom_php.ini file are

extension=pdo_sqlsrv.so
extension=sqlsrv.so

NOTE: For Azure, I had to create a .sh file in my project and run all this from Home > My App > Configuration > General Settings > Startup Command - so that it'd be ran every time a new server is instantiated

NOTE 2: I also had to make changes to the nginx /etc/nginx/sites-enabled/default file, which moved the root of my project to /home/site/wwwroot/public - but that's laravel specific

Mike Wright
  • 111
  • 1
  • 2