Building Apache with mod_php, PHP 4.3.3 and Perl 5.8.1 on Solaris 8 Notes: http://groups.google.com/groups?q=curl+solaris+Text+relocation+remains&hl=en&lr=&ie=UTF-8&selm=Pine.GSO.4.21.0202011641300.5771-100000%40hume.nlm.nih.gov&rnum=1 Tools: gcc 2.95.3 (precompiled from Sunfreeware.com) GNU Make 3.80 GNU binutils 2.13.1 GNU Tar 1.13.19 GNU bc 1.06 (for OpenSSL make test) # mkdir /build (if not already created) Setup our environment: # LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib:/usr/lib:/usr/openwin/lib:/usr/ccs/lib:/usr/ucblib:/usr/openwin/lib/libp; export LD_LIBRARY_PATH Compile OpenSSL first. Download http://www.openssl.org/source/openssl-0.9.7c.tar.gz and save it into /build/openssl-0.9.7d.tar.gz uncompress and untar # cd /build/openssl-0.9.7d # ./config --prefix=/usr/local --openssldir=/usr/local/openssl threads shared For OpenSSL 0.9.6a and greater we need to update its Makefile to correctly create shared libraries # cp Makefile.ssl Makefile.ssl.orig # sed "s/SHLIB_TARGET=gnu-shared/SHLIB_TARGET=solaris-shared/" Makefile.ssl > Makefile.tmp # mv Makefile.tmp Makefile.ssl # make # make test # make install # openssl version OpenSSL 0.9.7d 10 Apr 2003 Now build Gnu M4 Download from ftp://ftp.gnu.org/pub/gnu/m4/m4-1.4.tar.gz # cd /build/m4-1.4 # ./configure --prefix=/usr/local # make # make install Build Bison Download http://ftp.gnu.org/gnu/bison/bison-1.875.tar.gz # cd /build/bison-1.875 # ./configure --prefix=/usr/local # make # make install Build Flex Download from ftp://ftp.cise.ufl.edu/pub/mirrors/GNU/non-gnu/flex/flex-2.5.4a.tar.gz # cd /build/flex-2.5.4 # ./configure --prefix=/usr/local # make # make test Check successful, using COMPRESSION="" # make install Build libxml: http://www.xmlsoft.org/ Download from ftp://xmlsoft.org/libxml2-2.5.10.tar.gz # cd /build/libxml2-2.5.10 # ./configure --prefix=/usr/local # make # make install Build libxslt: Download from ftp://xmlsoft.org/libxslt-1.0.32.tar.gz # cd /build/libxslt-1.0.32 # ./configure --prefix=/usr/local # make # make install Build CrackLib: Download http://www.crypticide.org/users/alecm/security/cracklib,2.7.tar.gz # cd /build # mv "cracklib,2.7" cracklib2.7 # cd /build/cracklib2.7 # CC=gcc; export CC Edit util/Makefile and replace all "cc $(CFLAGS) -o" with "gcc $(CFLAGS) -o" # make all # make install # cp /build/cracklib2.7/cracklib/libcrack.a /usr/local/lib/libcrack.a # chmod +x /usr/local/lib/libcrack.a Build Curl (needs 7.9.8 or better): Notes: http://curl.haxx.se/mail/archive-2000-05/0002.html http://groups.google.com/groups?hl=en&lr=lang_en|lang_iw|lang_es&ie=UTF-8&newwindow=1&safe=off&threadm=3C33A3E9.1D6EAD40%40sonic.net&rnum=2&prev=/groups%3Fhl%3Den%26lr%3Dlang_en%257Clang_iw%257Clang_es%26ie%3DISO-8859-1%26newwindow%3D1%26safe%3Doff%26q%3Dcurl%253A%2B(35)%2BSSL%253A%2Berror%253A140770FC%253ASSL%2Broutines%253ASSL23_GET_SERVER_HELLO%253Aunknown%2Bprotocol%26sa%3DN%26tab%3Dwg Download http://curl.haxx.se/download/curl-7.10.5.tar.gz # cd /build/curl-7.10.5 # CFLAGS='-O2 -I/build/openssl-0.9.7d/include -DEAPI'; export CFLAGS # LDFLAGS="-L/build/openssl-0.9.7d"; export LDFLAGS # SSL_BASE=/build/openssl-0.9.7d; export SSL_BASE # ./configure --prefix=/usr/local # make # make test # make install Build Berkeley DB Download http://www.sleepycat.com/update/snapshot/db-3.1.17.tar.gz into /build # cd /build/db-3.1.17/dist # export CC=gcc # ./configure --prefix=/usr/local # make # make install Test install: # db_verify -V Sleepycat Software: Berkeley DB 3.1.17: (July 31, 2000) Build libsas12 http://asg.web.cmu.edu/sasl/ ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ Downlod from ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.15.tar.gz # cd /build/cyrus-sasl-2.1.15 # export LIBS=-lcrypto # export SASL_USE_GSSAPI=NO # ./configure --prefix=/usr/local --without-krb --enable-login --disable-gssapi \ --disable-krb4 --with-saslauthd=/var/run/saslauthd # make # make install Build cyrus-imap (needs 2.0.8 or better): Download ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-imapd-2.1.13.tar.gz # cd /build/cyrus-imapd-2.1.13 # ./configure --prefix=/usr/local --with-auth=unix --without-perl # make # make install We will also need to install the UW implementation of IMAP http://www.faqchest.com/prgm/cyrus-l/cyrus-01/cyrus-0107/cyrus-010700/cyrus01070415_23371.html Download from ftp://ftp.cac.washington.edu/imap/imap.tar.Z # cd /build/imap-2002c1 # make gso # cp /build/imap-2002c1/src/c-client/rfc822.h /usr/include/rfc822.h # chmod +x /usr/include/rfc822.h Build libpng: http://sourceforge.net/projects/libpng/ Download from http://prdownloads.sourceforge.net/libpng/libpng-1.2.5.tar.gz # cd /build/libpng-1.2.5 # cp scripts/makefile.solaris Makefile # make # make test # make install Build libjpeg: Download from ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz # cd /build/jpeg-6b # ./configure --prefix=/usr/local # make # make test # make install # cp /build/jpeg-6b/libjpeg.a /usr/lib/libjpeg.a # chmod +x /usr/lib/libjpeg.a Build mcrypt, libmcrypt and libmhash: Mhash can be found at http://mhash.sourceforge.net/ or http://unc.dl.sourceforge.net/sourceforge/mhash/mhash-0.8.18.tar.gz Download from ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz Download from ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/mcrypt-2.6.4.tar.gz # cd /build/mhash-0.8.18 # ./configure --prefix=/usr/local # make install Notes: http://lists.hellug.gr/pipermail/mcrypt-dev/2003/000405.html "Replace mcrypt_symb.c in src/ with the original file from the distribution. For some reason the makefile decided to overwrite it." # cd /build/libmcrypt-2.5.7 # ./configure --prefix=/usr/local # cp lib/mcrypt_symb.c src/mcrypt_symb.c # make # make install # cd /build/mcrypt-2.6.4 # ./configure --prefix=/usr/local # make # make install Build MySql: Download from http://www.mysql.com/downloads/mysql-4.0.html ftp://mirror.mcs.anl.gov/pub/mysql/Downloads/MySQL-4.0/mysql-4.0.14.tar.gz # cd /build/mysql-4.0.14 # ./configure --prefix=/usr/local/mysql # make # make test # make install Install the MySQL grant database: Notes: http://www.mysql.com/doc/en/Post-installation.html Check /etc/passwd and if no mysql account is defined then: # groupadd mysql # useradd -d /tmp -g mysql mysql # mkdir -p /var/lib/mysql # chown mysql:mysql /var/lib/mysql # chmod 770 /var/lib/mysql Create /etc/my.cnf: Create /etc/my.cnf with the following lines: [mysqld] datadir=/var/lib/mysql socket=/tmp/mysql.sock [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid Backup your old data if you have any first! # /build/mysql-4.0.14/scripts/mysql_install_db "Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables 030911 15:14:49 /usr/local/mysql/libexec/mysqld: Shutdown Complete To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! This is done with: /usr/local/mysql/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h wstest03 password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe & You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests Please report any problems with the /usr/local/mysql/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at https://order.mysql.com" Verify the admin database was built: # ls -lR /var/lib/mysql /var/lib/mysql: total 4 drwx------ 2 root other 512 Sep 17 08:02 mysql drwx------ 2 root other 512 Sep 17 08:02 test /var/lib/mysql/mysql: total 132 -rw-rw---- 1 root other 0 Sep 17 08:02 columns_priv.MYD -rw-rw---- 1 root other 1024 Sep 17 08:02 columns_priv.MYI -rw-rw---- 1 root other 8778 Sep 17 08:02 columns_priv.frm -rw-rw---- 1 root other 306 Sep 17 08:02 db.MYD -rw-rw---- 1 root other 3072 Sep 17 08:02 db.MYI -rw-rw---- 1 root other 9088 Sep 17 08:02 db.frm -rw-rw---- 1 root other 0 Sep 17 08:02 func.MYD -rw-rw---- 1 root other 1024 Sep 17 08:02 func.MYI -rw-rw---- 1 root other 8641 Sep 17 08:02 func.frm -rw-rw---- 1 root other 0 Sep 17 08:02 host.MYD -rw-rw---- 1 root other 1024 Sep 17 08:02 host.MYI -rw-rw---- 1 root other 9064 Sep 17 08:02 host.frm -rw-rw---- 1 root other 0 Sep 17 08:02 tables_priv.MYD -rw-rw---- 1 root other 1024 Sep 17 08:02 tables_priv.MYI -rw-rw---- 1 root other 8877 Sep 17 08:02 tables_priv.frm -rw-rw---- 1 root other 168 Sep 17 08:02 user.MYD -rw-rw---- 1 root other 2048 Sep 17 08:02 user.MYI -rw-rw---- 1 root other 9806 Sep 17 08:02 user.frm /var/lib/mysql/test: total 0 Create the MySQL init script: # mkdir -p /var/run/mysqld # chown mysql:mysql /var/run/mysqld # chmod 0755 /var/run/mysqld Create the file /etc/init.d/mysqld with the following lines: #!/bin/sh # # mysqld This shell script takes care of starting and stopping # the MySQL subsystem (mysqld). # # description: MySQL database server. # processname: mysqld # config: /etc/my.cnf # pidfile: /var/run/mysqld.pid prog="MySQL" datadir="/var/lib/mysql" pidfile="/var/run/mysqld/mysqld.pid" start(){ LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib:/usr/local/mysql/lib/mysql; export LD_LIBRARY_PATH mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld touch /var/run/mysqld/mysqld.pid chown mysql:mysql /var/run/mysqld/mysqld.pid chmod 0755 /var/run/mysqld/mysqld.pid touch /var/log/mysqld.log chown mysql:mysql /var/log/mysqld.log chmod 0640 /var/log/mysqld.log touch $pidfile chown mysql:mysql $pidfile chmod 0644 $pidfile if [ ! -d $datadir/mysql ] ; then echo "Initializing MySQL database: " /usr/local/mysql/bin/mysql_install_db ret=$? chown -R mysql:mysql $datadir if [ $ret -ne 0 ] ; then return $ret fi fi chown -R mysql:mysql $datadir chmod 0755 $datadir /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf & ret=$? if [ $ret -eq 0 ]; then echo "Starting $prog: " /bin/true else echo "Starting $prog: " /bin/false fi return $ret } stop(){ /bin/kill `cat $pidfile 2> /dev/null ` > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then echo "Stopping $prog: " /bin/true else echo "Stopping $prog: " /bin/false fi [ $ret -eq 0 ] && rm -f /tmp/mysql.sock [ $ret -eq 0 ] && rm -f $pidfile return $ret } restart(){ stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status mysqld ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac exit $? # chmod +x /etc/init.d/mysqld Setup MySQL to start automatically on reboot: # ln -s /etc/init.d/mysqld /etc/rc2.d/S78mysql # ln -s /etc/init.d/mysqld /etc/rc1.d/K01mysql Now startup MySQL: # /etc/rc2.d/S78mysql start # ps -ef | grep -i sql root 9770 1 1 16:40 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mys mysql 9801 9770 7 16:40 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld Test it: # /usr/local/mysql/bin/mysql -e status -------------- /usr/local/mysql/bin/mysql Ver 12.21 Distrib 4.0.14, for sun-solaris2.8 (sparc) Connection id: 1 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Server version: 4.0.14 Protocol version: 10 Connection: Localhost via UNIX socket Client characterset: latin1 Server characterset: latin1 UNIX socket: /tmp/mysql.sock Uptime: 1 min 8 sec Threads: 1 Questions: 2 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.029 -------------- You must now add "/usr/local/mysql/bin" to your PATH and "/usr/local/mysql/lib/mysql" to your LD_LIBRARY_PATH statements (/etc/profile) Build Apache: Notes: http://www.smartframeworks.com/qt-apache-ssl.html Download from http://httpd.apache.org/download.cgi # cd /build/httpd-2.0.50 # export SSL_BASE=/usr/local/openssl # ./configure --prefix=/usr/local/httpd \ --enable-shared=ssl --enable-ssl=shared \ --with-ssl=/usr/local/openssl \ --with-openssl=/usr/local/openssl \ --enable-so \ --enable-mods-shared=all \ --enable-access=shared --enable-auth=shared --enable-auth_anon=shared \ --enable-auth_dbm=shared --enable-auth_digest=shared --enable-include=shared \ --enable-log_config=shared --enable-env=shared --enable-mime_magic=shared \ --enable-cern_meta=shared --enable-expires=shared --enable-headers=shared \ --enable-usertrack=shared --enable-unique_id=shared --enable-setenvif=shared \ --enable-mime=shared --enable-dav=shared --enable-status=shared \ --enable-autoindex=shared --enable-asis=shared --enable-info=shared \ --enable-cgi=shared --enable-dav_fs=shared --enable-vhost_alias=shared \ --enable-negotiation=shared --enable-dir=shared --enable-imap=shared \ --enable-actions=shared --enable-speling=shared --enable-userdir=shared \ --enable-alias=shared --enable-rewrite=shared --enable-proxy=shared \ --enable-proxy_ftp=shared --enable-proxy_http=shared \ --enable-proxy_connect=shared --enable-rule=SHARED_CORE \ --verbose # make # make install Finally fixup Apache: # groupadd apache # useradd -d /tmp -g apache apache # mkdir -p /var/run/httpd # chown apache:apache /var/run/httpd # chmod 0755 /var/run/httpd # mkdir -p /usr/local/httpd/conf.d # cp /usr/local/httpd/conf/httpd.conf /usr/local/httpd/conf/httpd.conf.orig Edit /usr/local/httpd/conf/httpd.conf Change the line: ServerAdmin you@your.address to ServerAdmin nicadmin@harcourt.com and the line: #ServerName new.host.name:80 to ServerName my.host.com:80 or similiar and the lines: User nobody Group #-1 to User apache Group apache Add the below lines underneat the Listen statement: # Load config files from the config directory "/usr/local/httpd/conf.d". # Include /usr/local/httpd/conf.d/*.conf Change the PidFile line to: PidFile /usr/local/httpd/logs/httpd.pid Save and exit. Try to start the server again: # /usr/local/httpd/bin/apachectl stop # /usr/local/httpd/bin/apachectl start # ps -ef | grep http nobody 17474 17470 0 19:28:28 ? 0:00 /usr/local/httpd/bin/httpd -k start root 17470 1 14 19:28:25 ? 0:03 /usr/local/httpd/bin/httpd -k start nobody 17475 17470 0 19:28:28 ? 0:00 /usr/local/httpd/bin/httpd -k start nobody 17471 17470 0 19:28:28 ? 0:00 /usr/local/httpd/bin/httpd -k start nobody 17473 17470 0 19:28:28 ? 0:00 /usr/local/httpd/bin/httpd -k start nobody 17472 17470 0 19:28:28 ? 0:00 /usr/local/httpd/bin/httpd -k start Now update the init script: # mv /etc/init.d/httpd /etc/init.d/httpd.orig_b4_httpd_upgrade_2_0_48 Create the file /etc/init.d/httpd with the following lines: #!/bin/sh # # Startup script for the Apache Web Server # # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/httpd/bin/apachectl httpd=/usr/local/httpd/bin/httpd pidfile=/usr/local/httpd/logs/httpd.pid prog=httpd RETVAL=0 # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo "Starting $prog: " $apachectl startssl RETVAL=$? return $RETVAL } stop() { echo "Stopping $prog: " /bin/pkill -U apache kill -5 `/bin/cat $pidfile` RETVAL=$? return $RETVAL } reload() { echo "Reloading $prog: " check13 || exit 1 killproc $httpd -HUP RETVAL=$? return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f $pidfile ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo "Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac Save and exit. # chmod +x /etc/init.d/httpd # ln -s /etc/init.d/httpd /etc/rc3.d/S99httpd # ln -s /etc/init.d/httpd /etc/rc1.d/K10httpd Download php from http://www.php.net/downloads.php # cd /build/php-4.3.3 # CFLAGS='-O2 -I/build/openssl-0.9.7d/include -DEAPI'; export CFLAGS # LDFLAGS="-L/build/openssl-0.9.7d"; export LDFLAGS # ./configure --prefix=/usr/local \ --with-apxs2=/usr/local/httpd/bin/apxs \ --with-config-file-path=/etc --enable-track-vars \ --without-bz2 --with-crack=/build/cracklib2.7 \ --with-curl=/build/curl-7.10.5 --with-cyrus=/build/cyrus-imapd-2.1.13 \ --without-fbsql --without-fdftk --without-fribidi --with-jpeg-dir=/build/jpeg-6b \ --with-png-dir=/build/libpng-1.2.5rc2 --without-hwapi --without-imap \ --without-informix --without-ingres --without-ircg --without-java --without-mcal \ --without-mcrypt --without-mcve --without-ming --without-mnogosearch --without-msession \ --without-ncurses --without-oracle --without-oci8 --without-ovrimos --disable-pcntl \ --without-cpdflib --without-pdflib --without-pfpro --without-pgsql --without-pspell \ --without-qtdom --without-readline --without-libedit --without-recode --without-swf \ --without-sybase --without-sybase-ct --without-xslt-sablot --without-sablot-js \ --without-expat-dir --disable-xslt --without-yaz --disable-yp --without-zip \ --with-mysql=/usr/local/mysql \ --with-xml --with-dom --with-domxml --with-zlib # make # make test # make install # cp php.ini-recommended /usr/local/etc/php.ini (this is new in PHP 4) # php -v PHP 4.3.3 (cli) (built: Aug 25 2003 13:06:54) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies Note if you have older PHP programs that are used to Ver. 3.x Global Register behavior being on you can set Global Registors for that virtual host only via the command in the Apache conf for that host: . . . php_value register_globals 1 Create php.conf Edit /usr/local/httpd/conf.d/php.conf # # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. # LoadModule php4_module modules/libphp4.so # # Add PHP file types # AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps AddType application/x-httpd-php .inc AddType application/x-httpd-php .php # # Note: This is the old Apache 1.x syntax but I am leaving in commented # out for documentation sake # # # Cause the PHP interpreter handle files with a .php extension. # # # SetOutputFilter PHP # SetInputFilter PHP # LimitRequestBody 524288 # # # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php Compiling Python: Download from http://www.python.org/download/ Note: You need to use GNU Tar 1.13 or you will see checksum errors from Solaris tar # cd /build/Python-2.3.3 # ./configure --prefix=/usr/local # make # make test # make install Test it: # python -V Python 2.3.3 Compiling Perl: Download from