How do I make my PHP Source installation use the libraries inside of /usr/local/programname/lib instead or /usr/local/lib?

I have tried setting LD_LIBRARY_PATH to each of the program names like LD_LIBRARY_PATH="/usr/local/programname1/lib:/usr/local/programname2/lib:/usr/local/programname3/lib".

And, I logged out. Even ran source /etc/environment (I have put the LD_LIBRARY_PATH variable in /etc/environment), even rebooted the system.

But still, when I run ./configure --with-openssl --with-curl, it tells me that libssl does not exist.

I do not want to use the libssl-dev and libcurl-dev package provided by apt, because I need the newest versions, for testing.

And, I noted that: If I install the program's lib directory in /usr/local/lib instead of /usr/local/programname/lib, it works without setting any environment variables.

But, in my opinion, /usr/local/programname/lib is more clear, so I want to use this type of path.

How can I make it so that PHP uses the libraries inside /usr/local/programname/lib instead of /usr/local/lib? By that I mean that, I want to give more priority to /usr/local/programname/lib than other lib directories.

programname refers to the name of each of the programs that is installed inside of /usr/local.

I even tried to use /etc/ld.so.conf.d/programname.conf (I wrote /usr/local/programname inside it), and ran ldconfig. But still no luck.

Btw, I am using Ubuntu 20.10


"Don't fight the system's conventions" - I can't just move on like that. I have to try to do this, or I will just be stuck, and be dependent on the kinda old packages that apt gives me (even if it gives me the newest ones, I cannot for example: use http/3 and test it and more..). And, no testing will be possible. I do this to make my programs future proof, and even to have fun experimenting these. By testing with programs that are new. Installing in /usr/local doesn't feel good, because I test with multiple versions of the libraries. Like I test with OpenSSL 1.1.1i and OpenSSL 3.0.0, and other versions too. So, installing to /usr/local will not benefit me on this, but installing to /usr/local/openssl-1.1.1i and /usr/local/openssl-3.0.0 will be more clean, and will save me more time. I can't just keep running make install and make uninstall every time. Not only OpenSSL, even cURL, and other packages.

  • Don't fight the system's conventions. – Michael Hampton Jan 13 at 6:54
  • @MichaelHampton ?? Im confused about 'flighting system's conventions'. That makes no sense to me! There must be a way to answer my question. I feel like you want me to just give up on this... That doesn't sound good to me though... – user549144 Jan 13 at 6:55

The system default convention is used in so many places that you are creating big overhead for yourself by using different directories.

The easiest way is to use Docker containers for your testing. That way you can use default system locations inside the container.

  • Is a docker container kinda like VirtualBox? – user549144 Jan 13 at 8:09
  • So, you mean each container contains ubuntu each openssl version for example??? – user549144 Jan 13 at 8:25

I added PKG_CONFIG_PATH="/usr/local/programname/lib/pkgconfig" with LD_LIBRARY_PATH set to /usr/local/programname/lib, and it works now. My PHP conf now uses the version I installed inside of /usr/local/programname.

After so much research, this is what I came up with. But, until I keep checking it, I cannot confirm it will work for everyone who wants to do it this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy