23

Mac(10.8)で最新バージョンのApache Webサーバー(2.4.3)をコンパイルしようとすると、問題が発生します。./configureコマンドを実行すると、次の出力が得られました。

checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-apple-darwin12.0.0
checking host system type... x86_64-apple-darwin12.0.0
checking target system type... x86_64-apple-darwin12.0.0
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc"
  setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E"
  setting CFLAGS to " "
  setting CPPFLAGS to " -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/cti/Downloads/Applications/httpd-2.4.3':
configure: error: C compiler cannot create executables
See `config.log' for more details

ログファイルの最後の数行は次のとおりです。

## ----------- ##
## Core tests. ##
## ----------- ##

configure:3056: checking for chosen layout
configure:3058: result: Apache
configure:3861: checking for working mkdir -p
configure:3877: result: yes
configure:3886: checking for grep that handles long lines and -e
configure:3944: result: /usr/bin/grep
configure:3949: checking for egrep
configure:4011: result: /usr/bin/grep -E
configure:4027: checking build system type
configure:4041: result: x86_64-apple-darwin12.0.0
configure:4061: checking host system type
configure:4074: result: x86_64-apple-darwin12.0.0
configure:4094: checking target system type
configure:4107: result: x86_64-apple-darwin12.0.0
configure:4137: 
configure:4139: Configuring Apache Portable Runtime library...
configure:4141: 
configure:4182: checking for APR
configure:4327: result: yes
configure:4587: 
configure:4589: Configuring Apache Portable Runtime Utility library...
configure:4591: 
configure:4628: checking for APR-util
configure:4707: result: yes
configure:4968: checking for gcc
configure:4995: result: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
configure:5224: checking for C compiler version
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc --version >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -v >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -V >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5233: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -qversion >&5
./configure: line 5235: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5244: $? = 127
configure:5264: checking whether the C compiler works
configure:5286: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK   conftest.c  >&5
./configure: line 5288: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
configure:5290: $? = 127
configure:5328: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:5333: error: in `/Users/cti/Downloads/Applications/httpd-2.4.3':
configure:5335: error: C compiler cannot create executables
See `config.log' for more details

ログ出力でわかるように、。/ configureのスクリプトは、ログ出力に記載されているように含まれているので、含まれて/Applications/Xcode.app/Contents/Developer/usr/bin/ccいないため、Cコンパイラへのパスを見つけることができませんでし/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/ccた。ソリューションは単純であると言えます。構成スクリプトを変更することですよね?それに関する問題は、シェルスクリプトについて何も知らないことです。そのため、この3時間はシェルスクリプトに苦労しています。助けてください。前もって感謝します。

4

10 に答える 10

53

私が作成して回答したこの投稿で同様の問題に苦しんでいたので、調査結果を共有すると思いました. 次のようにしてシンボリックリンクを作成するだけです。

# Create a symlink to default Xcode toolchain for OS X lion
sudo ln -s \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain

# Create a symlink to default Xcode toolchain for OS X maverick
sudo ln -s \
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain

少なくとも次のステップに進む必要があります。

于 2012-11-28T00:32:10.057 に答える
11

OSX 10.9 Mavericks Apache は既にインストールされているため、直接ターミナルに移動して次のコマンドを入力できます。

Apache のバージョンを確認するには

httpd -v

始めること :

sudo apachectl start 

止まる :

sudo apachectl stop

再起動します :

sudo apachectl restart
于 2013-12-12T22:46:27.103 に答える
2

OSX Yosemite (10.10.5):

受け入れられた答えは私のために働いた:

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

$ ln -s XcodeDefault.xctoolchain/ OSX10.10.xctoolchain
                   ^                      ^
                   |                      |
             existing dir(or file)     link name

(なぜそれが機能するのかについての説明は後述します。)

それで:

httpd-2.4.18$ ./configure  (php may require an additional option)

php もインストールする場合は、./configure に別のオプションを追加する必要がある場合があります。

Unix に php をインストールするための基本的な手順には、Apache のインストール方法も記載されています。

./configure --enable-so
make
make install

Apache の構成ヘルプには次のように書かれています。

httpd-2.4.18$ ./configure --help 
...
...
--enable-so    DSO capability. This module will be automatically
               enabled unless you build all modules statically.

これは、オプションがデフォルトのオプションである可能性があることを示しているよう--enable-soですが、Apache のインストール手順には--enable-so. configureのApache 2.2ドキュメントで、次のことがわかりました。

Modules, disabled by default
Some modules are compiled by default and have to be enabled explicitly...
...
...
--enable-so
...

configureの apache 2.4ドキュメントには --enable-so について言及されていません。代わりに、--enable-so がリストされているunderの出力を確認するように指示されます。./configure --helpOptional features

その結果、次のように apache を構成する必要があると思います。

 httpd-2.4.18$ ./configure --enable-so

========

PHP のインストール

mysql を php で動作させるには、php を再インストールし、php インストール ドキュメントの次の行を変更する必要がありました。

php-7.0.2$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql

に:

php-7.0.2$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysql

最初のものでは、構成の出力は--with-mysqlオプションが存在しないことを示していました。それ以外の場合、php は正常にインストールされ、apache の php ファイルはhtdocs directoryphp によって実行されました。

問題は、phpがその mysql サポートを変更し、mysql_connect()非推奨になった (そして php7 から削除された) ことです。pdo-mysql adapter

PHPを再インストールした後、最後の行は次のようにmake install述べています:

You may want to add: /usr/local/lib/php to your php.ini include_path

php.iniはここにあります: /usr/local/lib/php.ini、そして私はその変更を行いました:

include_path = ".:/php/includes:/usr/local/lib/php"

次に、Apache を再起動し、mysql が実行されていることを確認し、ブラウザに次の URL を入力しました。

http://localhost:8080/mysql_test.php

私のテストPDOスクリプトは機能しました(ディレクトリ/usr/local/apache2/htdocsにあります):

<?php

$user = 'root';
$password = ’root_password_here’;
$host = 'localhost';
$dbname = 'my_db';


$pdo = new PDO(
    "mysql:host=$host; dbname=$dbname", 
    $user,
    $password
);

$statement = $pdo->query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['_message']);

?>

===========

op と同じエラー メッセージが表示された後、ディレクトリをチェックインconfig.logするhttpd-2.4.18と、次のような行が表示されました。

./configure: line 5326: /Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin/cc: 
No such file or directory

したがって、構成スクリプトは次のものを探しています。

  1. 次の名前のディレクトリ:

    /Applications/Xcode.app/Contents/Developer/ Toolchains/OSX10.10.xctoolchain/usr/bin/

  2. そのディレクトリで名前が付けられたファイルcc

ccさて、そのディレクトリにあるかどうか見てみましょう:

~$ cd/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin/

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

つまり、ディレクトリが存在しません。ここで、その長いパスのどのディレクトリが存在しないかを把握する必要があります。

~$ cd /Applications/Xcode.app
/Applications/Xcode.app$ cd Contents/Developer
/Applications/Xcode.app/Contents/Developer$ cd Toolchains/OSX10.10.xctoolchain

-bash: cd: Toolchains/OSX10.10.xctoolchain/: No such file or directory

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

XcodeDefault.xctoolchain

という名前のディレクトリがないことがわかります -- という名前OSX10.10.xctoolchainのディレクトリだけがありXcodeDefault.xctoolchainます。その結果、configure スクリプトはOSX10.10.xctoolchain、ファイルの検索に使用しているパスでディレクトリを見つけることができませんccconfigureがそのディレクトリを探しているのはなぜですか? スクリプトを書いた開発者が失敗したか、Apple が失敗したかのどちらかです。

の本当の目的はconfigure、ディレクトリを見つけることではなく、厄介なccファイルを見つけることです。ファイルは次の場所にあることccがわかります。

/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin$ ls
...
cc
clang       
...
...

そして、より好奇心旺盛な人のために:

/Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin$ ls -al cc

lrwxr-xr-x  1 7stud  admin  5 Oct 29 15:22 cc -> clang

ccXcode の clang コンパイラへの単なるリンクです。

OSX10.10.xctoolchain受け入れられた回答は、名前から実際にファイルを含むディレクトリへのリンクを作成しccます(ただし、いくつかのディレクトリがより深くなります)XcodeDefault.xctoolchain

Applications/
  Xcode.app/
    Contents/
      Developer/
        Toolchains/
          XcodeDefault.xctoolchain/
          OSX10.10.xctoolchain/ -> XcodeDefault.xctoolchain/
            usr/
              bin/
                 cc 

つまり、リンクを作成した後、2 つのパス:

/Applications/Xcode.app/Contents/Developer/Toolchains/
XcodeDefault.xctoolchain/usr/bin

/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain/usr/bin

同等になります。名前XcodeDefault.xctoolchainOSX10.10.xctoolchainは、同じディレクトリのエイリアスになります。

====

わかりません@AlphaZygma's answer。次の 2 つのディレクトリを (/etc/paths 経由で) PATH に追加することをお勧めします。

/Applications/Xcode.app/Contents/Developer/usr/bin

/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.8.xctoolchain/usr/bin
  1. 私のシステムでは、最初のディレクトリにccファイルが含まれていないため、そのディレクトリを PATH に追加する必要はありません。

  2. 2 番目のディレクトリは、configure が見つからないと言うディレクトリです。存在しないディレクトリを PATH に追加しても、それは存在しないことを意味します。

  3. いずれにせよ、configure スクリプトは PATH ディレクトリを検索していないようです。ccこれは、エラー メッセージに存在しないパスが問題としてリストされているためです。PATH ディレクトリを検索すると、存在しないパスをリストするエラー メッセージが表示されるのはなぜですか? configure スクリプトは、他のどこかから指示を受けて、 を検索する場所を伝えているようですcc

  4. @AlphaZygma が の既存のパスのいくつかの間に新しいパスを挿入した理由がわかりません/etc/paths。既存のパスの下に新しいパスを追加してみませんか?

この回答のいくつかの異なるバージョンを試しましたが、何もうまくいきませんでした。

====

私はの出力を見ました./configure --help

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

...
...

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor

ねえ、そこに CC がリストされています。やってみよう:

$ ./configure CC=/Applications/Xcode.app/Contents/Developer/
Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

...
...

checking for APR... yes
  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 " "
configure: 
...
...
configure: error: C compiler cannot create executables

出力をもう少し注意深く見ると、次の行があります。

      setting CPP to "/Applications/Xcode.app/Contents/Developer/Toolchains/
OSX10.10.xctoolchain 

構成スクリプトは、CPP と組み合わせて、存在しないパスについてまだ言及しています。./configure --help再び出力を見る:

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

...
...

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor

最後の行には、エラー行で言及された変数 CPP がリストされています。やってみよう:

$ ./configure \
> CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
> CPP=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc 

...
...

checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
configure: error: in `/Users/7stud/Downloads/httpd-2.4.18':
configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" fails sanity check
See `config.log' for more details

これで、エラー メッセージのすべてのパスが正しくなりましたが、何かが「サニティ チェックに失敗」しています。あきらめる!たぶん、他の誰かが私が中断したところから始めることができます.

さて、ここでの提案のおかげで、次のように動作します:

$ ./configure \
> CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
> CPP='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -E'

これは次のように短縮できます。

$ ./configure \
> CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
> CPP='cc -E'

しかし、その後make失敗しました:

$ make
...
/usr/share/apr-1/build-1/libtool: line 8962: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc: No such file or directory

もう一度、存在しないパスが言及されています。今回はlibtool. それは私がそのうさぎの穴を下る限りです。

于 2016-01-18T20:08:44.407 に答える
0

通過できる完全なソリューション:

checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no

問題はここにあります: http://mac-dev-env.patrickbougie.com/apache/

コマンドは次のとおりです(sudo suが必要なものもあります):

cd /usr/local/src (mkdir /usr/local/srt if /usr/local/src doesnt exist)
curl --remote-name http://mirror.csclub.uwaterloo.ca/apache/httpd/httpd-2.4.9.tar.gz
tar -xzvf httpd-2.4.9.tar.gz
rmhttpd-2.4.9.tar.gz
cd httpd-2.4.9

sudo xcode-select -switch /
mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin (this might require sudo su)
ln -s /usr/bin/cc /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc (this might require sudo su)

./configure --prefix=/usr/local/apache-2.4.9
make
make install

ln -s apache-2.4.9 /usr/local/apache
于 2014-05-31T08:41:46.970 に答える
0

シンボリック リンクを作成する代わりに、パスをライブラリ パスに追加し、OSX バージョンに適切なディレクトリを使用するだけです。

したがって、あなたの場合、次のようになります

[user@host ~]$ sudo vi /etc/paths
/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin
/bin
...

このアプローチは、さまざまなツールで期待されるように、さまざまな場所にシンボリックリンクを追加する必要がないため、少しクリーンだと思います。

とにかく、これは単なる代替ソリューションです。

お役に立てれば。

于 2013-10-31T05:32:02.600 に答える