2

I need to build PHP from source in order to use this customer ODBC drivers. I've followed these inspections: https://www.progress.com/tutorials/odbc/using-php and everything (including the ODBC driver) works fine when I manually start apache with /usr/local/apache2/bin/apachectl start But when I try to start apache with systemd, the ODBC drivers no longer works.

I've created this file: /usr/lib/systemd/system/httpd.service

[Unit]
Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/apache2/logs/httpd.pid
ExecStart=/usr/local/apache2/bin/apachectl start
ExecStop=/usr/local/apache2/bin/apachectl graceful-stop
ExecReload=/usr/local/apache2/bin/apachectl graceful
PrivateTmp=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

I get the following error in my php file when starting apache with systemd:

odbc_connect(): SQL error: [DataDirect][ODBC lib] Driver Manager Message file not found. Please check for the value of InstallDir in your odbc.ini., SQL state IM002 in SQLConnect

The InstallDir is set correctly in my odbc.ini file: enter image description here

enter image description here

I don't get this error when starting apache with apachectl start manually. Any suggestion on how to fix this?

Barry Ralphs
  • 191
  • 1
  • 1
  • 11
  • I got this, I'm not sure what to make of it: `type=ANOM_ABEND msg=audit(1624733159.706:196): auid=1000 uid=48 gid=48 ses=1 pid=1589 comm="httpd" reason="memory violation" sig=11 type=ANOM_ABEND msg=audit(1624733159.706:197): auid=1000 uid=48 gid=48 ses=1 pid=1591 comm="httpd" reason="memory violation" sig=11 type=SERVICE_START msg=audit(1624733172.056:198): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'` – Barry Ralphs Jun 26 '21 at 18:50
  • Well that's just a plain old "Segmentation fault" crash. Maybe this code isn't all that reliable? – Michael Hampton Jun 26 '21 at 19:18
  • Are you referring to the build/source code of Apache or the PHP code? The PHP code works fine when starting Apache manually. – Barry Ralphs Jun 26 '21 at 19:30
  • There's no way to know, unless you have a core dump you can analyze. – Michael Hampton Jun 26 '21 at 19:35
  • You are compiling odbc for PHP, not Apache, there is a big difference. Why don´t you try and see which kind of configuration you are trying to start Apache with afterwards? In any case, have you tried to run php in php-fpm and use Apache to proxy requests to it without trying to use mod_php? I think that alone, would help you understand better what you are trying to achieve and what your problem really is. – Daniel Ferradal Jun 28 '21 at 15:23
  • Thanks @ezra-s, good point, I just always lump Apache & PHP together. Can you clarify what you mean by checking which kind of configuration you are trying to start Apache with? How would I do that? My PHPINFO() shows: ` './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysqli' '--with-openssl' '--with-bz2' '--with-zlib' '--with-zip' '--enable-mbstring' '--enable-ssl' '--prefix=/usr/local/php' '--with-custom-odbc=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC' ` – Barry Ralphs Jun 28 '21 at 17:20
  • Oops, I just made the mistake of not reading that link about the ODBC driver until now. Are they serious? The environment they specify is 15 years old! This is entirely not supportable. Is there some particular reason that you need to use this specific (and apparently long obsolete) ODBC driver? – Michael Hampton Jun 28 '21 at 20:22
  • Thanks @MichaelHampton, I didn't follow the part about building PHP5.1. I built 7.4 instead. Our client is using the accounting software Deltek Vision hosted in Deltek's cloud. Apparently, Deltek only supports this ODBC driver to read data from their cloud. – Barry Ralphs Jun 28 '21 at 22:14
  • That definitely limits your options. I did look into it a bit more and apparently it's just that particular tutorial is 15 years old, the software is more or less up to date. So after looking into that message a bit, I have a suspicion about the issue. How did you provide the ODBCINI and ODBCINST environment variables? – Michael Hampton Jun 28 '21 at 22:36
  • Thanks, I did notice something new. If I run `sudo /usr/local/apache2/bin/apachectl` as myself, I still get the error above, but if I swatch to root and run `/usr/local/apache2/bin/apachectl` it works fine. This is what makes me think it's a permissions issue. Is there anyway to tell systemd to start apachectl as root? – Barry Ralphs Jun 28 '21 at 22:38
  • Re: ODBCINI and ODBCINST, I have the file: `/etc/profile.d/odbc.sh` which has: `ODBCINI=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC/odbc.ini export ODBCINI ODBCINST=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC/odbcinst.ini export ODBCINST` Is sysytemd not seeing them? – Barry Ralphs Jun 28 '21 at 22:44
  • Thanks @MichaelHampton, I was able to figure it out based on your hint about the environment variables. – Barry Ralphs Jun 29 '21 at 23:58

1 Answers1

1

I was able to resolve my issue by adding the following lines to my /usr/lib/systemd/system/httpd.service file, under the [Service] section:

Environment="ODBCINST=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC/odbcinst.ini" Environment="ODBC_HOME=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC" Environment="ODBCINI=/opt/Progress/DataDirect/Hybrid_Data_Pipeline_for_ODBC/odbc.ini" Environment="TZ=America/Los_Angeles"

Barry Ralphs
  • 191
  • 1
  • 1
  • 11