I'm running Mac OS X with Apache/2.0.59 (Unix) PHP/5.2.5 DAV/2. I've never administered Apache or PHP before so somethings aren't really that obvious to me.
I'm trying to get PHP Tidy to run as mentioned here http://th.php.net/manual/en/tidy.installation.php
It says I need to "In PHP 5 you need only to compile using the --with-tidy option." but I just don't understand how to do this and this is after 1 hour of trying to googling it!
Help please!
Go here to get started http://us.php.net/manual/en/install.php. Also consider this, this and this.
You will need to read up on how to compile PHP. It is done from the command line so if you aren't comfortable with that, be careful. Also be aware that the specifics for compiling on the Mac are very detailed and one tiny slip results in a hosed install.
Since you are on a Mac look at Marc Liyanage's packages (though I don't know if they have Tidy configured). Also consider using MacPorts to do all of this (especially useful for making sure you have all dependancies installed). If you must do it from scratch please understand that you really need to know what you are doing.
That out of the way:
The basic process is to configure, make, make install.
Here are some sample configurations (do NOT use these. The paths are specific to certain installations and you will have different ones. This is just to show you what the config can look like):
./configure --with-mysql=/Applications/MAMP/Library --with-apxs2=/Applications/MAMP/Library/bin/apxs --with-gd --with-jpeg-dir=/Applications/MAMP/Library
./configure --prefix=/usr/local/apache2/php --with-zlib --with-xml --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
So you would need to add --with-tidy to that list along with any of the other config options you need/want.
Here is another example showing make and make install (notice --with-tidy at the end):
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-curl --with-gd --enable-exif --enable-fastcgi --enable-zip --with-ldap=/usr --with-kerberos=/usr --with-zlib=/usr --enable-ftp --enable-sockets --with-iodbc=/usr --with-config-file-path=/etc --with-openssl --with-xmlrpc --with-xsl=/usr --with-tidy=/usr/bin/tidy
make
sudo make install
Read up on this and be prepared to have to do it several times to get it right (the whole process takes a while, too)
You might also look at using a pre-compiled php-tidy module for OS X. It comes packaged with projects like Zend IDE.
In case you don't have ready access to such a project, download it from here: http://projectbee.org/blog/archive/download-php-tidy-extension-for-mac-os-x/
Related
I've been trying to build and link libphp5.so using the --enable-embed configure option, on OSX. This doesn't complete successfully, failing primarily because of object files not being found during the linking stage.
There are reports that the --enable-embed option has been broken on OSX for a long time.
Has anybody had any success doing this, linking and embedding the Zend Engine functions into a C/C++ app?
I finally managed to do this after lots of failed attempts. Here is a configure string that will build the libphp5.a library on OSX for PHP 5.3.6:
./configure --enable-embed=static --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-iconv
Then, when linking to C/C++ code, you need to add libresolv to prevent link errors relating to DNS functions in the Zend Engine. For example:
g++ -o yourapp src/main.o -Lpath/to/libs -lphp5 -lresolv
Hope this helps somebody one day :-)
I use some like this:
CFLAGS='-m32 -m64' LDFLAGS='-m32 -m64' CPPFLAGS="-m32 -m64" ./configure --prefix=/usr/local --disable-cli --enable-embed --build="build folder" --with-iconv-dir=/usr/local/opt/libiconv/
And enable cli later with phpize, this work with 5.2.10 and up.
Edit:
look here: http://forums.wxphp.org/viewtopic.php?f=6&t=42 it is my full resolution with makefile etc... for 5.4.17.
I'm trying to cross compile php for arm and have good progress but I'm totally stuck where it wants to run the php itself (have no idea why). as it is an arm binary and not intel (my building platform) it won't run:
/bin/sh: /path-to-build/sapi/cli/php: cannot execute binary file
How can I fix this? The configure script understood I'm cross compiling but didn't do anything about it (from configure log):
checking whether the C compiler (/path-to-compiler/arm-none-linux-gnueabi-gcc) is a cross-compiler... yes
I'm compiling php-5.3.6 with configure command line:
export CC=/path-to-cc/arm-none-linux-gnueabi-gcc
../configure --prefix=/prefix-path/ --host=arm-none-linux-gnueabi
--disable-libxml --disable-dom --disable-openssl
--without-iconv --without-openssl --disable-simplexml
--disable-xml --disable-xmlreader --disable-xmlwriter
--without-pear --without-sqlite --without-sqlite3
--disable-pdo --without-pdo-sqlite
I was able to resolve this my own by disabling phar. I hope disabling so much modules won't break something internal.
Build without cross compiling and then, when cross compiling, point to the host version of php by overrididing a variable in the makefile on the command line when running make.
Something like:
make PHP_VAR_NAME=path to php built for host
I managed to compile PHP for arm with the following parameters:
export PATH="$PATH:/toolchains/gnu_cortex-a9_tools/usr/bin"
export ARCH=arm
configure script:
./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-uclibcgnueabi --prefix=/usr/arm CC="arm-linux-uclibcgnueabi-gcc --sysroot=/toolchains/gnu_cortex-a9_tools/" --disable-libxml --disable-dom --without-iconv --without-openssl --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --without-sqlite3 --disable-pdo --without-pdo-sqlite --disable-phar
followed by
make
I managed to solve similar issue while cross-compiling PHP 5.6.0 by editing Makefile after running configure script. Just replace all occurrences of
$(top_builddir)/$(SAPI_CLI_PATH)
with
/usr/bin/php
Where /usr/bin/php is your host php cli. Make sure it is installed, e.g., sudo apt-get install php5-cli for Debian/Ubuntu.
After doing so phar extension builds fine
Here is a quick overview:
I just finished compiling PHP 5.3.5 and made the attempt to compile "--with" a number of different extensions. Among the extensions that I need are mbstring and intl. I can manually phpize, configure, make, make install the mbstring extension and it seems to work fine. However, I am unable to do the same for intl.
My ./configure line looks like this:
./configure --with-openssl --with-pcre-regex --enable-calendar
--with-curl --enable-exif --enable-ftp --with-gd
--with-mhash --enable-mbstring --with-mysql --enable-zip
--enable-intl --with-icu-dir=...
The code compiles without problem: ./configure... make, make install
I used the php.ini-production for my php.ini configuration and I configured Apache to use php-cgi for a specific domain, and that works fine as well.
A quick:
<?php phpinfo() ?>
reveals that I am in fact running the newer version of PHP. However, the extensions specified in the "./configure..." line do not show up anywhere on the PHP info page.
After a bit of scouting I found that I could run phpize on a single extension in the PHP source folder, then compile a build of the specific module and install it in my PHP extension directory. After adding:
extension=MY_EXT
in my php.ini, the extension showed up on my phpinfo() page.
So can anyone explain why --with-mbstring doesn't seem to have an effect on my compilation?
I had no compilation problems for the intl extension, but moving the intl.so file to my PHP extensions directory and adding an extension line in my php.ini has no effect.
From php.net, have you tried
If your ICU is installed to a
non-standard directory then you might
want to specify its location in
LD_LIBRARY_PATH environment variable
so that dynamic linker can find it: $
export LD_LIBRARY_PATH=/opt/icu/lib
Otherwise, if PHP and ICU are
installed to their default locations,
then the additional options to
`configure' are not needed.
Can anyone direct me to or write their experiences installing Apache and PHP on Snow Leopard?
I had this working in the past on Leopard, it would die after a security update, but was as simple as:
$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install
and I was up and running again.
Since the Snow Leopard update I get the following issue on make command
libtool: link: cannot find the library `/usr/lib/libexpat.la' or unhandled argument `/usr/lib/libexpat.la'
make[2]: *** [htpasswd] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
As most of you know Snow Leopard (SL) is based on 64-bit architecture, and when you install Xcode 3.2 that comes with SL the gcc compiler defaults to 4.2.1 and seems to default to x86_64 not i386.
Thanks to the following websites:
http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/
http://projects.serenity.de/php/
http://dawsdesign.com/drupal/comment/reply/30#comment-form
http://pixelchimp.net/blog/pixel-chimp/reverting-php-53-5210-snow-leopard(most helpful for finding the other sites)
http://www.kevinkorb.com/post/24
http://www.latko.org/2009/01/31/compiling-64-bit-apachephp-on-mac-os-x-1056/
http://www.gen-x-design.com/archives/recompiling-php-5-3-on-snow-leopard-with-freetype-support/
My Solution:
Follow the instructions on hivelogic.com for installing MySQL on SL
Install Apache 2.2.14 via instructions on http://projects.serenity.de/php/ - it uses 2.2.13 but replacing a 13 with a 14 is easy right? ;) After Apache (x86_64) is installed do the following:
cd /usr/local/apache2/bin
cp httpd /usr/sbin/
cp apachectl /usr/sbin/
As mentioned on http://www.kevinkorb.com/post/24
Compile and install packages (freetype,gettext,libjpeg,libpng,mcrypt,mhash,etc) mentioned right after the Apache install instructions on http://projects.serenity.de/php/ until IMAP, if you need IMAP then try the instructions mentioned in the url above but I didn't install since I didn't need it.
NOTE: These all compiled as x86_64 with the exception of libpng which required the the following to be compiled as 64-bit:
*export CFLAGS="-arch x86_64" ./configure
This is where all the head banging on a desk and trial and error occurred. The installation of PHP 5.3.0. The biggest issue is with ICONV which has linking issues. I searched all over Google and some others were successful by editing the iconv.c file and the Makefile by adding -lresolv to the EXTRA_LIBS= after the ./configure string was executed. I was not so lucky, but still needed to make the edits for the --without-iconv parameter to work. Also --with-xmlrpc would not work. For the iconv hacks please refer to this blog entry
So here is my ./configure string:
./configure
--prefix=/usr/local/php5
--without-iconv
--with-apxs2=/usr/local/apache2/bin/apxs
--enable-pdo
--with-gd
--with-zlib
--with-jpeg-dir=/usr/local
--with-png-dir=/usr/local
--with-libxml-dir=/usr/local
--with-curl
--with-mcrypt
--with-pdo-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-mysql=/usr/local/mysql
--with-mhash
--with-libxml-dir=/usr/local
--with-t1lib=/usr/local
--with-xsl
--with-freetype-dir=/usr/local
--with-gettext
--with-bz2=/usr
--with-openssl=/usr
--enable-bcmath
--enable-calendar
--enable-cgi
--enable-exif
--enable-ftp
--enable-gd-native-ttf
--enable-mbstring
--enable-soap
--enable-sqlite-utf8
--enable-cli
--enable-wddx
--enable-zip
make
sudo make install
On a final note, I downloaded PHP-5.3.2-dev (http://snaps.php.net/) and it seems to have fixed the linking issues with ICONV and XMLRPC. The only changes that I've made to the above ./configure string were replace --without-iconv with --with-iconv=/usr/local and added --with-xmlrpc. This is a dev version and I am sure that it still has bugs so use at your own discretion.
If you are having any issues please feel free to comment and I will try to help!
See here:
http://bugs.php.net/bug.php?id=49267
Basically:
Add "-lresolv" to MH_BUNDLE_FLAGS, EXTRA_LDFLAGS and
EXTRA_LDFLAGS_PROGRAM in "Makefile"
Change "ext/iconv/iconv.c"
#define iconv libiconv
to:
#define iconv iconv
As they say, worked for me.
In apache source directory
cd srclib/apr-util/xml/expat
./configure
# OR ./configure --prefix=/{{YOURDIR}}/apache/source/httpd-2.2.22/srclib/apr-util/xml/expat/
sudo make install
# OR make install
Remember to clean up your previous apache install after make install failed
cd {{YOURDIR}}/apache/
ls -la
rm -r bin
rm -r build
rm -r include
rm -r lib
Well if you have no need for a custom built version of PHP than perhaps the one Apple provides will do, but that is not the case, with the person who asked the question, or me for that matter as I seek an answer to the same question. Does anyone else have a suggestion?
Maybe you didnt install the developer tools!
The guys from Liip maintain a great package for PHP and Apache on OS X, with really easy install. The package is very suitable for development. You could check it out here: http://php-osx.liip.ch/
This package installs the (usually) latest PHP 5.3.x/5.4.x on OS X 10.6 (aka Snow Leopard) and OS X 10.7 (aka Lion) in /usr/local/php5. It installs many useful extensions (see below) and ini-settings and is what we at Liip and Local.ch use for our development. It's especially suited for Symfony 2 development. It also provides a decent php.ini with all settings configured according to "Best Practices".
You can then use the standard Apache and install MySQL (x64) with the package from the MySQL website.
Mac OS X Snow Leopard already comes with Apache 2.2 and PHP 5.3 pre-installed. Please see:
http://www.brandonsavage.net/first-glance-apples-snow-leopard/
It is probably best to leave those alone, as they are optimally configured for Snow Leopard.
I am running a wiki server for my group at work and recently moved it to a Fedora 8 OS. Everything works great except that an extension I wrote that contacts an MsSql server fails because the function mssql_connect is not there.
On my old server I used "Free TDS" (with ./configure --prefix=/usr/local/freetds --enable-msdblib) and built PHP with:
./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mssql=/usr/local/freetds \
--enable-safe-mode \
--enable-ftp \
--enable-inline-optimization \
--enable-magic-quotes --enable-xml \
--with-gd \
--with-zlib-dir=/usr/lib \
--with-jpeg-dir=/usr/local/lib
Is there a way I can easily rebuild PHP with the "--with-mssql=/usr/local/freetds" configuration on Fedora? I would like to use yum to do this, but I don't see how. More to the point, I would like to avoid having to build everything from scratch. It's not that I don't know how, I would just like to avoid it.
Thanks for your your advice,
~Eric
Please post output from your build. Is it failing because /usr/local/freetds is missing?
If it is, can you use yum to install it, or download and compile freetds yourself. I haven't done this but it'll be something like this...
Open shell and navigate to directory with freetds archive.
Execute tar zxvf to extract.
Execute cd
Run ./configure for the freetds build
Run make, (sudo) make install
Then find where freetds is installed and pass that folder to the ./configure command for PHP.
So, the answer to adding mssql is as easy as "yum install php-mssql". Fixed my problem without any messing around. FreeTDS is installed an easily configurable. Thanks everyone who tried to answer or left a comment.
Get SQL Server Driver for PHP, I don't think that you have to rebuild php to use this driver. I suggest you to use vendor's driver.