The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 15, 2019, 08:03:23 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Compiling Apache on a 64bit machine  (Read 6446 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: November 05, 2007, 01:09:38 PM »

I am working on a few new boxes I just bought for the rack – they’re 64 bit dual Xeon machines – fast, strong, delightful. But when I went to build Apache I had trouble. My personal method is to create configure scripts that call configure with the options that want – and I name this file configure.p, so that no matter how long it’s been since I’ve worked on a machine, I can come back and see how I configured (that) application. My standard Apache config looks like this:

Code:
./configure \
        --enable-rewrite \
        --enable-ssl \
        --enable-proxy \
        --enable-so

It configured without complaint, but when I went to make, I received this error and termination:

Code:
/usr/lib/libexpat.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[3]: *** [libaprutil-1.la] Error 1
make[3]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib/apr-util'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib/apr-util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib'
make: *** [all-recursive] Error 1

After a big of searching, it turns out that Apache does not like to be compiled with 64 bit libraries by default. In addition to calling them out, you need to patch a bug in the configure script. Below is all the steps you need.

First off, we’ll assume that you are ready to compile apache 2. You have a directory something like /usr/local/installs/httpd-2.2.3 where your compiling from. Step into the srclib directory. Copy the following code, and paste it into a new file in the srclib directory called patch64:

(You can also get it directly from the apache foundation bug fixes here: http://issues.apache.org/bugzilla/attachment.cgi?id=16166

Code:
diff -rNu --exclude=.svn apr-util/build.orig/apu-conf.m4 apr-util/build/apu-conf.m4
--- apr-util/build.orig/apu-conf.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/apu-conf.m4 2005-08-23 16:10:23.000000000 +0200
@@ -20,6 +20,17 @@
 dnl
 
 dnl
+dnl enable preference of lib64 instead of lib
+dnl
+AC_ARG_ENABLE(lib64,
+AC_HELP_STRING([--enable-lib64],[prefer lib64 over lib [[default=no]]]),
+[case $enableval in
+yes|no) ;;
+*) AC_MSG_ERROR([bad value $enableval for --enable-lib64, need yes or no]) ;;
+esac],
+[enable_lib64=no])
+
+dnl
 dnl APU_FIND_APR: figure out where APR is located
 dnl
 AC_DEFUN([APU_FIND_APR], [
@@ -64,6 +75,14 @@
     expat_libs="-lexpat"
     expat_libtool="$1/lib/libexpat.la"
   elif test -r "$1/include/expat.h" -a \
+    -r "$1/lib64/libexpat.la" -a \
+    "$enable_lib64" = "yes" ; then
+    dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool)
+    expat_include_dir="$1/include"
+    expat_ldflags="-L$1/lib64"
+    expat_libs="-lexpat"
+    expat_libtool="$1/lib64/libexpat.la"
+  elif test -r "$1/include/expat.h" -a \
     -r "$1/lib/libexpat.la"; then
     dnl Expat 1.95.* installation (with libtool)
     expat_include_dir="$1/include"
diff -rNu --exclude=.svn apr-util/build.orig/apu-iconv.m4 apr-util/build/apu-iconv.m4
--- apr-util/build.orig/apu-iconv.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/apu-iconv.m4 2005-08-23 19:06:27.000000000 +0200
@@ -39,7 +39,11 @@
   [ apu_iconv_dir="$withval"
     if test "$apu_iconv_dir" != "yes"; then
       APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include])
-      APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
+      if test "$enable_lib64" = "yes" ; then
+        APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib64])
+      else
+        APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
+      fi
     fi
     if test -f "$apu_iconv_dir/include/api_version.h"; then
       have_apr_iconv="1"
@@ -74,9 +78,14 @@
     fi
   fi
   APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include])
-  APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
   APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include])
