Welcome, Guest. [ Log In ]
Question   Compiling your own custom PHP
Search KBase


Top 5 in this Area:
1. What's the difference between PHP-CGI and PHP as an Apache module?
2. PHP Security
3. Compiling your own custom PHP
4. Can I run a phpbb forum (message board) on my site?
5. Do you support this PHP module or extension?

 
Compiling your own custom PHP
If you need to use PHP modules we do not support, you can (if you're lion-mettled) compile PHP in your home directory and tell PHP scripts to use this binary instead of the default system PHP binary.

http://php.net has good instructions for compiling, and once that's completed, you can make it work like this.

Let's assume that you installed PHP into /home/username/php/. The binary is /home/username/php/bin/php. Your domain is hosted from /home/username/domain.com.

Copy that binary into some location accessible from your domain (cgi-bin/ is a good idea). So:

cp /home/username/php/bin/php /home/username/domain.com/cgi-bin/php

For the sake of maximum ease, rename the PHP binary to end in .cgi:

mv /home/username/domain.com/cgi-bin/php /home/username/domain.com/cgi-bin/php.cgi

Now create an .htaccess file to redirect all PHP requests to this PHP binary intead of going through the default system PHP binary. Put this inside:

AddHandler custom-php .php .pcgi
Action custom-php /cgi-bin/php.cgi

Note: You can use whatever extension(s) in the AddHandler line. Separate multiple entries with spaces.

Make sure that the Action line points to a useful URL. In the example above, it points to http://domain.com/cgi-bin/php.cgi. If your PHP binary is in a different location, use a different URL. And keep in mind that it's a URL (sans domain name), NOT a path for the filesystem. Don't forget that first slash!

Good luck!

Last updated: Dec 29, 2004.

User Post (2005-12-31 14:15:27 by johnjosephbachir)
Here is how i got php5 compiled and working happily on my account:

http://blog.johnjosephbachir.org/?p=231
User Post (2005-08-12 04:07:52 by ping1434)
Another Addition :) For people wanted specific IMAP installed, but also includes other useful things. I run vbulletin board, and some optimization modifications were needed for IMAP support, so here it is, a simple follow the step to getting everything done. but not sure if it'd work on regular users, as i'm on dedicated.

http://www.ffxionline.com/dhphp/index.html

Hope it helps!
User Post (2005-04-22 10:45:19 by marcoorg)
I've compiled PHP4 successfully, but the Apache configuration is not working. I've followed all of the instructions - copying the binary to (my www dir)/cgi-bin/php.cgi, chmodding cgi-bin 755, and editing the (www dir)/.htaccess file with the lines given. The binary is executable, and works perfectly fine from the command line.

But when I try to access a PHP page with a browser, I get "Unexpected T_STRING" parse errors for *within* the binary! It seems as though PHP is somehow parsing its own binary.

http://marco.dreamhosters.com/info.php (should be phpinfo())

Help?
User Post (2005-04-04 15:14:50 by porges)
Anybody wishing to compile PHP 5 with MySQL support should check on the wiki:

http://wiki.dreamhost.com/index.php/Installing_PHP5
User Post (2005-03-31 11:03:13 by psross)
I've managed to get PHP 5 compiled and working with MySQL (using the system MySQL libraries in /usr). The following is a log of what I did to compile it. Once built, you'll have to copy the php binary to cgi-bin and modify your .htaccess file as described above.

---

mkdir ~/php

mkdir -p ~/src/php
cd ~/src/php
wget http://us3.php.net/distributions/php-5.0.3.tar.bz2
tar -xjf php-5.0.3.tar.bz2
mkdir php5libs
cd php5libs
wget http://cogent.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz
wget http://xmlsoft.org/sources/libxml2-2.6.18.tar.gz
wget http://xmlsoft.org/sources/libxslt-1.1.13.tar.gz
wget http://www.zlib.net/zlib-1.2.2.tar.gz
tar -xzf libmcrypt-2.5.7.tar.gz
tar -xzf libxml2-2.6.18.tar.gz
tar -xzf libxslt-1.1.13.tar.gz
tar -xzf zlib-1.2.2.tar.gz

cd zlib-1.2.2
nice ./configure --prefix=~/php --shared
nice make
nice make install

cd ../libxml2-2.6.18
nice ./configure --prefix=~/php --without-python
nice make
nice make install

cd ../libxslt-1.1.13
nice ./configure --prefix=~/php --with-libxml-prefix=~/php --without-python
nice make
nice make install

cd ../libmcrypt-2.5.7
nice ./configure --prefix=~/php --disable-posix-threads
nice make
nice make install

ln -s /usr/lib/libltdl.so.3 ~/php/lib/libltdl.so

