今回のOS環境: Mac OS X Yosemite 10.10.2

Apache の ./configure に失敗

Apache 2.2.29 のソースコードをダウンロードして、 ./configure してみたら失敗。


$ cd /usr/local/src/

$ wget http://ftp.tsukuba.wide.ad.jp/software/apache//httpd/httpd-2.2.29.tar.gz

$ tar zxf ./httpd-2.2.29.tar.gz 

$ cd httpd-2.2.29

$ ./configure --enable-mods-shared=all --enable-proxy=shared --enable-cache=shared --enable-disk-cache=shared --enable-mem-cache=shared
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-apple-darwin14.1.0
checking host system type... x86_64-apple-darwin14.1.0
checking target system type... x86_64-apple-darwin14.1.0

Configuring Apache Portable Runtime library ...

checking for APR... yes
  setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc"
  setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -E"
  setting CFLAGS to " "
  setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -DDARWIN_10"
  setting LDFLAGS to " "

Configuring Apache Portable Runtime Utility library...

checking for APR-util... yes
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/usr/local/src/httpd-2.2.29':
configure: error: C compiler cannot create executables
See `config.log' for more details

/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc というファイルが見つからない。


$ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
-bash: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc: No such file or directory

シンボリックリンクを張って対処


$ cd /Applications/Xcode.app/Contents/Developer/Toolchains/

$ sudo ln -s ./XcodeDefault.xctoolchain ./OSX10.10.xctoolchain

$ ls -la
total 8
drwxr-xr-x   4 root  wheel  136  4  5 21:53 .
drwxr-xr-x  11 root  wheel  374  2 27 09:08 ..
lrwxr-xr-x   1 root  wheel   26  4  5 21:53 OSX10.10.xctoolchain -> ./XcodeDefault.xctoolchain
drwxr-xr-x   4 root  wheel  136  2 27 09:09 XcodeDefault.xctoolchain

Apache を ./configure, make, make install


$ cd /usr/local/src/httpd-2.2.29

$ ./configure --enable-mods-shared=all --enable-proxy=shared --enable-cache=shared --enable-disk-cache=shared --enable-mem-cache=shared

$ make

$ sudo make install

インストールした Apache を確認


$ sudo /usr/local/apache2/bin/apachectl -V
Server version: Apache/2.2.29 (Unix)
Server built:   Apr  5 2015 21:54:09
Server's Module Magic Number: 20051115:36
Server loaded:  APR 1.4.8, APR-Util 1.5.2
Compiled using: APR 1.4.8, APR-Util 1.5.2
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Apache を起動する。


$ sudo /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using hoge.local for ServerName

http://localhost/ にアクセスすると、「It works!」と表示される。


$ curl http://localhost/
<html><body><h1>It works!</h1></body></html>

参考資料

tags: apache mac_os_x

Posted by NI-Lab. (@nilab)