I have long been frustrated by the fact that the midgard makefiles 
assume they can rein over the box. As a discipline, I like to have my 
software nicely installed under /home/martin while I test and develop.

I will only set up system-wide software once (a) I am very confortable 
with it and (b) I know I'm not going to need more than one version in 
the system and (c) I am unlikely to be forced to upgrade it.

But then, I am a control freak.

Midgard has been a bit of a problem to develop with in -- because I 
could not provide midgard in each programmer's home directory and with 
an easy 10 minute install procedure.

Now, and after 2 1/2 days of hair pulling, I've just put together a 
makefile that

- gets php, apache, midgard-*
- custom-compiles everything -- inside a directory --

Can be run as root (as usual) or as a regular user, in your home 
directory, to have a full developer sandbox without whacking the system.

Indeed, I've got my development server running with 4 programmers each 
in his/her own sandbox, plus 3 sandboxes where I am about to test 
midgard versions against php versions.

I've successfully run it on a "clean" potato system -- there some system 
dependancies you have to cover.

Right now, it is very project-specific, but I will go over the process 
of generalizing it -- when the project's done.

Do you people find it useful?

What I'd like to do would be to clean up the install procedure to ensure 
all the pacages know how to behave when installed as a non-root user. I 
am doing some ugly patching in that Makefile.


cheers,








m







## ==================================================================
##  
## SSC Makefile
## 
##  $Header: /var/cvs/ssc_core/Makefile.dist,v 1.7 2002/04/11 01:21:27 martin Exp $
## ==================================================================



## ==================================================================
##             Options
## ==================================================================

# indicate where include/mysql will be found
MYSQL           = /usr/local/mysql
# where is the mysql client?
MYSQL_CLIENT            = /usr/bin/mysql

# where is xml-lib (it requires 2.2.12)
#  ftp://planetmirror.com/pub/gnome/stable/sources/libxml/libxml2-2.2.12.tar.gz
# this directory must contain libxml.so
DOM             = /usr/local/lib

# where will apache sit?
APACHE_VHOST    = bluefox.internal.cwa.co.nz
APACHE_PORT     = 8080

MIDGARD_VHOST   = bluefox.internal.cwa.co.nz
MIDGARD_PORT    = 8080

# careful! The database will be created!
MIDGARD_MYSQL_ROOT_USER = root
MIDGARD_MYSQL_ROOT_PW   = XXXXXXX 
MIDGARD_MYSQL_HOST      = localhost
MIDGARD_MYSQL_USER      = ssc_test_user
MIDGARD_MYSQL_PW        = ssc_test_pw
MIDGARD_MYSQL_DB        = ssc_test_db

DIST_DIR        = /home/martin/cvs_cookie/ssc_core

# mysql settings
MYSQL_ROOT_USER=root
MYSQL_ROOT_PW  =XXXXXXXX
MYSQL_HOST     =localhost
MYSQL_USER     = ssc_test_user
MYSQL_PW       = ssc_test_pw
MYSQL_DB       = ssc_sysdoc_test_db

# Apache -- 
APACHE_USER             = YOU    
APACHE_GROUP            = YOU

## ==================================================================
##             Options (Software)
## ==================================================================

PHP                     = php-4.0.6
APACHE                  = apache_1.3.24

## This is Midgard-1.4.2-1
MIDGARD_VERSION         = 1.4.2-1
MOD_MIDGARD             = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/00c0c18ddfba685684143324dccf5584/mod_midgard-1.4.2-1.tar.bz2
MOD_MIDGARD-PREPARSE    = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/d21041f0a0819193689164d5099616d1/mod_midgard-preparse-1.4.2-1.tar.bz2
MIDGARD-LIB             = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/a042a029b169cfed95abda4dc96f703c/midgard-lib-1.4.2-1.tar.bz2
MIDGARD-DATA            = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/caa01c511688178f84c4aa14315952de/midgard-data-1.4.2-1.tar.bz2
MIDGARD-FILETEMPLATES   = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/15d74a34576bef631723b773b7338b0f/midgard-filetemplates-1.4.2-1.tar.bz2
MIDGARD-PHP4            = 
http://www.midgard-project.org/attachment/434f392e6f87e1e76202f00695dd251f/1da23348ef2a258418e1651d504256bd/midgard-php4-1.4.2-1.tar.bz2



## ==================================================================
##             Internal Variables
## ==================================================================
 
LOCAL_DIR       = $(DIST_DIR)/local
SRC_DIR         = $(LOCAL_DIR)/src

