Score:2

Built PHP from source with custom DataDirect ODBC drivers, but can't auto start with systemd

br flag

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 avatar
br flag
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'`
Michael Hampton avatar
cz flag
Well that's just a plain old "Segmentation fault" crash. Maybe this code isn't all that reliable?
Barry Ralphs avatar
br flag
Are you referring to the build/source code of Apache or the PHP code? The PHP code works fine when starting Apache manually.
Michael Hampton avatar
cz flag
There's no way to know, unless you have a core dump you can analyze.
ezra-s avatar
ru flag
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.
Barry Ralphs avatar
br flag
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' `
Michael Hampton avatar
cz flag
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?
Barry Ralphs avatar
br flag
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.
Michael Hampton avatar
cz flag
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?
Barry Ralphs avatar
br flag
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 avatar
br flag
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 avatar
br flag
Thanks @MichaelHampton, I was able to figure it out based on your hint about the environment variables.
Score:1
br flag

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"

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.