Created
May 12, 2010 14:06
-
-
Save iloveitaly/398622 to your computer and use it in GitHub Desktop.
Compile PHP for OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to download & compile PHP for os x (restoration of a custom PHP installation after a system update) | |
# author: Michael Bianco <http://mabblog.com> | |
# References: | |
# http://jspr.tndy.me/2009/07/php-5-3-iconv-osx-symbols-missing-_libiconv/ | |
# http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-compiling-php-528/ | |
# http://bugs.php.net/bug.php?id=43189 | |
# you'll have to aquire a new URL here: http://us3.php.net/downloads.php when a new version of PHP comes out | |
PHP_VERSION='5.3.6' | |
wget "http://us3.php.net/distributions/php-${PHP_VERSION}.tar.gz" | |
tar -xzf php-${PHP_VERSION}.tar.gz | |
rm php-${PHP_VERSION}.tar.gz | |
cd php-${PHP_VERSION} | |
# strip the 64 bit version of apache in order to eliminate compatibility issues with 32 bit PHP | |
sudo lipo /usr/sbin/httpd -thin i386 -output /usr/sbin/httpd | |
# install some modules | |
sudo port install libpng && sudo port install jpeg && sudo port install freetype && sudo port install gd2 | |
# compile and install PHP | |
./configure --prefix=/usr --sysconfdir=/private/etc --with-libxml-dir=/opt/local --with-iconv=/opt/local/ --with-config-file-path=/etc --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-zlib-dir=/usr --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-dblib=/opt/local --with-mysql=/usr/local/mysql --with-pear --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --enable-sockets --enable-exif --enable-wddx --enable-ftp --enable-cli --enable-mbstring --enable-mbregex --enable-sockets --with-curl --with-sqlite --enable-soap --with-libxml-dir=/usr --with-readline=/opt/local | |
# have to search / replace the following: | |
# not sure if sed actually replaces the file so the text that actually needs to be replaced is shown below | |
# $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) | |
# $(CC) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(MH_BUNDLE_FLAGS) | |
cat ./Makefile | sed 's/$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS)/$(CC) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(MH_BUNDLE_FLAGS)/g' > ./Makefile | |
make && sudo make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment