January 24, 2005 (This version may be slightly out of date. For the most recent instructions, please see: http://www.moztips.com/php5_install/index.php ) Setting up PHP5 on Dreamhost Here is how you can set up PHP 5 on Dreamhost 's Debian Stable shared hosting server. Dreamhost lets you compile your own version of PHP as a CGI binary when you are logged in through SSH. This means you can use PHP 5 and MySQL 4 at a shared server price, without needing a dedicated server of your own! This whole process took about one and a half hours to complete. Syntax hightlighting by the GeSHi program # ---------------------- Setting up PHP 5 on a Dreamhost Account ----------------------- # ---------- Pre Install ------------------- # Dreamhost's site: http://www.dreamhost.com # Type of hosting: Shared hosting with SSH access, Debian Linux (Version: 'Debian Stable') # This document is based on notes found at: # https://panel.dreamhost.com/kbase/index.cgi?area=2538&keyword=compile%20php # Replace 'your_dh_username' with your Dreamhost shell username. This is the username to which your domain is mapped. # Replace 'your_dh_domain.com' with to the domain to which your username is mapped. # Before you begin # Through the Dreamhost control panel, increase the disk space quota for the user for this domain to 500 MB # Wait up to two hours for this to take effect. Then begin. # Note: the following instructions were slightly rewritten from the way I originally did it, to make them easier to follow # This could have resulted in minor syntax errors when it comes to uncompressing / untarring things. # Thus, please double check all paths before beginning # Feedback: Please send feedback to jay [at - make this a real at] moztips.com # ---------- Install -------------- # Make dir for PHP binary and PHP libraries cd /home/your_dh_username # Make dir for compiled PHP binary and compiled PHP libraries mkdir php cd php mkdir lib # Make dir for generated configure_help output and install logs cd .. mkdir configure_help mkdir install_logs # Download PHP 5 5.0.3 and PHP 5 Libraries Source Code # Orig .tgz file has been updated (Jan 24, 2004). # Strange errors after compilation should now not occur. Sorry for the original problem. wget www.moztips.com/php5_install/php5_libs_src.tgz gunzip php5_libs_src.tgz tar -xf php5_libs_src.tar # To download each library individually from the orig. mirrors, pl. visit www.moztips.com/php5_install/manual_dloads.txt # # Above step(s) create(s) a src dir here # That src dir contains two subdirs: # php-5.0.3 and php5libs # -------------- Compile all PHP 5 libraries -------------------------- cd src/php5libs # ----------------- libiconv ----------------- cd libiconv-1.9.2 ./configure --prefix=/home/your_dh_username/php/lib > /home/your_dh_username/install_logs/libiconv_configure.txt make > /home/your_dh_username/install_logs/libiconv_make.txt # After running make, I got this (safe to ignore): # libtool: install: warning: remember to run # libtool --finish /home/your_dh_username/php/lib/lib make install > /home/your_dh_username/install_logs/libiconv_make_install.txt # ----------------- zlib ----------------- cd .. cd zlib-1.2.2 ./configure --prefix=/home/your_dh_username/php/lib > /home/your_dh_username/install_logs/zlib_configure.txt make > /home/your_dh_username/install_logs/zlib_make.txt make install > /home/your_dh_username/install_logs/zlib_make_install.txt # ----------------- libxml2 ----------------- # Problems with compiling latest version of the libxml2 library on Debian Stable # Thousands of elfghack.h warnings, e.g.: # elfgcchack.h:7598: warning: `visibility' attribute directive ignored # Using slightly older version (2.6.10) cd .. cd libxml2-2.6.10 ./configure --prefix=/home/your_dh_username/php/lib > /home/your_dh_username/install_logs/libxml2_configure.txt make > /home/your_dh_username/install_logs/libxml2_make.txt # Got following warnings (safe to ignore): # catalog.c: In function `xmlCatalogGetSystem': # catalog.c:3536: warning: function returns address of local variable # catalog.c: In function `xmlCatalogGetPublic': # catalog.c:3580: warning: function returns address of local variable make install > /home/your_dh_username/install_logs/libxml2_make_install.txt # Warnings/ Errors (safe to ignore): #/usr/bin/install: cannot stat `./*.html': No such file or directory #make[3]: [install-data-local] Error 1 (ignored) #/usr/bin/install: cannot stat `./html/index.sgml': No such file or directory #make[3]: [install-data-local] Error 1 (ignored) #libtool: install: warning: relinking `libxml2mod.la' # ----------------- libxslt1 ----------------- # Need slightly older version of libxslt # for it to work with older version of libxml2 # Try libxslt-1.1.3 # gunzip libxslt-1.1.3.tar.gz ./configure --help > /home/your_dh_username/configure_help/libxslt_configure_help.txt # Note: libxslt needs to find libxml on your system # Relevant configuration options: # --with-libxml-prefix=PFX Specify location of libxml config # --with-libxml-include-prefix=PFX Specify location of libxml headers # --with-libxml-libs-prefix=PFX Specify location of libxml libs # --with-libxml-src=DIR For libxml thats not installed/compiled yet cd libxslt-1.1.3 ./configure --prefix=/home/your_dh_username/php/lib \ --with-libxml-prefix=/home/your_dh_username/php/lib \ > /home/your_dh_username/install_logs/libxslt1_configure.txt make > /home/your_dh_username/install_logs/libxslt1_make.txt # Warnings (safe to ignore): # xsltutils.c: In function `xsltDefaultSortFunction': # xsltutils.c:1074: warning: passing arg 1 of pointer to function discards qualifiers from pointer target type # xsltutils.c:1079: warning: passing arg 1 of pointer to function discards qualifiers from pointer target type # More warnings / errors in sep. text file. make install > /home/your_dh_username/install_logs/libxslt1_make_install.txt # Warnings (safe to ignore): #libtool: install: warning: relinking `libexslt.la' #/usr/bin/install: cannot stat `./html/index.sgml': No such file or directory #make[2]: [install-data-local] Error 1 (ignored) #libtool: install: warning: relinking `libxsltmod.la' # ----------------- libmcrypt ----------------- cd .. cd libmcrypt-2.5.7 ./configure --prefix=/home/your_dh_username/php/lib \ --disable-posix-threads > /home/your_dh_username/install_logs/libmcrypt_configure.txt make > /home/your_dh_username/install_logs/libmcrypt_make.txt make install > /home/your_dh_username/install_logs/libmcrypt_make_install.txt # Note the --disable-posix-threads line # that is necessary for mcrypt to work with PHP5 # ----------------- mhash ----------------- cd .. cd mhash-0.9.2 ./configure --prefix=/home/your_dh_username/php/lib > /home/your_dh_username/install_logs/mhash_configure.txt make > /home/your_dh_username/install_logs/mhash_make.txt # Lots of mhash warnings (safe to ignore, I think): # mhash.c:105: warning: initialization from incompatible pointer type make install > /home/your_dh_username/install_logs/mhash_make_install.txt # ----------------- curl ----------------- cd .. cd curl-7.12.3 ./configure --prefix=/home/your_dh_username/php/lib > /home/your_dh_username/install_logs/curl_configure.txt make > /home/your_dh_username/install_logs/curl_make.txt make install > /home/your_dh_username/install_logs/curl_make_install.txt # ----------------- MySQL 4.0 client libraries ----------------- cd .. cd mysql-4.0.23a ./configure --prefix=/home/your_dh_username/php/lib \ --without-server > /home/your_dh_username/install_logs/mysql_client_configure.txt make > /home/your_dh_username/install_logs/mysql_client_make.txt # Lots of warnings and errors scrolled by! make install > /home/your_dh_username/install_logs/mysql_client_make_install.txt # ----------------------------------- PHP 5 Compilation ------------------------------- cd ../../php-5.0.3 # PHP 5 Compilation and Installation ./configure --prefix=/home/your_dh_username/php \ --enable-force-cgi-redirect \ --with-xml \ --with-libxml-dir=/home/your_dh_username/php/lib \ --enable-soap \ --with-xsl=/home/your_dh_username/php/lib \ --with-mysql=/home/your_dh_username/php/lib \ --with-curl=/home/your_dh_username/php/lib \ --with-mhash-dir=/home/your_dh_username/php/lib \ --with-mcrypt-dir=/home/your_dh_username/php/lib \ --with-zlib-dir=/home/your_dh_username/php/lib \ --with-jpeg-dir=/usr/ \ --with-png-dir=/usr/ \ --with-gd \ --enable-gd-native-ttf \ --enable-ftp \ --enable-sockets \ --enable-wddx \ --with-iconv \ --enable-soap \ > /home/your_dh_username/install_logs/php5_configure1.txt make > /home/your_dh_username/install_logs/php5_configure1_make.txt # Warnings (safe to ignore, I think): # /home/your_dh_username/src/php-5.0.3/main/php_sprintf.c: In function `php_sprintf': # /home/your_dh_username/src/php-5.0.3/main/php_sprintf.c:40: warning: assignment makes pointer from integer without a cast make install > /home/your_dh_username/install_logs/php5_configure1_make_install.txt # ------------------------- Post Install Setup ------------------------- cd /home/your_dh_username cd www.your_dh_domain.com mkdir cgi-bin # You MUST chmod 755 the cgi-bin directory your php interpreter goes in chmod 755 cgi-bin # Copy that binary into some location accessible from your domain (cgi-bin/ is a good idea). So: cp /home/your_dh_username/php/bin/php /home/your_dh_username/www.your_dh_domain.com/cgi-bin/php #For the sake of maximum ease, rename the PHP binary to end in .cgi: mv /home/your_dh_username/www.your_dh_domain.com/cgi-bin/php /home/your_dh_username/www.your_dh_domain.com/cgi-bin/php.cgi cd /home/your_dh_username/www.your_dh_domain.com/ # Now create an .htaccess file to redirect all PHP requests to this PHP binary # instead of going through the default system PHP binary. Put this inside: cd /home/your_dh_username/www.your_dh_domain.com/ mkdir php5docs # Use pico to create the following .htaccess file in the /home/your_dh_username/www.your_dh_domain.com/php5docs/ dir # Doing this will make all files ending in .php and .pcgi in http://www.your_dh_domain.com/php5docs/ be run by PHP 5! cd php5docs pico .htaccess # Paste following contents (remove # signs before pasting!) # AddHandler custom-php .php .pcgi # Action custom-php /cgi-bin/php.cgi # Ctrl+O to write out / save file # 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! # Create phpinfo.php test file pico /home/your_dh_username/www.your_dh_domain.com/php5docs/phpinfo.php # Enter the following contents: # Save the file using Ctrl + 0 # Go to # http://www.your_dh_domain.com/php5docs/phpinfo.php # You should see something like the following page: # http://www.moztips.com/php5_install/phpinfo_sample.html # If the a page like that appears, that's it! Congratulations! # ------- END------