MIDGARD_BLOB_DIR        = $(DIST_DIR)/var/blobs
MIDGARD_CACHE_DIR       = $(DIST_DIR)/var/cache


## ==================================================================
##             Targets
## ==================================================================

#   default target
all: build

## ------------------------------------------------------------------
##             Build Target
## ------------------------------------------------------------------
build:
        make download
        make untar-src
        make php-cli
        make apache-php
                

## ------------------------------------------------------------------
##             Download
## ------------------------------------------------------------------

download:

        @echo "DOWNLOADING" 
        cd $(SRC_DIR) && \
        wget -nd --mirror 
http://www.php.net/do_download.php?download_file=$(PHP).tar.gz &&\
        wget -nd --mirror http://www.apache.org/dist/httpd/apache_1.3.24.tar.gz        
  

        cd $(SRC_DIR) && \
        wget -nd --mirror $(MOD_MIDGARD)                                               
      &&\
        wget -nd --mirror $(MOD_MIDGARD-PREPARSE)                                      
      &&\
        wget -nd --mirror $(MIDGARD-LIB)                                               
      &&\
        wget -nd --mirror $(MIDGARD-DATA)                                              
      &&\
        wget -nd --mirror $(MIDGARD-FILETEMPLATES)                                     
      &&\
        wget -nd --mirror $(MIDGARD-PHP4)               

## ------------------------------------------------------------------
##             Untar sources
## ------------------------------------------------------------------
untar-src:

        make rm-src

        @echo "UNTARRING tar.gz"
        @cd $(SRC_DIR) && ls *.tar.gz | xargs -l --verbose tar -xzf 
        @cd $(SRC_DIR) && ls *.tar.bz2 | xargs -l1 --verbose tar --bzip -xf

