Setting environment variable for apache user2019 Community Moderator ElectionSetting up Apache 2 Local Development Environment & PermissionsSetting user environment variable permanently, outside shell?Setting the TOPCOLORS environment variableCompiling ImageMagick with special path to librairiesSetting environment variable using shell scriptSetting the LANG environment variable for xfceSetting path environment variable for desktop launchersHow can DYLD_LIBRARY_PATH be unset for launchd processes?How to change group for apache user in FedoraApache/Nginx document root environment-variable

How can a new country break out from a developed country without war?

Pre-Employment Background Check With Consent For Future Checks

is this saw blade faulty?

Why is this tree refusing to shed its dead leaves?

"Marked down as someone wanting to sell shares." What does that mean?

What is the reasoning behind standardization (dividing by standard deviation)?

The English Debate

Why is "la Gestapo" feminine?

label a part of commutative diagram

Knife as defense against stray dogs

Hot air balloons as primitive bombers

Animating wave motion in water

What are the consequences of changing the number of hours in a day?

Error in master's thesis, I do not know what to do

Exit shell with shortcut (not typing exit) that closes session properly

DisplayForm problem with pi in FractionBox

Do I need an EFI partition for each 18.04 ubuntu I have on my HD?

Is there any common country to visit for uk and schengen visa?

Fair way to split coins

Could any one tell what PN is this Chip? Thanks~

pipe commands inside find -exec?

Print last inputted byte

CLI: Get information Ubuntu releases

How can an organ that provides biological immortality be unable to regenerate?



Setting environment variable for apache user



2019 Community Moderator ElectionSetting up Apache 2 Local Development Environment & PermissionsSetting user environment variable permanently, outside shell?Setting the TOPCOLORS environment variableCompiling ImageMagick with special path to librairiesSetting environment variable using shell scriptSetting the LANG environment variable for xfceSetting path environment variable for desktop launchersHow can DYLD_LIBRARY_PATH be unset for launchd processes?How to change group for apache user in FedoraApache/Nginx document root environment-variable










0















I tried what not:



  1. in /etc/profile.d/ I created a script file apachhe.sh with content if [ $UID -eq 48 ]; then . export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; fi

  2. in /etc/environment I added LD_LIBRARY_PATH=/usr/local/lib

  3. in /etc/sysconfig/httpd I added LD_LIBRARY_PATH=/usr/local/lib

Restarting apache thru phpinfo() I see the variable set properly but when I try to call the program that needs this variable from a script as <?php exec('the_exe'); ?>, I still get an error that the system can't find a lib file.



I finally managed to do a workaround by calling putenv("LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"); from the PHP script prior to the exec call but I don't want to do this on every request. Any ideas how to set the variable for apache properly? What do I miss?



BTW PHP is running as fpm under apache user. The OS is CentOS 7. Thanks.










share|improve this question

















  • 1





    Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

    – sebasth
    Sep 18 '17 at 12:46






  • 1





    sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

    – Jeff Schaller
    Sep 18 '17 at 12:53











  • @sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

    – Martin Dimitrov
    Sep 18 '17 at 13:30











  • @JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

    – Martin Dimitrov
    Sep 18 '17 at 13:32






  • 1





    I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

    – Jeff Schaller
    Sep 18 '17 at 13:33















0















I tried what not:



  1. in /etc/profile.d/ I created a script file apachhe.sh with content if [ $UID -eq 48 ]; then . export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; fi

  2. in /etc/environment I added LD_LIBRARY_PATH=/usr/local/lib

  3. in /etc/sysconfig/httpd I added LD_LIBRARY_PATH=/usr/local/lib

Restarting apache thru phpinfo() I see the variable set properly but when I try to call the program that needs this variable from a script as <?php exec('the_exe'); ?>, I still get an error that the system can't find a lib file.



I finally managed to do a workaround by calling putenv("LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"); from the PHP script prior to the exec call but I don't want to do this on every request. Any ideas how to set the variable for apache properly? What do I miss?



BTW PHP is running as fpm under apache user. The OS is CentOS 7. Thanks.










