Fedora 8 howto rebuild custom PHP? - php

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.

Related

How to build SQL Relay for PDO from source on windows?

I am trying to integrate SQL Relay with PHP PDO on Windows (WAMP). I have installed and compiled Rudiments and SQL Relay on Windows through Visual Studio Developer Command Prompt following the instructions given on the Rudiments and SQL Relay SourceForge pages.
Then I downloaded the pdo_sqlrelay extension source from github and tried to build the dll for this extension.
In the build instructions, I couldn't find the ones pertaining to Windows specifically. I found instructions related to Linux. They are:
cd /path/to/pdo_sqlrelay
phpize
./configure --with-php-config=/path/to/php-config \
--with-pdo-sqlrelay=/path/to/sqlrelay/prefix \
--with-rudiments=/path/to/rudiments/prefix
make
make install
I tried to convert them to the relative Windows commands by following the step by step php extension build instructions on PHP's Wiki for building for Windows.
When I tried to execute the command, it threw a fatal error. (like undefined or invalid $remains).:
configure --disable-all --enable-cli --enable-$remains
I would appreciate if someone could help me out to build the pdo_sqlrelay extension on Windows.
you need to ...
first run bin\phpsdk_setvars.bat
to set up the build environment, so that $remains will be known as a variable.
then configure the build with buildconf (or buildconf --force for rebuilding).
then configure --disable-all --enable-cli --enable-$remains ... you probably might also want to --disable-zts (depending which PHP is being used).
it's rather nmake to build & nmake clean to clean.
to install & uninstall it's nmake install and nmake uninstall.
the documentation also states ...that:
First build and install Rudiments, then build and install SQL Relay.

Cannot find libmysqlclient under /usr. while build PHP 5.2 from source on Ubuntu 12.4

I was trying to build PHP 5.2.17 from source on Ubuntu 12.4 64bit using this configuration:
./configure --prefix=/opt/php5.2 --with-config-file-path=/opt/php5.2 --with-mysql
but I keep getting this error:
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!
Any Idea how to resolve this?
EDIT1: I minimized the configure command so it just focuses to mysql. also I'm running a 64bit version of ubuntu.
EDIT2: tried running ldconfig -v |grep mysql and here is the output
# ldconfig -v |grep mysql
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Cannot stat /usr/lib/x86_64-linux-gnu/libnss_db.so: No such file or directory
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
libmysqlpp.so.3 -> libmysqlpp.so.3.1.0
Thanx #hakre for the assistance.
here is the command I used and it works:
sudo ./configure --prefix=/opt/php5.2 --with-config-file-path=/opt/php5.2 --with-mysql --with-libdir=/lib/x86_64-linux-gnu
Maybe for some poor soul this will work:
./configure --with-apxs2=/usr/sbin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

Cross compiling php

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

Source install Apache 2.2.13 + PHP 5.3 + Snow Leopard

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.

Installing Html Tidy

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/

Categories