-  APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
+  if test "$enable_lib64" = "yes" ; then
+    APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib64])
+    APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib64])
+  else
+    APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
+    APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
+  fi
 fi
 
 if test "$have_iconv" = "1"; then
diff -rNu --exclude=.svn apr-util/build.orig/dbd.m4 apr-util/build/dbd.m4
--- apr-util/build.orig/dbd.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/dbd.m4 2005-08-23 19:03:12.000000000 +0200
@@ -40,19 +40,31 @@
       apu_have_pgsql=0
     else
       CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "
+      if test "$enable_lib64" = "yes" ; then
+        LIBS="-L$withval/lib64 "
+      else
+        LIBS="-L$withval/lib "
+      fi
 
       AC_MSG_NOTICE(checking for pgsql in $withval)
       AC_CHECK_HEADER(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
       if test "$apu_have_pgsql" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        if test "$enable_lib64" = "yes" ; then
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+        else
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        fi
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
       if test "$apu_have_pgsql" != "1"; then
         AC_CHECK_HEADER(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
         if test "$apu_have_pgsql" != "0"; then
           APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql])
-          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+          if test "$enable_lib64" = "yes" ; then
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+          else
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+          fi
         fi
       fi
     fi
@@ -88,12 +100,36 @@
       apu_have_mysql=0
     else
       CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "
+      if test "$enable_lib64" = "yes" ; then
+        if test -d $withval/lib64/mysql ; then
+          LIBS="-L$withval/lib64/mysql "
+        else
+          LIBS="-L$withval/lib64 "
+        fi
+      else
+        if test -d $withval/lib/mysql ; then
+          LIBS="-L$withval/lib/mysql "
+        else
+          LIBS="-L$withval/lib "
+        fi
+      fi
 
       AC_MSG_NOTICE(checking for mysql in $withval)
       AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
       if test "$apu_have_mysql" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        if test "$enable_lib64" = "yes" ; then
+          if test -d $withval/lib64/mysql ; then
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64/mysql])
+          else
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+          fi
+        else
+          if test -d $withval/lib64/mysql ; then
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib/mysql])
+          else
+            APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+          fi
+        fi
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
 
@@ -101,7 +137,19 @@
         AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
         if test "$apu_have_mysql" != "0"; then
           APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
-          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+          if test "$enable_lib64" = "yes" ; then
+            if test -d $withval/lib64/mysql ; then
+              APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64/mysql])
+            else
+              APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+            fi
+          else
+            if test -d $withval/lib64/mysql ; then
+              APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib/mysql])
+            else
+              APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+            fi
+          fi
         fi
       fi
     fi
@@ -133,12 +181,20 @@
       apu_have_sqlite3=0
     else
       CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "
+      if test "$enable_lib64" = "yes" ; then
+        LIBS="-L$withval/lib64 "
+      else
+        LIBS="-L$withval/lib "
+      fi
 
       AC_MSG_NOTICE(checking for sqlite3 in $withval)
       AC_CHECK_HEADER(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
       if test "$apu_have_sqlite3" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        if test "$enable_lib64" = "yes" ; then
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+        else
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        fi
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
     fi
@@ -170,12 +226,19 @@
       apu_have_sqlite2=0
     else
       CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "
-
+      if test "$enable_lib64" = "yes" ; then
+        LIBS="-L$withval/lib64 "
+      else
+        LIBS="-L$withval/lib "
+      fi
       AC_MSG_NOTICE(checking for sqlite2 in $withval)
       AC_CHECK_HEADER(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
       if test "$apu_have_sqlite2" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        if test "$enable_lib64" = "yes" ; then
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+        else
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        fi
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
     fi
diff -rNu --exclude=.svn apr-util/build.orig/dbm.m4 apr-util/build/dbm.m4
--- apr-util/build.orig/dbm.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/dbm.m4 2005-08-23 18:58:55.000000000 +0200
@@ -87,7 +87,12 @@
       ;;
       * )
         if test -d $bdb_place; then
-          LDFLAGS="$LDFLAGS -L$bdb_place/lib"
+          if test "$enable_lib64" = "yes" ; then
+            LDFLAGS="$LDFLAGS -L$bdb_place/lib64"
+echo "$LDFLAGS"
+          else
+            LDFLAGS="$LDFLAGS -L$bdb_place/lib"
+          fi
           CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
         else
           AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
@@ -183,7 +188,11 @@
     ;;
   *)
     APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