share|improve this question

















  • 1





    Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

    – sebasth
    Sep 18 '17 at 12:46






  • 1





    sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

    – Jeff Schaller
    Sep 18 '17 at 12:53











  • @sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

    – Martin Dimitrov
    Sep 18 '17 at 13:30











  • @JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

    – Martin Dimitrov
    Sep 18 '17 at 13:32






  • 1





    I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

    – Jeff Schaller
    Sep 18 '17 at 13:33













0












0








0








I tried what not:



  1. in /etc/profile.d/ I created a script file apachhe.sh with content if [ $UID -eq 48 ]; then . export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; fi

  2. in /etc/environment I added LD_LIBRARY_PATH=/usr/local/lib

  3. in /etc/sysconfig/httpd I added LD_LIBRARY_PATH=/usr/local/lib

Restarting apache thru phpinfo() I see the variable set properly but when I try to call the program that needs this variable from a script as <?php exec('the_exe'); ?>, I still get an error that the system can't find a lib file.



I finally managed to do a workaround by calling putenv("LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"); from the PHP script prior to the exec call but I don't want to do this on every request. Any ideas how to set the variable for apache properly? What do I miss?



BTW PHP is running as fpm under apache user. The OS is CentOS 7. Thanks.










share|improve this question














I tried what not:



  1. in /etc/profile.d/ I created a script file apachhe.sh with content if [ $UID -eq 48 ]; then . export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; fi

  2. in /etc/environment I added LD_LIBRARY_PATH=/usr/local/lib

  3. in /etc/sysconfig/httpd I added LD_LIBRARY_PATH=/usr/local/lib

Restarting apache thru phpinfo() I see the variable set properly but when I try to call the program that needs this variable from a script as <?php exec('the_exe'); ?>, I still get an error that the system can't find a lib file.



I finally managed to do a workaround by calling putenv("LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH"); from the PHP script prior to the exec call but I don't want to do this on every request. Any ideas how to set the variable for apache properly? What do I miss?



BTW PHP is running as fpm under apache user. The OS is CentOS 7. Thanks.







apache-httpd environment-variables php






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 18 '17 at 12:16









Martin DimitrovMartin Dimitrov

1013




1013







  • 1





    Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

    – sebasth
    Sep 18 '17 at 12:46






  • 1





    sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

    – Jeff Schaller
    Sep 18 '17 at 12:53











  • @sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

    – Martin Dimitrov
    Sep 18 '17 at 13:30











  • @JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

    – Martin Dimitrov
    Sep 18 '17 at 13:32






  • 1





    I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

    – Jeff Schaller
    Sep 18 '17 at 13:33












  • 1





    Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

    – sebasth
    Sep 18 '17 at 12:46






  • 1





    sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

    – Jeff Schaller
    Sep 18 '17 at 12:53











  • @sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

    – Martin Dimitrov
    Sep 18 '17 at 13:30











  • @JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

    – Martin Dimitrov
    Sep 18 '17 at 13:32






  • 1





    I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

    – Jeff Schaller
    Sep 18 '17 at 13:33







1




1





Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

– sebasth
Sep 18 '17 at 12:46





Did you try adding the line in /etc/sysconfig/php-fpm and then restarting php-fpm with systemctl restart php-fpm.service?

– sebasth
Sep 18 '17 at 12:46




1




1





sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

– Jeff Schaller
Sep 18 '17 at 12:53





sounds very much like the variable isn't being exported; if the syntax in #1 is really . export LD... then you're not actually exporting there; removing the . (period) would get you a lot closer.

– Jeff Schaller
Sep 18 '17 at 12:53













@sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

– Martin Dimitrov
Sep 18 '17 at 13:30





@sebasth thanks. I tried it but doesn't work. I've restarted both - apache and the php-fpm process.

– Martin Dimitrov
Sep 18 '17 at 13:30













@JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

– Martin Dimitrov
Sep 18 '17 at 13:32





@JeffSchaller I changed the syntax but still doesn't work. I've restarted the services but do I need to restart the server itself?

– Martin Dimitrov
Sep 18 '17 at 13:32




1




1





I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

– Jeff Schaller
Sep 18 '17 at 13:33





I wouldn't think so, no. Possible that apache has the variable set but isn't exporting it to the child PHP processes.

– Jeff Schaller
Sep 18 '17 at 13:33










0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f392940%2fsetting-environment-variable-for-apache-user%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f392940%2fsetting-environment-variable-for-apache-user%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.