## ------------------------------------------------------------------
##             Remove Sources
## ------------------------------------------------------------------
rm-src:

        @echo "REMOVING OLD SOURCES"
        @find  $(SRC_DIR)/* -maxdepth 0 -type d | grep -v CVS | xargs -l --verbose rm 
-fr


## ------------------------------------------------------------------
##             PHP Command Line
## ------------------------------------------------------------------
php-cli:
        cd $(SRC_DIR)/$(PHP) && \
        ./configure \
                --prefix=$(LOCAL_DIR)/$(PHP) \
                --with-dom=$(DOM) \
                --with-mysql=$(MYSQL) \
                --enable-track-vars \
                --enable-ftp \
                --enable-sysvshm \
                --enable-sysvsem \
                --with-zlib-dir=/usr/lib && \
        make && make install


## ------------------------------------------------------------------
##             Apache-PHP
## ------------------------------------------------------------------
apache-php:

        cd $(SRC_DIR)/$(APACHE) && \
        ./configure 
        
        cd $(SRC_DIR)/$(PHP) && \
        ./configure \
                --prefix=$(LOCAL_DIR)/$(PHP) \
                --with-apache=../$(APACHE) \
                --with-dom \
                --with-mysql=$(MYSQL) \
                --enable-track-vars \
                --with-dom=/usr/local/lib \
                --enable-ftp \
                --enable-sysvshm \
                --enable-sysvsem \
                --with-zlib-dir=/usr/lib && \
        make && make install

        cd $(SRC_DIR)/$(APACHE) && \
        ./configure --prefix=$(LOCAL_DIR)/$(APACHE) \
                --activate-module=src/modules/php4/libphp4.a \
                --enable-module=all \
                --enable-shared=max && \
        make && make install
        
        cp $(SRC_DIR)/$(PHP)/php.ini-dist $(LOCAL_DIR)/$(PHP)/lib/php.ini
        ln --force -s $(LOCAL_DIR)/$(PHP)/lib/php.ini $(DIST_DIR)/etc/php.ini
 
        @echo "Please add a line to your httpd.conf file to include"
        @echo "etc/ssc_vhost.conf" 



## ------------------------------------------------------------------
##             Sysdoc Data  
## ------------------------------------------------------------------
sysdoc-data:

        @echo "prepping mysql"
        echo "GRANT ALL ON $(MYSQL_DB).* TO '$(MYSQL_USER)' \
                                                 IDENTIFIED BY '$(MYSQL_PW)'; \
               FLUSH PRIVILEGES;"\
              | $(MYSQL_CLIENT) -uroot -p$(MYSQL_ROOT_PW)

        -echo "create database $(MYSQL_DB)" \
             | $(MYSQL_CLIENT) -uroot -p$(MYSQL_ROOT_PW)

        @echo putting db in!
        zcat util/build/ssc_sysdoc_dump.sql.gz | $(MYSQL_CLIENT) -uroot 
-p$(MYSQL_ROOT_PW) $(MYSQL_DB)



                
## ------------------------------------------------------------------
##             Apache Config
## ------------------------------------------------------------------

apache-conf:
        #perl -pi -e 's#Port \d+#Port $(APACHE_PORT)#i' 
$(LOCAL_DIR)/$(APACHE)/conf/httpd.conf
        #perl -pi -e 's#local/apache_1.3.24/htdocs#htdocs#i' 
$(LOCAL_DIR)/$(APACHE)/conf/httpd.conf
        

## ------------------------------------------------------------------
##             Midgard
## ------------------------------------------------------------------
midgard:
        make midgard-lib
        make midgard-data
        make mod-midgard
        make midgard-php4
        @echo "Please remember to include"
        @echo "local/src/midgard-data-1.4.2-1/midgard-data.conf"
        @echo "in httpd.conf"

## ------------------------------------------------------------------
##             Midgard-Lib 
## ------------------------------------------------------------------
midgard-lib:

        cd $(SRC_DIR)/midgard-lib* && \
        ./configure \
                --prefix=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION) \
                --with-mysql=$(MYSQL)
                
        cd $(SRC_DIR)/midgard-lib* && \
        make
        
        cd $(SRC_DIR)/midgard-lib* && \
        make install    


## ------------------------------------------------------------------
##             Midgard-Data 
## ------------------------------------------------------------------
midgard-data: 

        @echo "Midgard-Data"
        # prep mysql
        @echo "Setting up a new user in the db."
        
        echo "GRANT ALL ON $(MIDGARD_MYSQL_DB).* TO '$(MIDGARD_MYSQL_USER)' \
                                                 IDENTIFIED BY '$(MIDGARD_MYSQL_PW)'; \
               FLUSH PRIVILEGES;"\
              | $(MYSQL_CLIENT) -uroot -p$(MIDGARD_MYSQL_ROOT_PW)
              
        mkdir -p $(MIDGARD_BLOB_DIR)
        mkdir -p $(MIDGARD_CACHE_DIR)
        
        @echo "Patching dbinstall.in"
        cd $(SRC_DIR)/midgard-data* && \
        patch dbinstall.in $(DIST_DIR)/util/build/dbinstall.in.patch    
        
        cd $(SRC_DIR)/midgard-data* && \
        ./configure \
                --with-db-host=$(MIDGARD_MYSQL_HOST) \
                --with-db-admin-user=$(MIDGARD_MYSQL_ROOT_USER) \
                --with-db-admin-password=$(MIDGARD_MYSQL_ROOT_PW) \
                --with-db-user=$(MIDGARD_MYSQL_USER) \
                --with-db-user-password=$(MIDGARD_MYSQL_PW)  \
                --with-db=$(MIDGARD_MYSQL_DB) \
                --with-host=$(MIDGARD_VHOST) \
                --with-port=$(MIDGARD_PORT) \
                --with-blobdir=$(MIDGARD_BLOB_DIR) \
                --with-pagecache=$(MIDGARD_CACHE_DIR) \
                --with-midgard=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION) \
                --with-apxs=$(LOCAL_DIR)/$(APACHE)/bin/apxs \
                --with-apache-user=$(APACHE_USER) \
                --with-apache-group=$(APACHE_USER) \
                --with-adminsite \
                --with-lang=en \
                --with-asgard  \
                --with-php=4 \
                --with-install=new
        
        cd $(SRC_DIR)/midgard-data* && \
        ./dbinstall \
        
        @echo "copying images into place"       
        cd $(SRC_DIR)/midgard-data* && \
        cp -pr images/* $(DIST_DIR)/htdocs/             

## ------------------------------------------------------------------
##             Mod_Midgard
## ------------------------------------------------------------------
mod-midgard:
        @echo "Mod_Midgard"
        cd $(SRC_DIR)/mod_midgard-$(MIDGARD_VERSION) && \
        ./configure \
                --prefix=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION) \
                --with-apxs=$(LOCAL_DIR)/$(APACHE)/bin/apxs \
                --with-midgard=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION)  \
                
--with-midgard-config=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION)/bin/midgard-config  \
                --with-mysql=$(MYSQL_CLIENT)

                
        cd $(SRC_DIR)/mod_midgard-$(MIDGARD_VERSION) && \
        make 

        cd $(SRC_DIR)/mod_midgard-$(MIDGARD_VERSION) && \
        make install 

        # make conf is deprecated

## ------------------------------------------------------------------
##             Midgard-Php4 
## ------------------------------------------------------------------
midgard-php4:           
  
        @echo "Patching mkall"
        cd $(SRC_DIR)/midgard-php4-$(MIDGARD_VERSION) && \
        patch mkall $(DIST_DIR)/util/build/mkall.patch  

        @echo "Running mkall"
        cd $(SRC_DIR)/midgard-php4-$(MIDGARD_VERSION) && \
        sh mkall && echo "done!"
        
        @echo "Running phpize"
        cd $(SRC_DIR)/midgard-php4-$(MIDGARD_VERSION) && \
        $(LOCAL_DIR)/$(PHP)/bin/phpize

        #
        # IDIOTIC configure script will only see binaries in the path
        #
        
PATH=$(LOCAL_DIR)/$(PHP)/bin:$(LOCAL_DIR)/$(APACHE)/bin:$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION)/bin:$(PATH)
 && \
        cd $(SRC_DIR)/midgard-php4-$(MIDGARD_VERSION) && \
        ./configure  \
                --prefix=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION)  \
                --with-midgard=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION) \
                --with-apxs=$(LOCAL_DIR)/$(APACHE)/bin/apxs  \
                --with-php=$(LOCAL_DIR)/$(PHP) \
                --with-php-config=$(LOCAL_DIR)/$(PHP)/bin/php-config

        cd $(SRC_DIR)/midgard-php4-$(MIDGARD_VERSION) && \
        make && make install
        
        echo ""
        echo "; Midgard Module" >> $(LOCAL_DIR)/$(PHP)/lib/php.ini
        echo "module=midgard.so" >> $(LOCAL_DIR)/$(PHP)/lib/php.ini 
        echo ""


        @echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
        @echo ""
        @echo " PLEASE edit your apachectl script to ensure     "
        @echo " the env variable LD_LIBRARY_PATH is configured  "
        @echo ""
        @echo " Add a line containing:"
        @echo " export LD_LIBRARY_PATH=$(LOCAL_DIR)/midgard-$(MIDGARD_VERSION)/lib"
        @echo ""
        @echo " and change your php.ini extension_dir to   "
        @echo " the location of midgard.so "
        @echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"




## ------------------------------------------------------------------
##             Mod_Midgard-Preparse 
## ------------------------------------------------------------------
midgard-mmp:


        @echo "MMP has not been elected/implemented here yet."



## ------------------------------------------------------------------
##             Midgard-Filetemplates 
## ------------------------------------------------------------------
midgard-filetemplates:

        @echo "Filetemplates is not yet implemented"    
                
                
        
                


## ------------------------------------------------------------------
##             Test
## ------------------------------------------------------------------
test:
        #
        # Run tests 
        # If you want to add tests
        # check in the util/test/t directory
        # or add them to runtests.sh
        #
           export VHOST=http://$(APACHE_VHOST):$(APACHE_PORT) \
        && sh ./util/test/runtests.sh
        
        
5,8c5,8
< if test "`perl -e 'print $>'`" != "0"; then
<   echo $0 must be run as root
<   exit 1
< fi
---
> #if test "`perl -e 'print $>'`" != "0"; then
> #  echo $0 must be run as root
> #  exit 1
> #fi
3,19d2
< APXSOK=`apxs 2>&1 | grep -c Usage`
< if test $APXSOK -ne 1 ; then
<    echo apxs not in PATH
<    exit 1
< fi
< 
< if test "x$CC" != "x" ; then
<    COMPILER=$CC
< else
<    COMPILER=gcc
< fi
< 
< PHP_INCLUDE=`php-config --includes`
< PHP_VERSION=`echo "#include \"php_version.h\"
< PHP_VERSION" | $COMPILER -E -I$PHP_INCLUDE/main -P - | awk '!/^[  ]*$/ { print $1}'`
< 
< echo ">> PHP VERSION $PHP_VERSION <<"
24,42d6
< PATCH=0
< if test $PHP_VERSION = '"4.0.5"'; then
<    PATCH=1
< elif test $PHP_VERSION = '"4.0.4pl1"'; then
<    PATCH=1
< elif test $PHP_VERSION = '"4.0.3pl1"'; then
<    PATCH=1
< fi
< 
< if test $PATCH -ne 0 ; then
<    cp -f config.m4 config.m4.bak
<       patch -p0 < configure.patch
< fi
< 
< phpize
< 
< ./configure --with-midgard
< make
< make install
44,46d7
< # EEH: move it back to prevent accidental checkin. Wouldn't happen to me,
< # of course. Nope. Can't happen.
< test -f config.m4.bak && cp -f config.m4.bak config.m4
##############################################################################
#
# This is a sample configuration.
# Modify to suit your installation
#
# $Header: /var/cvs/ssc_core/etc/ssc_vhost.conf.dist,v 1.2 2002/04/06 08:43:03 martin 
Exp $
#
##############################################################################
<VirtualHost ssc.nzl.com.ar>

        DocumentRoot    /home/martin/projects/cvs_cookie/ssc_core/htdocs
        CustomLog       /home/martin/projects/cvs_cookie/access_log common
        ErrorLog        /home/martin/projects/cvs_cookie/error_log
        

        AddType application/x-httpd-php .php .php4 .php3 .phtml
        AddType application/x-httpd-php-source .phps

        # Explicit allow for public dir
        <Directory /home/martin/projects/cvs_cookie/ssc_core/htdocs>            
                Options Indexes         
                Order allow,deny
                Allow from all
        </Directory>
        
        # Explicit disallow for private dirs
        # also secured by .htaccess files
        <Directory /home/martin/projects/cvs_cookie/ssc_core/htdocs/etc>               
 
                Order deny,allow
                Deny from all
        </Directory>
        <Directory /home/martin/projects/cvs_cookie/ssc_core/htdocs/inc>               
 
                Order deny,allow
                Deny from all
        </Directory>
        <Directory /home/martin/projects/cvs_cookie/ssc_core/htdocs/lib>               
 
                Order deny,allow
                Deny from all
        </Directory>
        <Directory /home/martin/projects/cvs_cookie/ssc_core/htdocs/var>               
 
                Order deny,allow
                Deny from all
        </Directory>
        
        
</VirtualHost> 
Title: SSC08 - Install

SSC08 - Install

Requirements:

Software requirements as per the documentation:

  • MySQL 3.22.32
  • glib 1.2.8
  • expat-1.95.1
  • zlib
  • libxml v2.2.12

Standard packages/software (based on Debian packaging system):

  • expat
  • zlib1g
  • zlib1g-dev
  • libglib1.2
  • libglib1.2-dev
  • cvs
  • libc6-dev
  • autoconf
  • automake
  • libtool
  • gcc
  • bison
  • libmysqlclient10
  • libmysqlclient10-dev
  • mysql-server
  • mysql-client
  • flex
  • libdb2
  • libdb2-dev
  • wget

The install procedure also requires Perl installed.

The location of libmysqlclient.so must be in ld.so.conf or equivalent -- use ldconf after editing.

Install procedure:

  1. Customize the Makefile
    1. $ cp Makefile.dist Makefile
    2. Edit Makefile to suit your mysql location and package location
  2. Make all
    $ make
  3. Optional: you can install the sysdoc database doing "make sysdoc-data"
  4. In the ./etc directory, edit ./ssc_vhost.conf.dist and save it as ./ssc_vhost.conf . If you are going to run your own development apache, comment out the VirtualHost lines.
  5. Edit httpd.conf
    1. Set the port directive to your port
    2. Check that user and group are set properly
    3. set maxrequestsperchild to 1
    4. set maxclients to 10
    5. comment out DocumentRoot
    6. comment out errorlog
    7. comment out customlog
    8. add an include statement (include /path/to/etc/ssc_vhost.conf)
  6. $ local/apache_1.3.24/bin/apachectl start
  7. You should now have apache running. Test it with a browser. (the homepage might still have some errors!)
  8. Customize the site configuration
    1. cd ./htdocs/etc
    2. cp ssc_php.inc.dist ssp_php.inc
    3. Edit ssc_php.inc to suit your site.
  9. You should now have apache running. Test it with a browser.
  10. `make test` will trigger the automated regression tests. To be able to run it successfully, please, see the testing requirements and the testing document. (See the testing requirements further down).

Midgard

  1. Customize the Makefile (probably done already!)
  2. make midgard
  3. Add the export LD_LIBRARY_PATH line to the head of your apachectl script.
  4. Edit etc/php.ini and change extension_dir to where midgard.so was installed (do a "find `pwd` -name midgard.so" to find it)
  5. Customize etc/midgard.conf.dist. Save it as midgard.conf.
  6. Edit httpd.conf. Add an include directive to include midgard.conf
  7. stop and start apache
  8. Open mysql and
    1. use <MIDGARD_DB_NAME>;
    2. update host set name="<HOST_NAME>";
    3. update host set port="<PORT>";
  9. Test with your browser the /admin area.

If everything has been built successfully, please do "make rm-src" to free 100MB.

Testing Requirements

See testing.html

$Header: /var/cvs/ssc_core/doc/INSTALL.html,v 1.5 2002/04/11 01:25:25 martin Exp $
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to