-    APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
+    if test "$enable_lib64" = "yes" ; then
+      APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib64])
+    else
+      APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
+    fi
     apu_db_header=$bdb_header
     apu_db_lib=$bdb_libname
     apu_have_db=1
@@ -589,12 +598,20 @@
       apu_have_gdbm=0
     else
       CPPFLAGS="-I$withval/include"
-      LIBS="-L$withval/lib "
+      if test "$enable_lib64" = "yes" ; then
+        LIBS="-L$withval/lib64 "
+      else
+        LIBS="-L$withval/lib "
+      fi
 
       AC_MSG_CHECKING(checking for gdbm in $withval)
       AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
       if test "$apu_have_gdbm" != "0"; then
-        APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        if test "$enable_lib64" = "yes" ; then
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+        else
+          APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+        fi
         APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
       fi
     fi
@@ -629,7 +646,11 @@
         ;;
         *)
           NDBM_INC="-I$withval/include"
-          NDBM_LDFLAGS="-L$withval/lib"
+          if test "$enable_lib64" = "yes" ; then
+            NDBM_LDFLAGS="-L$withval/lib64"
+          else
+            NDBM_LDFLAGS="-L$withval/lib"
+          fi
           AC_MSG_CHECKING(checking for ndbm includes in $withval)
         ;;
       esac

So at this point, you should have a file named patch64 in the directory /usr/local/installs/httpd-2.2.3/srclib. Of course, your directory structure might be different.

To execute the patch, enter this command:

patch –p0 < ./patch64

This will patch up the appropriate configuration files. Then you’ll need to rebuild the configuration. So delete the file [yourInstallDir]/srclib/apr-util/configure as well as the file [youInstallDir]/configure.

Then we’ll need to rebuild the configure scripts, so the from the root of the installation directory, do this: ./buildconf

That will rebuild everything necessary to configure for Apache.

Now we need to change our configuration file. My configure.p file now looks like this:

Code:
./configure \
        --enable-lib64 \
        --libdir=/usr/lib64 \
        --enable-rewrite \
        --enable-ssl \
        --enable-proxy \
        --enable-so

… this will have to assume that your lib64 is in /usr/lib64, which is the default for Fedora Core 6.

Now configure, make and make install and you’re good to go!
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #1 on: November 05, 2007, 07:43:00 PM »

Hey Perk,

Mind if I ask why you compile a new Apache instead of just using "yum install httpd"? Performance? Anal retentiveness?

Inquiring minds want to know......  ROFLMAO

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: November 05, 2007, 09:09:16 PM »

I've never been much for installers, RPMs etc. I often need machines that are a couple degrees off center, so it has just seemed easier to compile it exactly the way I want it. Got used to it, never quit.

And since it just never seems to fail that there's some little hiccup bullshit in an install, this gets me a little closer to it and *makes me feel* as thought I have more control. Wink

<edit>Minor Typo</edit>
« Last Edit: November 05, 2007, 09:31:37 PM by perkiset » Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #3 on: November 05, 2007, 09:15:23 PM »

good enough for me
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #4 on: November 08, 2007, 11:13:29 AM »

Another thing I've discovered from hand-building Apache2+PHP with funky configure options...

On RH, the build session will often grab 32-bit libraries without warning, even if the system is 64-bit, because links and library paths are often not correct.  I wasted 2 days reproducing a funky Gentoo Apache2+PHP build on RH thanks to this kind of crap at last $job.