cd ../../php-5.0.3
nice ./configure \
--prefix=~/php \
--enable-force-cgi-redirect \
--with-mcrypt=~/php \
--with-zlib-dir=~/php \
--with-mysql=/usr \
--with-xml \
--with-libxml-dir=~/php \
--with-openssl=/usr \
--with-xsl=~/php \
--enable-mbstring \
--enable-mbregex
nice make
nice make install
User Post (2005-02-20 23:30:45 by protonage)
Anyone have a working solution for compiling php5 and mysql4 yet? There must be a way!
User Post (2005-02-17 08:30:52 by swedesign)
Is there any way to get the IMAP extention in PHP without having to install the full PHP-package?
User Post (2005-02-16 07:29:40 by jcisio)
In order to answer @jayeshsheth:
By following http://www.moztips.com/php5_install/ I've just successfully compiled PHP 5.0.3. My site (written in PHP4) works normally in PHP5, only a slightly error is that some values in $_SERVER changed (eg. IP varibles).
I downloaded mysql-4.0.23a (src) when compiling and it's ok (instructions on the site below don't have mysql).
----- Detail: (you're supposed to follow the instructions below)
wget http://dev.mysql.com/get/Downloads/MySQL-4.0/mysql-4.0.23a.tar.gz/from/http://my sql.he.net/
tar -xzvf mysql-4.0.23a.tar.gz
cd mysql-4.0.23a
./configure --prefix=/home/myaccount/php/lib
make > /home/myaccount/install_logs/mysql_make.txt
make install
------------
then add "--with-mysql=/home/myaccount/php/lib" when configuring PHP.
It misses some features, like FastCGI, FreeType support... but I think we could add them when we run configure.
User Post (2005-02-12 10:58:23 by jayeshsheth)
A note of caution:
PHP 5 - for some unknown reason - cannot compile against Dreamhost's system MySQL client libraries ( in usr / ). I.e. it fails to compile with the directive --with-mysql=/usr .

If you compile the MySQL 4 client libraries locally and then compile PHP 5 against those libraries, it will work, but the PHP 5 binary will crash whenever it encounters a mysql_ function in a script. This will, in turn, produce a "500 Internal Server Error" as Apache cannot get any output from the crashed PHP 5 binary. I do not know what the solution to this could be.

I tried compiling PHP 4.3.10 with the bundles MySQL client libraries that come with all PHP 4.x distributions ( by using --with-mysql ) and this seemed to work.

But the problem is that PHP 5 does not come bundled with the MySQL client library any more.

So, it seems it is possible to compile PHP 5 on Dreamhost, but not with MySQL support.

If anyone has a solution, please post it here.

Thanks.
User Post (2005-02-09 19:17:07 by jayeshsheth)
Hello pikkle,

you are right - it is perhpas not necessary to compile all the libraries that PHP depends on (such as the MySQL client libraries). But I included instructions on this to be on the safe side - because sometimes PHP's binary cannot be linked against system libraries due to PHP 5 needing newer versions of libraries than those installed on the system.
User Post (2005-02-06 23:36:36 by pikkle)
moztips: a truly invaluable document. thanks so much.

but is it needed to download the latest version of all those patches? i thought the DH config includes defaults for many things, which might speed up the install process a lot...
User Post (2005-01-20 18:17:30 by jayeshsheth)
I have written up a detailed, step-by-step document on setting up PHP 5 on Dreamhost:

http://www.moztips.com/php5_install/
User Post (2004-12-31 11:49:04 by rsim)
From hunsvotti's (very useful!) post on compiling your own PHP:
-----------------------------------------------
This all ran great, but then when I ran make it got an error because it couldn't find one of the header files for libxml2. I opened Makefile and found the "INCLUDES = blah blah" line and put the proper paths in the beginning.
-----------------------------------------------

To fix this so that you don't need to edit the Makefile _at all_, you should use --with-dom=$HOME/usr - ommiting the directory as was originally stated causes PHP to be compiled against the version of libxml installed in /usr/lib, not /home/username/usr/lib.
User Post (2004-12-30 23:37:16 by jbyers)
A note on setting the location of your php.ini file. Make sure you set --with-config-file-path to the directory containing php.ini, not the location of the file itself.

For example, "--with-config-file-path=/home/username/etc/" will find the file "/home/username/etc/php.ini".

However, "--with-config-file-path=/home/username/etc/php.ini" will fail to find "/home/username/etc/php.ini"! In a pinch, you can get around this without recompiling by putting the file at "/home/username/etc/php.ini/php.ini".

http://www.php.net/manual/en/configure.php#configure.with-config-file-path

kappa noted this way back in the first post in this thread, but it's been a mistake in several examples since then. I've verified this behavior with PHP 4.3.10.

James
User Post (2004-12-20 03:23:19 by sleepyrobot)
This is a long message. I hope it is helpful.

I spent some time installing PHP5 on my Dreamhost server, so I'll take a minute to explain my procedure below. Thanks to Pikkle and others who have documented their experiences -- their help was invaluable.

My comments are specifically geared to people who are not familiar with Linux and are in a little bit over their heads.

For the most part, if you follow slimc's link to pointbeing.net, and just change the path in each step and read Pikkle's notes *before* trying to do the install, it will not be too difficult to get a basic installation working, even if you are not a Linux expert. For a simple install, I think you can just skip all the stuff in pointbeing's directions except libxml and php.

However, if you want to get some additional libraries (mcrypt, libinconv, xsl, gd's jpeg libs) working, you have have a bit more work ahead of you. Although a basic installation could be completed quickly (less than an hour), any installation involving extra libraries, even without glitches, will probably take you 1.5 to 2 hours -- much more if you start running into frustrating complications.

Let me begin by saying that because everyone's needs are different, and because things can change somewhat rapidly, it is difficult to provide a step-by-step, line-by-line "type this, then type this" account of how to do the install. This post is just intended to describe the basic principles and help you with some obstacles you might run into along the way.

BASIC CONCEPTS
Essentially, you are going to download a bunch of files into a directory, uncompress them, prepare them to be compiled, compile them ("make"), and install them. The tricky part comes when some files depend on others -- if you screw up the installation of one, then all the files that depend on it won't work, but you might not realize that immediately when it happens.

INSTALLATION
1. Telnet or SSH to your server.

2. Create a directory where you will install PHP. This should be at or near the top level of your account, in a non-web-accessible directory. Call it "bin" or "php" or something. For the rest of these instructions, I'm going to assume you called it "php." The path to it will be /home/yourusername/php/, where "yourusername" is your username and php is whatever you called the directory.

3. cd into that directory and follow the blocks of instructions for Zlib and Libiconv at pointbeing: http://www.pointbeing.net/howto/index.php/installphp5/ , skipping the first set of instructions about installing Apache, since Apache is already installed on your server. Wherever it says "--prefix=/usr/local/", change it to "--prefix=/home/yourusername/php"

Before downloading these files and the ones mentioned below, in most cases you should visit the official page for that software at sourceforge or xmlsoft or wherever and find out what the latest version is. Then, replace the filename in pointbeing's directions with that latest version number. You can use wget to download every file mentioned in pointbeing's instructions -- but because of the way sourceforge's mirroring/redirecting system works, it might take a minute for you to figure out the exact path of the files on the servers. You can just use your browser to begin the download, and then copy the URL of the file from your browser window and use it for your wget command. If a file won't uncompress with tar -zxvf, it's probably because you downloaded an html file instead of the actual tar.gz file, even though the url you passed to wget ended with ".tar.gz." (Test this theory by doing "more filename.tar.gx" -- if a bunch of html shows up, that's the problem.)

Note: for each piece of software you download, there is a text file in its folder (available once you uncompress it) called "INSTALL". You can read this file by typing "more INSTALL" from the command line. It often gives you helpful tips for properly installing the software. (Imagine that, right?) Reading the README's is also a good idea, and gives you good info about dependencies.

Also, when you run the "configure" step for each file, you can optionally run "configure --help" first, and get an explanation of your configuration options. This helped me in step 5 below.

4. When you attempt to install LibXML2, you may run into some problems. The directions at pointbeing tell you to add flags for the path to the zlib and libiconv you installed in previous steps. *I could not get these flags to work.* Ultimately, I was only able to successfully install Libxml after leaving those flags off of the configure command. It took me a couple of hours to figure out what the problem was and that this was what was interfering with the rest of my installation. In the end, libiconv and zlib were installed on my server, and are available to PHP -- but apparently they are not properly integrated with Libxml. Since I don't plan on directly relying on either of them, I'm not really concerned about this. If someone can explain how to get libxml to work with these two libraries, and if it's even necessary, that would be great.

During the "make" process of Libxml, which takes quite a while, you will probably see hundreds of "warning" message related to a "visibility attribute directive". These can be ignored, apparently. It seems they relate to an older version of gcc, the compiler that is installed on DH's servers. It should not affect the overall success of the installation. If on the other hand Make reports "Error 1" or "Error 2" at the end of its process, your installation was not successful: LibXML was not installed, which means that LibXSLT will not be able to install either. (That was my experience, anyway.)

If you really botch things up, you can do "rm -r libxml2-2.6.16" to remove the directory you created when you uncompressed the file you downloaded. Then just uncompress the tar.gz file again and start over. This applies to all the libraries you download.

Once you successfully run "make" on LibXML, you can run the command "make tests," which will run a long (~15 minute) series of tests on the installation. It is normal to see 6 errors during this process. When it's all over, hopefully you won't get any fatal error messages, and you can be happy that you got a good installation of libxml and can proceed.

Note that as of 12/20/04, pointbeing.net's instructions omit the final command "make install." This is an error. You should run "make install" after a successful "make" or "make tests".

5. If you successfully installed libxml, libxslt should go smoothly. You may want to read the "Install" text file first to make sure you send it the right flag so it can properly find the LibXML you just installed. If you don't add the proper flag, I think it will attempt to use Dreamhost's default installation of libxml, which is too old for this version of libxslt, apparently. I set the flag for "xmllib source" or whatever it is and pointed it to /home/yourusername/php and it worked fine. This is one of those things that took me forever to figure out, but wouldn't have been a problem at all if I had just RTFM to begin with.

6. I believe you can skip the installation of libjpeg and libpng. DH already has these installed in the /usr directory on their servers, so you can just tell PHP to just look for them there, along with a bunch of other stuff. If you choose to install the jpeg library in your own directory, you will get an error because it tries to install a file in /php/libjeg-nnn/man/man1. The solution is to manually create the man and man1 directories before running the make. Read the INSTALL file and set prefixes with "configure" as necessary.

7. **Other Extensions/Libraries* For my installation to be as complete as I wanted, I needed some files that were not provided by DH, or at least not provided in a recent enough version. For instance, the curl libraries. DH has both of these installed, but I couldn't get them working for some reason, so I downloaded and compiled them myself, following the basic steps outlined for each of the other extensions, and (eventually) reading the INSTALL and README files for each.

PHP.net has an extremely useful page that lists and describes every standard extension available to you, and how to install it. It tells you whether they are included in the default download of PHP, and whether they are automatically installed. See the navbar on the left side of the page here: http://www.php.net/manual/en/ref.domxml.php . If you read it carefully, this will save you a lot of trouble. It tells you exactly how to reference the files in your PHP configuration command later on. It's probably a good idea to look at the list of available extensions and say, "I want that...I want that." and then read up on each one, so you don't separately download and compile them unnecessarily (like I did).

8. *Configuring PHP.* Once you have all your libraries installed, download PHP and uncompress it.

You configure PHP to prepare it to be compiled. You should run "./configure --help" first so you get an idea of what all your options are. You can also read about them here: http://www.php.net/manual/en/configure.php

Now, when you configure PHP, you could/should borrow the configuration options from me (see end of this post), or Pikkle, or pointbeing, or someone else, and then add or subtract as necessary. It's a good idea to look at the config options on a standard default installation of PHP *4* on Dreamhost, so you don't miss anything you might want. (Do this by putting "phpinfo()" on a page in your existing PHP4-powered site.) Don't forget that you can break your configuration commands across several lines, so you don't have to type everything in one long uninterrupted stream. To do this, just type a backslash at the end of the line, and hit Enter. Omit the backlash to execute the batch of commands you've entered.

So:

[machine]$: ./configure --with-pear \
> --enable-sockets \
> --enable-ftp \
> --prefix=/home/yourusername/php

When doing the configure, you must tell the installer where to find the various files you installed earlier. You must also tell it to use the default DH files where appropriate. So:

> --with-zlib-dir=/adm/usr/bin \
> --with-freetype=/usr \

I am not certain, but apparently you do not need "--with-apxs=/dh/apache/template/bin/apxs" . This tells PHP to create PHP as an Apache module, but since you will eventually be running PHP as a CGI binary, I think you should omit this. Again, I am not sure, but I skipped it. For any libraries/extensions that are not included with the default installation and for which you want to rely on the default DH files, you must tell PHP to find them. In most cases, they will be in /usr

You should (must?) also create a php.ini file that contains all the PHP preferences. It seems to me this is one of the primary reasons for compiling your own php, so it's probably a good idea to use it. Add a flag like this to your compilation script to tell PHP where to find the file once you finish the installation:

--with-config-file-path=/home/yourusername/php/php.ini

(The file does not have to exist there already! You move it there later. [see below])

If you are lucky, configure will run and everything will be fine. The errors that configure generates are often specific enough to figure out what the underlying problem is: a software version is too old, or you typed in the wrong path, or one library requires another one that you didn't include, or whatever.

Once configure is done (it takes a minute or two, depending on how many options you have), you are ready to compile PHP with the Make command.

Make takes quite a while -- about 5 minutes, I think, depending -- during which time all kinds of stuff will scroll by on your screen. If you see something that says "Error," you are probably not going to have a successful compilation.

However, Make can also finish and produce **no errors** but you can still have a failed compilation! This sucks. The way to see if your installation work is to go to the directory /home/yourusername/php/sapi/cgi . If there is a file in there called "php", then it was successful. If not, it wasn't. In other words, the whole point of the Make is to produce the binary file called "php". If it doesn't get produced, you have to do the configure and make again, which takes a frustratingly long time.

As Pikkle points out, the way to clean the installation you just messed up is to run "make distclean" from the same directory you ran make in. This will delete all the unused, malformed files you just created. I am not sure whether it is necessary to do this after each botched compile, but I did.

If your make was unsuccessful, the problem can probably be indentified by carefully going through your configuration command and trying to figure out what's missing or what's wrong.

[Remember that you can press the up arrow on your keyboard to flip through your most recent commands. This is very useful at this stage. Also, when you run make, even if it is not successful, it stores your configuration command in a file called "config.nice". I found it useful to save my original version of config.nice as "config.bak" so I could read it and make sure I didn't forget any options as I was troubleshooting later on.]

If you run make a few times and are getting nowhere, then start with the most basic configuration command possible, which Pikkle discovered is apparently:

./configure --with-libxml-dir=/home/yourusername/php

This should produce the PHP binary in sapi/cgi/ . If not, you've got worse problems than I did, and I can't really help.

It's a good feeling to see the php binary once you run the above command, because you know you are getting close.

Here's what I did from there:

a. Starting with the minimum configure command above, I ran "make" and made sure it generated the PHP binary.
b. if successful, i saved the config.nice as "config.works"
c. did "make distclean"
d. re-ran configure, adding a few likely-to-succeed options from my original "config.bak"
e. ran "make", made sure the binary was produced, and repeated the steps A-D until i got all my options working.

This took a very long time, but it was ultimately a successful method.

DO NOT run "make install" after make. It is not necessary and will cause an error, because it will try to install PHP to DH's Apache directory, which obviously you do not have permissions for.

9. *Installing the PHP binary.* The rest is easy, and is outlined at the root of this thread pretty clearly. Create ("mkdir") a web-accessible directory called cgi-bin within your website (e.g., /home/yourusername/yourwebsite.com/cgi-bin/)

Copy your PHP binary to that new directory using "cp /home/yourusername/php/sapi/cgi/php /home/username/yourwebsite.com/cgi-bin". cd to that web directory. Rename your PHP binary to php.cgi using "mv php php.cgi".

Important: Set the permissions on the cgi-bin directory using "chmod -R 755 cgi-bin" This allows the PHP binary to execute.

Create an .htaccess file in your main web directory (or one level up, maybe) as described in the original post in this thread.

10. php.ini configuration file. When you finish your installation, you will have a file in the /home/yourusername/php directory called php.ini-recommended and php.ini-distro or something like that. I copied the php.ini-distro to the ini path mentioned in the configuration script above, and renamed it to php.ini. I imagine this is what you are supposed to do, but I have not tested it by changing values and seeing if those values work, etc. Maybe you should use the "recommended" ini file instead. I'm sure it's documented somewhere.

11. *Test your installation*. You should already know how to do this if you just went through the trouble of creating your own PHP installation, but just create a php file with "phpinfo()" in it. Upload or save the file to a web-accessible directory, and access it with your browser. If it shows you your PHP configuration information, you have a successful installation! If it says something about authorization, make sure you've set the permissions to 755 on the cgi-bin directory and the php binary inside it.

RESOURCES
My PHP configuration options:

To use in your configuration routine, omit the quotes, and enter each one as a configure option:

'./configure' '--prefix=/home/adm/bin' '--with-libxml-dir=/home/adm/bin' '--with-pear' '--with-gd' '--enable-ftp' '--enable-shared=yes' '--enable-static=yes' '--enable-track-vars' '--enable-sockets' '--enable-calendar' '--with-zlib-dir=/adm/usr/bin' '--with-jpeg-dir=/home/adm/bin' '--enable-wddx' '--enable-discard-path' '--enable-exif' '--enable-soap' '--with-curl=/home/adm/bin' '--with-curlwrappers' '--with-config-file-path=/home/adm/php/php.ini' '--with-xsl=/home/adm/bin' '--with-xmlrpc=/home/adm/bin' '--with-mysql=/usr' '--with-freetype=/usr' '--with-ttf=/usr' '--with-png-dir=/usr'

phpinfo() for my installation:
http://thousandrobots.com/dev/phpinfo.php

demo of XSL library working:
http://thousandrobots.com/dev/xsl/
(uses, verbatim, the example at http://www.php.net/manual/en/ref.xsl.php )
User Post (2004-10-24 20:46:20 by tobe2199)
***************************

You MUST chmod 755 the cgi-bin directory your php interpreter goes in..

***************************

took me 2 hours to figure out why I was getting Internal Server Error.. missed the post further down so I'm making a more obvious one...

Configure options I used are in the top box in this page:
--
User Post (2004-10-19 10:22:08 by pikkle)
Is anyone using pre-compiled PHP modules?

As far as I can see there is no way to load php modules - the php.ini is not processed unless the webserver is restarted. And running php as a CGI doesn't mean it is part of the apache process, so no extensions can be added unless they are:
- compiled into the CGI php engine
- dynamically loaded using dl() everytime the page is hit... heavy load.

hmm.
User Post (2004-10-14 10:53:54 by pikkle)
has anyone had luck working with ming 0.3 within PHP?
I am not sure how to add extras to PHP. I cant get it to compile within PHP using the
./configure --with-ming=/home/pikkle/php

but just get the default ming (0.2) which is part of PHP5.

Is there a way to install the built binaries after the compile? eg

modifing a 'php.ini' file somewhere to add:
extension=php_ming.so

since any "install" command wont work since I am not root...

awkward schtuff.
User Post (2004-10-13 22:21:49 by oafyc)
So, do we need to do anything with php.ini? I originally copied it to a folder and had --with-config-file-path=/home/oafyc/php in my config. I had some errors that way. It seemed to work but I got random errors like

Fatal error: main() [function.require]: Failed opening required 'components/com_config/admin.config.html.php' (include_path='/home/oafyc/usr/local/lib/php') in /home/.ego/oafyc/oafyc.com/administrator/components/com_config/admin.config.php on line 218
User Post (2004-10-09 02:16:35 by pikkle)
OK I finally got php5 working. I put a binary with a different suffix than .cgi in this directory. I am not sure if other people can just copy this and use it?

http://pikkle.com/pub/php5/

also documented the issues i had in a text file in that dir... good luck! mail me at dc3@pikkle.com if you think i could help. took me a couple evenings messing around to get this to work, not being a unix guy. Now I have to do the same on windows for my home/dev environment....

User Post (2004-10-07 12:55:49 by fuzzymonk)
I am having the same problem as pikkle, and iconv is the reason I wanted the custom install of php in the first place.
User Post (2004-08-03 12:38:54 by 12to12studios)
Wow after much hard work and research I finally got PHP to work. I documented my findings and frustrations and will post them for others soon... good luck all. It wasn't easy for someone such as I who is new to this kind of development: http://www.socialbanter.com/info.php
User Post (2004-07-23 13:23:26 by jonathanbell)
I got 5 final installed. http://dev.stonewallcs.com/info.php

I followd slimc's link, and tweaked the configure line to get it to work nicely
User Post (2004-05-08 11:38:26 by slimc9999)
YEah, it's pretty easy: <a href="http://slimc.com/phpinfo.php" target="_blank">http://slimc.com/phpinfo.php</a>

Go here: http://www.pointbeing.net/howto/index.php/installphp5/
and just follow the instructions -- minus the Apache part
User Post (2004-05-05 11:39:20 by dphiffer)
pikkle: I have PHP 5 RC2 up and running: http://phiffer.org/info.php
User Post (2004-04-17 06:35:34 by hunsvotti)
Also make sure your /cgi-bin directory and /cgi-bin/php.cgi executable is chmod 755'd. Failure to do so will give you an internal server error.
User Post (2004-04-05 18:54:53 by pikkle)
has anyone tried running PHP5 this way yet?
User Post (2004-03-25 22:46:14 by th3p03t)
Thanks to hunsvotti for the excellent instructions, especially for xslt support, etc enabled. Additionally, I ran into an error where the compiled php binary seemed to be executing itself (that's the best way to describe the parse errors and warnings that it was giving for itself). It's a weird error, but after some digging I found the fix at http://www.zend.com/lists/php-dev/200201/msg00979.html - just remove --enable-discard-path, start from scratch and viola! I'm guessing this is specific to the 4.3.x branch. I ran into this error compiling 4.3.4.
User Post (2004-03-23 08:35:46 by hunsvotti)
Building PHP with full GD, XML, XSLT, XML-RPC, etc. support:

<br>
I put the following lines into my ~/.bash_profile (this may or may not have been necessary, but I did it to be safe):<br>
export LD_LIBRARY_PATH=$HOME/usr/lib:$HOME/usr<br>
export LD_RUN_PATH=$HOME/usr/lib:$HOME/usr<br>
export INCLUDE_DIRECTORY=$HOME/usr/include<br>
<br>
After that you have to either relogin or type 'source ~/.bash_profile' so that bash recognizes the changes.<br>
<br>
I had to download and compile Sablot-1.0.1, libxml2-2.6.7, and libxslt-1.1.4. This was exceedingly easy, for each I just did "./configure --prefix=$HOME/usr" (I had already made a ~/usr directory) followed by "make; make install". Then I configured PHP 4.3.4 like this:<br>
<br>
./configure \<br>
--prefix=$HOME/php4 \<br>
--enable-force-cgi-redirect \<br>
--with-config-file-path=$HOME/php4/etc/php.ini \<br>
--enable-discard-path \<br>
--enable-sysvmsg \<br>
--enable-sysvsem \<br>
--enable-sysvshm \<br>
--exec-prefix=$HOME/php4 \<br>
--with-mysql \<br>
--enable-bcmath \<br>
--enable-calendar \<br>
--with-jpeg-dir=/usr/lib \<br>
--with-zlib-dir=/usr/lib \<br>
--with-xslt-sablot=$HOME/usr \<br>
--with-expat \<br>
--with-dom \<br>
--with-dom-xslt=$HOME/usr \<br>
--with-dom-exslt=$HOME/usr \<br>
--enable-exif \<br>
--with-gd \<br>
--with-png-dir=/usr/lib \<br>
--with-ttf \<br>
--with-freetype \<br>
--enable-gd-native-ttf \<br>
--enable-sockets \<br>
-enable-wddx \<br>
--with-xmlrpc \<br>
--enable-xslt \<br>
--with-pear<br>
<br>
This all ran great, but then when I ran make it got an error because it couldn't find one of the header files for libxml2. I opened Makefile and found the "INCLUDES = blah blah" line and put the proper paths in the beginning.
If something similar happens to you, just do this:<br>
cd ~<br>
find -name (whatever it couldn't find, usually "something.h")<br>
<br>
In my case I had to put these at the beginning of the INCLUDES = line: -I/home/myusername/usr/include -I/home/myusername/usr/include/libxml2 -I/home/myusername/usr/include/libxml2/libxml/<br>
<br>
Good luck,<br>
Huns.<br>
User Post (2003-08-29 08:45:47 by vavish)
Finally it worked... but what a pain in the ass...

To the others that has to do that, follow EXACTLY what's mentionned in www.kellybreed.com/phpinstall.txt, text file provided by 2zcompany
You have to have the exact version of PHP because I tried 4.3.3 and it didn't work. I tried the 4.3.0 specified in his text file and it worked great so I touch some wood :o)

Thanx 2zcompany for your text file, that's why compiling php here isn't a pain anymore :o)
User Post (2003-06-11 21:27:35 by monomute)
I did the AddType trick and it seemed to improve my PHP but it looks like even though GD 2.0 is present on Dreamhost I still get errors like this:

Warning: imagecreatetruecolor(): requires GD 2.0 or later

Do I need to compile my own PHP to resolve this?
User Post (2003-05-22 11:01:25 by warren)
I'm having trouble defining the base path for a PHP realestate application I've set up in a folder for clients to see
The site in question is www.warrenzanes.com/realestate

the "ReadMe" files state that I need to change the base path (in config.php) to the The actual location of openlistings on the machine

currently I've set it to
$config[basepath] = "/www/users/warren/realestate";

but I keep geting errors such as
Warning: open_basedir restriction in effect. File is in wrong directory in /home/.penguinoven/warren/warrenzanes.com/realestate/include/common.php on line 42

Warning: Failed opening '/www/users/warren/realestate/template/generic/style.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/.penguinoven/warren/warrenzanes.com/realestate/include/common.php on line 42

I've tried changing the base path to just about everything but I have the feelng that the folder in question (include) needs to be moved

Can anyone help or point me in the right direction to solve this?
Tech Support has not helped at all

thanx
cobyco

User Post (2003-02-22 22:31:53 by physco_acj)
Quite Simply... THANK YOU 2zcompany your document made the install smooth and painless. dreamhost and its users rock....
User Post (2003-02-11 14:44:02 by mstyne)
Even with the .pcgi solution, it seems like some functions like imagefttext and imagettftext are disabled. Why? I have no idea. Fortunately, those are the only ones I've run into so far.
User Post (2003-01-23 12:16:41 by 2zcompany)
Yes, thank you fivetide. Tech support helped me with my boneheadedness. If anyone else needs more explicit instructions you can take a look here www.kellybreed.com/phpinstall.txt for the steps that I went through to install php 4.3.0 here on Dreamhost. By the way, Dreamhost support rocks.
User Post (2003-01-19 13:11:05 by fivetide)
To 2zcompany: I had the same problem. It was because my cgi-bin folder had its permissions set as 775. I changed the permissions (chmod 755 cgi-bin) and it worked fine.
User Post (2003-01-14 12:30:31 by 2zcompany)
I managed to get PHP compiled and copied to my cgi-bin. I even got it to run from the command line while in cgi-bin, but for the life of me I cannot get the .htaccess file set up to make it use my copy of PHP. I get Internal Server Error every time. I'm using these lines in the .htaccess, which is in the same directory (my www dir) as the scripts I'm trying to run:
AddHandler custom-php .php .pcgi
Action custom-php /cgi-bin/php.cgi

The copy of php in the cgi-bin is name php.cgi. I know this is not a support column, bu can anyone give me a clue?

Thanks!
User Post (2003-01-10 08:21:36 by mareotis)
Thanks IAN for your post!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
It was not easy, but I finally compiled PHP with GD.

Arnauti
User Post (2003-01-02 14:07:58 by foozmeat)
I just finished compiling PHP 4.3.0. I used the following configure line. Replace username with your username.

'./configure' '--with-mysql' '--enable-force-cgi-redirect' '--with-config-file-path=/home/username/local/etc/' '--enable-trans-sid' '--enable-ftp' '--with-xml' '--with-zlib' '--prefix=/home/username/local' '--without-pear' '--with-gd' '--with-jpeg-dir=/usr/lib'
User Post (2002-12-15 06:40:51 by gwhite)
PHP, when running as a CGI instead of an Apache module now supports JPEG, PNG and WBMP. All you need to do to get PHP to run as CGI is add the following line to your .htaccess file:

AddType php-cgi .php

User Post (2002-12-12 08:41:54 by idleminds)
As of PHP 4.3.0, the GD libraries will be included in the standard PHP installation.

Release Candidate 3 was released yesterday, so the final version should be ready in a couple of weeks.
User Post (2002-10-28 21:49:46 by sawrecordings)
Ian,

what versions of GD and PHP were you trying to install?

I can't get GD to make test properly nor can i get PHP to make without erroring off.

+Brian
User Post (2002-10-20 21:11:37 by ewebs)
Coming from a non-technical aspect, I also support GD as part of the base php.

At very least, Dreamhost should hurry along with the jpg pcgi support.

Thanks for the detailed explaination guys
User Post (2002-10-09 17:28:48 by peterjtracey)
Well I asked tech support about why they don't compile GD into PHP. The answer sort of made sense though with all the hosts that offer GD by default I'm not sure how true it is.

<br>
Anyway the bottom line is contrary to what you'll find in this knowledge base, to use the GD extensions you DO NOT have to compile your own PHP. The CGI version they offer does inlude the GD extensions though for now (they say this will change in the next couple weeks) it only supports the PNG format (more on that bellow). Here's excerpt from the email I got that explains how to use GD extensions without compiling a custom PHP:
<br><br>
>>><br>
> linux. I've been trying for a while now to compile my own PHP with GD
> support, but it won't work.
<br><br>
Then complain to the PHP people that their build process sucks. Believe you me, I sympathize. I've built PHP more times that I care to remember.
<br><br>
> Or why can't you make a
> php.exe with various configurations including GD being built in
> available?
<br><br>
We do. Just rename your script to have a .pcgi instead of .php and it'll have the GD extensions. Or put a line like this:
<br><br>
AddType php-cgi .php
<br><br>
in an .htaccess file and all files in that directory and its subdirectories (recursively) will be treated as PHP-CGI.
<br><br>
Note that GD only supports PNG at this point. When we upgrade to Debian woody (in the next few weeks) it'll support more.
<<<<br>
<br><br>
That's pretty simple! If it had just been mentioned here it would have saved me a days worth of trying to compile PHP and then writing support (not to mention the three days I waited for the response to my question)
<br><br>
Now handling the PNG problem may mean you'll want to compile your own PHP, though as Stephen says there they should have support for jpeg in a couple weeks.
<br><br>
Here's a code snipet to help:
<br><br>
include 'AEBrowser.php';<br>
/*<br>
PNG Support:<br>
IE: <br>
Windows: 4.0 up<br>
Mac: 5.0 up<br>
Netscape:<br>
4.04 up<br>
AOL:<br>
Windows: 4.0 up<br>
*/<br>
<br><br>
$supportspng = ($BROWSER["isNavigator"] && $BROWSER["MajorVersion"] >= 4 && $BROWSER["MinorVersion"] >= 4) ||<br>
($BROWSER["isExplorer"] && $BROWSER["MajorVersion"] >= 4 && (!$BROWSER["isMac"])) ||<br>
($BROWSER["isExplorer"] && $BROWSER["MajorVersion"] >= 5);<br>
<br><br>
Just add that to your page and spit out a PNG with whatever modifications your making with the GD functions IF $supportspng is true. Otherwise here are your options:
<br><br>
If all you're doing is resizing the image, than for browsers that don't support PNG (only like 1% of the average vistors will be using browserss that old I think), use the build in resizing with the WIDTH and HEIGHT attributes of the IMG tag. It doesn't look as good as resizing with GD, but it should only be used for 1% of your vistitors.
<br><br>
Host the image manipulation PHP page elsewhere - the only caveat is that if you use that page in an image tag on an SSL secured server the vistor will get a warning unless the place you host it is also SSL secured. There are many cheap hosts that support GD, the one I found is glypto.com, $5/month and you *don't* have to register a domain (just enter anything when asked what domain you want) you'll get an address like 209.155.155.155/~username/ if you don't want to register a domain, which is perfectly fine for just hosting images. It includes MySQL and SSL and everything else you could want. That's what I'll probably end up doing because I have to worry about what images look like for that 1% since I'm running a lot of e-commerce sites (http://www.levelthreesolutions.com/l3shop).
<br><br>
So right now if you don't mind that 1% then just use the pcgi extension and the height and width attributes, if not you'll have to wait a couple weeks or host the php image page elsewhere, or perhaps you're good enough troubleshooting linux quirks to get PHP to compile unlike myself ;)
<br><br>
Peter Tracey<br>
Level Three Solutions<br>
http://www.levelthreesolutions.com/<br>
<br><br>
(happy dreamhost customer)<br>

User Post (2002-10-03 00:21:26 by bradc)
I really do think that we should have GD support built in. After reading thru all of this and seeing all of the scripts that are available online, it's pretty clear that GD would be of huge benefit to all of us!
User Post (2002-09-27 09:53:48 by peterjtracey)
I think we should lobby to get GD extensions as part of the base PHP support. For Christ's sake, even some free hosts I've used have support for GD. It's hands-down the most common extension needed!

<br>
For now I'll be doing my best to follow these great instructions - thanks for the post! The site I need the extensions for is supposed to go live tonight :(
<br><br>
Peter<br>
Level Three Solutions<br>
http://www.levelthreesolutions.com
User Post (2002-09-05 16:18:15 by kappa)
Wrote this up to help another dreamhost user and he suggested it might be useful for others, so here it is!
<p>
I compiled PHP so i could use GD w/jpeg functions and so i could have my own php.ini file to tweak.
<p>
Along with the kbase.newdream.net directions, check out http://www.phpbuilder.com/columns/hampton20010904.php3 for a good tutorial on how to get the libraries installed (you don't need to install webalizer, just up to GD). Just make sure that wherever it says to do "make install" you want to do "make install prefix=$HOME". You can actually install these libraries wherever you want inside of your home directory, so it's up to you if you want to set a different prefix (i.e. "make install prefix=/home/user/stuff/").
<p>
You'll need to create a few directories or the installations will bitch at you: create directories "bin", "lib", "man", and "etc" in the same directory you will set as your prefix for the installs.
<p>
It's important to have the various libraries installed before you install GD, and to have GD properly installed before you build PHP.
<p>
You will need to pay close attention to the GD "Makefile" (when installing GD) as you actually need to modify the file itself.
<p>
The ./configure string I used for PHP is:
./configure --with-mysql=/usr --enable-calendar --enable-force-cgi-redirect --with-config-file-path=/home/kappa/etc/php --enable-trans-sid --with-gd=/home/kappa --with-jpeg-dir=/home/kappa --with-png-dir=/home/kappa --with-zlib-dir=/home/kappa --enable-ftp --enable-exif
<p>
(change "/home/kappa" to your home directory)
<p>
notice the "--with-config-file-path=/home/kappa/etc/php". this means I want to use my own php.ini file located in "/home/kappa/etc/php/". Don't forget to copy the php.ini file from the dreamhost install which is, i think, in "/etc/php/cgi/" and edit it to your settings.
<p>
This should get you going :D Good luck!
-ian