Compile and install the Apache server and PHP interpreter on MacOS.

Source: Internet
Author: User
This article describes how to compile and install the Apache server and the PHP interpreter on MacOS, even though Apache and PHP are installed on Mac, however, due to the version or other reasons, it is more comfortable to configure your own configuration. For more information about how to compile and install Apache 2.2.27 and PHP 5.5.12 on Mac OS X 10.8.5, see:
Before you start, upgrade Xcode components: preferences => Downloads => Download the Command Line Tools package.

Then go to the Apache source code package. for most source code packages, you can use the following command to view the compilation options:

./configure --help

Configure compilation options:

./configure --prefix=/Users/levin/dev/apache2.2.27 --enable-modules=most --enable-mods-shared=all

Error:

checking for APR-util... yeschecking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/ccchecking whether the C compiler works... noconfigure: error: in `/Users/levin/Downloads/httpd-2.2.27':configure: error: C compiler cannot create executablesSee `config.log' for more details

The preceding error indicates the path:

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

Does not exist

Solution:

cd /Applications/Xcode.app/Contents/Developer/Toolchainssudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain

Then compile and install:

makemake install

Edit the configuration file httpd. conf. modify the listening port, the user and group running Apache, the server name, and gzip.

Go to the installed directory and start Apache:

./bin/apachectl start

Install PHP

For PHP compilation options, refer to: PHP: List of core configure options-Manual

./configure --prefix=/Users/levin/dev/php5.5.12 --with-apxs2=/Users/levin/dev/apache2.2.27/bin/apxs --with-config-file-path=/Users/levin/dev/php5.5.12/etc --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-mhash --enable-mbstring --enable-soap --enable-zip --enable-sockets --with-mysql=/usr/local/mysql-5.6.12-osx10.7-x86_64 --with-mysqli=/usr/local/mysql-5.6.12-osx10.7-x86_64/bin/mysql_config --with-iconv --with-pear --enable-opcachemake

The entire compilation process takes 5-10 minutes. depending on the hardware configuration, you can get a cup of milk first.

Error:

Undefined symbols for architecture x86_64: "_res_9_init", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o   _zif_dns_check_record in dns.o "_res_9_search", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o   _zif_dns_check_record in dns.o "_res_9_dn_skipname", referenced from:   _zif_dns_get_mx in dns.o   _zif_dns_get_record in dns.o "_res_9_dn_expand", referenced from:   _zif_dns_get_mx in dns.o   _php_parserr in dns.old: symbol(s) not found for architecture x86_64collect2: ld returned 1 exit statusmake: *** [libs/libphp5.bundle] Error 1

Solution:

export LDFLAGS=-lresolv

Error:

dyld: Library not loaded: libmysqlclient.18.dylib Referenced from: /Users/levin/Downloads/php-5.5.12/sapi/cli/php Reason: image not found...make: *** [ext/phar/phar.php] Error 133

Solution:

cd /usr/libln -s /usr/local/mysql-5.6.12-osx10.7-x86_64/lib/libmysqlclient.18.dylib libmysqlclient.18.dylib

Recompile and install:

make clean && makemake install

After the installation is complete, copy a configuration file from the PHP source code directory to The etc folder under the installation directory and change it to php. ini, you can use this file when you need to change the PHP configuration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.