Carefully analyze what libraries are getting pulled in if you wind up with executables that don't get created, but with no apparent compiler failures.

=RT=
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: February 18, 2008, 07:47:31 PM »

Interesting and frustrating update:

I compiled Apache on yet another new 64bit machine, but forgot to run these steps. Try as I might, I could not make clean the directory such that my patches would work.

After removing the entire directory tree and unpacking the tarball again, and doing these steps from scratch everything worked as expected.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vito
n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #6 on: October 19, 2011, 07:53:37 PM »

Hi Perkiset,

I have installed an Apache 2.2.21, however, I need to activate MySQL Support and PHP.

The problem that I have is related to  MySQL has 64bits libraries, because It was installed into our Sun Solaris 9 64 bits.

When I try to start httpd I get this message:

# ./apachectl start
httpd: Syntax error on line 60 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: ld.so.1: httpd: fatal: /opt/mysql/mysql/lib/libmysqlclient.so.15: wrong ELF class: ELFCLASS64



 Due to the information in the DB is very important, my boss don't allow me to touch this application. That's why I am looking for a way to compile 64bits Apache. I think you post can help me.

I started the procedure, but I am in trouble.

When I ran the command,
patch --p0 < patch64

I got the following message

# patch --p 0 < ./apr-util.patch64
patch: Invalid options.
patch: Usage:   patch [-blNR] [-c|-e|-n] [-d dir] [-D define] [-i patchfile]\
              [-o outfile] [-p num] [-r rejectfile] [file]

I changed the command, I get the following message
# patch -p 0 < ./apr-util.patch64
  Looks like a unified context diff.
Hunk #2 failed at line 64.
Hunk #3 failed at line 39.
Hunk #4 failed at line 74.
Hunk #5 failed at line 40.
Hunk #6 failed at line 88.
Hunk #7 failed at line 101.
Hunk #8 failed at line 133.
Hunk #9 failed at line 170.
Hunk #10 failed at line 87.
Hunk #11 failed at line 183.
Hunk #12 failed at line 589.
Hunk #13 failed at line 629.
12 out of 13 hunks failed: saving rejects to apr-util/build/apu-conf.m4.rej
don
e

What I can see is that there are a lot of failing hunks.  In order to test, I run the buildconf command and I got:

# ./buildconf
found apr source: srclib/apr
found apr-util source: srclib/apr-util
rebuilding srclib/apr/configure
buildconf: checking installation...
buildconf: python not found.
           You need python installed
           to build APR from SVN.
./buildconf failed for apr



Could you help me to compile this Apache?

My infrastructure is:

# isainfo -kv
64-bit sparcv9 kernel modules
# uname -a
SunOS dav01 5.9 Generic_118558-26 sun4u sparc SUNW,Ultra-60


Apache 2.2.21
MySQL 5.0.41 64Bits
PHP 5.3.8


All the prerequisites accomplished.

PD. If it is necessary, I will start a new topic.


Waiting for your soon answer,

Vito








Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: October 21, 2011, 03:57:45 PM »

Wow Vito, I have no idea if I can really help here.

First though, have you tried a 64B binary to see if it will even go on your machine? Here's a site with pre-compiled versions that may help you triage:

http://www.apachehaus.com/cgi-bin/download.plx

Note also that the patch on the first post is for apache 2.2.3, and you're at 2.2.21, so it's a pretty safe bet that those mods will no longer work correctly. I can't even find these patches anymore, much less a .21 version.

I can't find a lot on it, interestingly - in fact, "apache compile 64 bit" returns this board for the #1 position  ROFLMAO

The MySQL DB files are quite easily protected, although going forward to 64 bit would probably be preferable, if you can't get it to go, copying the data away and then working through a normal 32b MySQL install would not be difficult.

I regret that I don't think I can be of much help on this Vito. I just googled about to see what's out there and it's pretty shockingly dry ... j'Apologize mate  Undecided
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!