<p>As part of our product release we ship Apache HTTP Server binaries that we have compiled on our (UNIX) development machine.</p>

<p>We tell our clients to install the binaries (on their UNIX servers) under the same directory structure that we compiled it under. For some clients this is not appropriate, e.g. where there are restrictions on where they can install software on their servers and they don't want to compile Apache themselves.</p>

<p>Is there a way of compiling Apache HTTP Server so its installation location(s) can be specified dynamically using environment variables ?</p>

<p>I spent a few days trying to sort this out and couldn't find a way to do it. It led me to believe that the Apache binaries were hard coding some directory paths at compilation preventing the portability we require.</p>

<p>Has anyone managed to do this ?</p>

[{'answer_id': 22210, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 1, 'selected': False, 'text': '<p>I think the way to do(get around) this problem is to develop a "./configure &amp;&amp; make" script that your client uses to install, specify and compile the binaries. That would offcourse require that the client has all the source-code installed on his server or you can make it available on an NFS share.</p>\n'}, {'answer_id': 27644, 'author': 'wvdschel', 'author_id': 2018, 'author_profile': 'https://Stackoverflow.com/users/2018', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>I think the way to do(get around) this problem is to develop a "./configure &amp;&amp; make" script that your client uses to install, specify and compile the binaries. That would offcourse require that the client has all the source-code installed on his server or you can make it available on an NFS share.</p>\n</blockquote>\n\n<p>Not to mention a complete build toolchain. These days, GCC doesn\'t come default with most major distributions. Wouldn\'t it be sane to force the client to install it to <code>/opt/my_apache2/</code> or something like that?</p>\n'}, {'answer_id': 27902, 'author': 'Hissohathair', 'author_id': 2997, 'author_profile': 'https://Stackoverflow.com/users/2997', 'pm_score': 1, 'selected': False, 'text': "<p>If you are compiling Apache2 for a particular location but want your clients to be able to install it somewhere else (and I'm assuming they have the same architecture and OS as your build machine) then you can do it but the apachectl script will need some after-market hacking.</p>\n<p>I just tested these steps:</p>\n<ol>\n<li><p>Unpacked the Apache2 source (this should work with Apache 1.3 as well though) and ran <code>./configure --prefix=/opt/apache2</code></p>\n</li>\n<li><p>Ran <em>make</em> then <code>sudo make install</code> to install on the build machine.</p>\n</li>\n<li><p>Switch to the install directory (/opt/apache2) and tar and gzip up the binaries and config files. I used <code>cd /opt/apache2; sudo tar cf - apache2 | gzip -c &gt; ~/apache2.tar.gz</code></p>\n</li>\n<li><p>Move the tar file to the target machine. I decided to install in <code>/opt/mynewdir/dan/apache2</code> to test. So basically, your clients can't use rpm or anything like that -- unless you know how to make that relocatable (I don't :-) ).</p>\n</li>\n<li><p>Anyway, your client's <code>conf/httpd.conf</code> file will be full of hard-coded absolute paths -- they can just change these to whatever they need. The <em>apachectl</em> script also has hard coded paths. It's just a shell script so you can hack it or give them a <em>sed</em> script to convert the old paths from your build machine to the new path on your clients.</p>\n</li>\n<li><p>I skipped all that hackery and just ran <code>./bin/httpd -f /opt/mynewdir/dan/conf/httpd.conf</code> :-)</p>\n</li>\n</ol>\n<p>Hope that helps. Let us know any error messages you get if it's not working for you.</p>\n"}, {'answer_id': 47738, 'author': 'cwhite', 'author_id': 4923, 'author_profile': 'https://Stackoverflow.com/users/4923', 'pm_score': 0, 'selected': False, 'text': "<p>@Hissohathair</p>\n\n<p>I suggest 1 change to @Hissohathair's answer.</p>\n\n<pre><code>6). ./bin/httpd -d &lt;server path&gt; (although it can be overridden in the config file) \n</code></pre>\n\n<p>In apacheclt there is a variable for HTTPD where you could override to use it.</p>\n"}]
['https://Stackoverflow.com/questions/22140', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/381/']