Changes between Initial Version and Version 1 of InstallationGuidelines/Linux/Server/RedHat


Ignore:
Timestamp:
06/22/12 10:21:10 (10 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InstallationGuidelines/Linux/Server/RedHat

    v1 v1  
     1= !RedHat =
     2[[TOC]]
     3
     4We normally recommend users to install on Debian 6 Squeeze servers wherever possible as those scripts are the best maintained.
     5
     6If you need to install on a !RedHat-based system then you may find the nots on this page useful:
     7
     8== Fedora ==
     9We have no Sahana-specific documentation, however this Web2Py script could be useful:
     10 * https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-fedora.sh
     11
     12Also see:
     13 * http://www.web2pyslices.com/slices/take_slice/98
     14
     15== CentOS ==
     16CentOS 5.x comes with just Python 2.4.3, so need to add the EPEL repository to upgrade to Python26
     17{{{
     18yum install -y lrzsz
     19yum install -y sqlite-devel zlib-devel bzip2-devel libxslt-devel
     20yum install -y gcc
     21
     22wget https://fedoraproject.org/static/217521F6.txt
     23rpm --import 217521F6.txt
     24
     25vim /etc/yum.repos.d/epel.repo
     26[epel]
     27name=Extra Packages for Enterprise Linux 5 - $basearch
     28#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
     29mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
     30failovermethod=priority
     31enabled=1
     32gpgcheck=1
     33gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
     34
     35[epel-debuginfo]
     36name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
     37#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
     38mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
     39failovermethod=priority
     40enabled=0
     41gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
     42gpgcheck=1
     43
     44[epel-source]
     45name=Extra Packages for Enterprise Linux 5 - $basearch - Source
     46#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
     47mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
     48failovermethod=priority
     49enabled=0
     50gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
     51gpgcheck=1
     52
     53
     54yum install -y python26 python26-devel
     55yum install -y python26-imaging
     56
     57yum install -y httpd-devel
     58wget http://dl.fedoraproject.org/pub/epel/5/SRPMS/python26-mod_wsgi-3.3-1.el5.src.rpm
     59rpm -ivh python26-mod_wsgi-3.3-1.el5.src.rpm
     60yum install -y redhat-rpm-config
     61rpmbuild -bb /usr/src/redhat/SPECS/python26-mod_wsgi.spec
     62rpm -ivh /usr/src/redhat/RPMS/x86_64/python26-mod_wsgi-3.3-1.x86_64.rpm
     63cat << EOF > "/etc/httpd/conf.d/python26-mod_wsgi.conf"
     64<IfModule !python_module>
     65    <IfModule !wsgi_module>
     66        LoadModule wsgi_module modules/python26-mod_wsgi.so
     67        WSGISocketPrefix /var/run
     68    </IfModule>
     69</IfModule>
     70EOF
     71
     72wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
     73tar zxvf setuptools-0.6c11.tar.gz
     74cd setuptools-0.6c11
     75/usr/bin/python26 setup.py install
     76cd ..
     77
     78wget http://pypi.python.org/packages/source/l/lxml/lxml-2.3.4.tar.gz
     79tar zxvf lxml-2.3.4.tar.gz
     80cd lxml-2.3.4
     81/usr/bin/python26 setup.py install
     82cd ..
     83
     84yum install -y rpm-build
     85wget http://pkgs.repoforge.org/geos/geos-3.2.2-1.rf.src.rpm
     86rpm -ivh geos-3.2.2-1.rf.src.rpm
     87rpmbuild -bb /usr/src/redhat/SPECS/geos.spec
     88rpm -ivh /usr/src/redhat/RPMS/x86_64/geos*.rpm
     89
     90wget http://pypi.python.org/packages/source/S/Shapely/Shapely-1.2.14.tar.gz
     91tar zxvf Shapely-1.2.14.tar.gz
     92cd Shapely-1.2.14
     93/usr/bin/python26 setup.py install
     94cd ..
     95
     96yum install -y python26-numpy python26-numpy-devel
     97yum install -y libpng-devel
     98wget http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
     99tar zxvf matplotlib-1.1.0.tar.gz
     100cd matplotlib-1.1.0
     101/usr/bin/python26 setup.py install
     102cd ..
     103
     104wget http://pypi.python.org/packages/source/x/xlwt/xlwt-0.7.4.tar.gz
     105tar zxvf xlwt-0.7.4.tar.gz
     106cd xlwt-0.7.4
     107/usr/bin/python26 setup.py install
     108cd ..
     109
     110wget http://pypi.python.org/packages/source/x/xlrd/xlrd-0.7.7.tar.gz
     111tar zxvf xlrd-0.7.7.tar.gz
     112cd xlrd-0.7.7
     113/usr/bin/python26 setup.py install
     114cd ..
     115
     116yum install -y freetype-devel
     117wget http://www.reportlab.com/ftp/reportlab-2.5.tar.gz
     118tar zxvf reportlab-2.5.tar.gz
     119cd reportlab-2.5
     120/usr/bin/python26 setup.py install
     121cd ..
     122
     123wget http://labix.org/download/python-dateutil/python-dateutil-1.5.tar.gz
     124tar zxvf python-dateutil-1.5.tar.gz
     125cd python-dateutil-1.5
     126/usr/bin/python26 setup.py install
     127cd ..
     128
     129wget http://ipython.scipy.org/dist/0.10.2/ipython-0.10.2.tar.gz
     130tar zxvf ipython-0.10.2.tar.gz
     131cd ipython-0.10.2
     132/usr/bin/python26 setup.py install
     133cd ..
     134
     135yum install -y mysql-server
     136yum install -y phpMyAdmin
     137yum install -y python26-mysqldb
     138/etc/init.d/mysqld start
     139chkconfig --level 3 mysqld on
     140chkconfig --level 4 mysqld on
     141chkconfig --level 5 mysqld on
     142mysqladmin -u root -p password new-password
     143<Enter - default password is blank>
     144
     145yum install -y git
     146
     147adduser -rd /var/www/web2py web2py
     148cd /var/www
     149git clone git://github.com/web2py/web2py.git
     150cat << EOF > "/var/www/web2py/routes.py"
     151#!/usr/bin/python26
     152default_application = 'eden'
     153default_controller = 'default'
     154default_function = 'index'
     155routes_onerror = [
     156        ('eden/400', '!'),
     157        ('eden/401', '!'),
     158        ('eden/*', '/eden/errors/index'),
     159        ('*/*', '/eden/errors/index'),
     160    ]
     161EOF
     162sed -i 's|python|python26|' /var/www/web2py/wsgihandler.py
     163ln -s /var/www/web2py /home/web2py
     164ln -s /var/www/web2py ~
     165cd web2py
     166cd applications
     167git clone git://github.com/flavour/eden.git
     168# Fix permissions
     169chown web2py ~web2py/
     170chown web2py ~web2py/applications/admin/cache
     171chown web2py ~web2py/applications/admin/cron
     172chown web2py ~web2py/applications/admin/databases
     173chown web2py ~web2py/applications/admin/errors
     174chown web2py ~web2py/applications/admin/sessions
     175chown web2py ~web2py/applications/eden
     176chown web2py ~web2py/applications/eden/cache
     177chown web2py ~web2py/applications/eden/cron
     178mkdir -p ~web2py/applications/eden/databases
     179chown web2py ~web2py/applications/eden/databases
     180chown web2py ~web2py/applications/eden/errors
     181chown web2py ~web2py/applications/eden/models
     182chown web2py ~web2py/applications/eden/sessions
     183chown web2py ~web2py/applications/eden/static/img/markers
     184mkdir -p ~web2py/applications/eden/static/cache/chart
     185chown web2py -R ~web2py/applications/eden/static/cache
     186chown web2py ~web2py/applications/eden/uploads
     187mkdir -p ~web2py/applications/eden/uploads/gis_cache
     188mkdir -p ~web2py/applications/eden/uploads/images
     189mkdir -p ~web2py/applications/eden/uploads/tracks
     190chown web2py ~web2py/applications/eden/uploads/gis_cache
     191chown web2py ~web2py/applications/eden/uploads/images
     192chown web2py ~web2py/applications/eden/uploads/tracks
     193ln -s /home/web2py/applications/eden ~
     194
     195cat << EOF > "/usr/local/bin/backup"
     196#!/bin/sh
     197NOW=\$(date +"%Y-%m-%d")
     198mysqldump sahana > /root/backup-\$NOW.sql
     199OLD=\$(date --date='7 day ago' +"%Y-%m-%d")
     200rm -f /root/backup-\$OLD.sql
     201EOF
     202chmod +x /usr/local/bin/backup
     203cat << EOF > "/usr/local/bin/compile"
     204#!/bin/sh
     205cd ~web2py
     206python26 web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
     207service httpd restart
     208EOF
     209chmod +x /usr/local/bin/compile
     210
     211cat << EOF > "/usr/local/bin/pull"
     212#!/bin/sh
     213cd ~web2py/applications/eden
     214sed -i 's/deployment_settings.base.migrate = False/deployment_settings.base.migrate = True/g' models/000_config.py
     215git pull
     216
     217# Maintenance
     218ln -sf /etc/httpd/conf/maintenance.conf /etc/httpd/conf/vhosts.conf
     219service httpd reload
     220killall -u web2py python
     221
     222rm -rf compiled
     223cd ~web2py
     224sudo -H -u web2py python26 web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
     225cd ~web2py/applications/eden
     226sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
     227
     228cd ~web2py
     229python26 web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
     230ln -sf /etc/httpd/conf/production.conf /etc/httpd/conf/vhosts.conf
     231cd ~web2py && sudo -H -u web2py python web2py.py -K eden -Q >/dev/null 2>&1 &
     232service httpd reload
     233EOF
     234chmod +x /usr/local/bin/pull
     235
     236# Change the value of prepopulate, if-necessary
     237cat << EOF2 > "/usr/local/bin/clean"
     238#!/bin/sh
     239# Maintenance
     240ln -sf /etc/httpd/conf/maintenance.conf /etc/httpd/conf/vhosts.conf
     241service httpd reload
     242killall -u web2py python
     243
     244cd ~web2py/applications/eden
     245rm -f databases/*
     246rm -f errors/*
     247rm -f sessions/*
     248rm -rf uploads/*
     249sed -i 's/deployment_settings.base.migrate = False/deployment_settings.base.migrate = True/g' models/000_config.py
     250sed -i 's/deployment_settings.base.prepopulate = 0/deployment_settings.base.prepopulate = 1/g' models/000_config.py
     251rm -rf compiled
     252mysqladmin -f drop sahana
     253mysqladmin create sahana
     254cd ~web2py
     255sudo -H -u web2py python26 web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
     256cd ~web2py/applications/eden
     257sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
     258sed -i 's/deployment_settings.base.prepopulate = 1/deployment_settings.base.prepopulate = 0/g' models/000_config.py
     259
     260cd ~web2py
     261python26 web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
     262ln -sf /etc/httpd/conf/production.conf /etc/httpd/conf/vhosts.conf
     263cd ~web2py && sudo -H -u web2py python web2py.py -K eden -Q >/dev/null 2>&1 &
     264service httpd reload
     265EOF2
     266chmod +x /usr/local/bin/clean
     267
     268cat << EOF > "/usr/local/bin/w2p"
     269#!/bin/sh
     270cd ~web2py
     271python26 web2py.py -S eden -M
     272EOF
     273chmod +x /usr/local/bin/w2p
     274}}}
     275
     276{{{
     277#!/bin/sh
     278# Script to configure an Eden server
     279# - assumes that install-eden-apache-mysql.sh has been run
     280echo -e "What domain name should we use? : \c "
     281read DOMAIN
     282echo -e "What host name should we use? : \c "
     283read hostname
     284sitename=$hostname".$DOMAIN"
     285echo -e "What is the current root MySQL password: \c "
     286read rootpw
     287# @ToDo: Generate a random password
     288echo -e "What should be the MySQL password for user 'sahana': \c "
     289read password
     290echo "Now reconfiguring system to use the hostname: $hostname"
     291cd /etc
     292filename="hosts"
     293sed -i "s|localdomain localhost|localdomain localhost $hostname|" $filename
     294cd /etc
     295filename="hostname"
     296echo $hostname > $filename
     297cd /etc
     298filename="mailname"
     299echo $sitename >  $filename
     300# -----------------------------------------------------------------------------
     301# Update system
     302#   in case run at a much later time than the install script
     303# -----------------------------------------------------------------------------
     304yum update
     305# If using the bleeding edge Web2py:
     306cd ~web2py
     307git pull
     308cd ~web2py/applications/eden
     309git pull
     310# -----------------------------------------------------------------------------
     311# Email
     312# -----------------------------------------------------------------------------
     313#echo configure for Internet mail delivery
     314#dpkg-reconfigure exim4-config
     315# -----------------------------------------------------------------------------
     316# Apache Web server
     317# -----------------------------------------------------------------------------
     318echo "Setting up Web server"
     319sed -i 's|#NameVirtualHost \*:80|NameVirtualHost \*:80|' /etc/httpd/conf/httpd.conf
     320cat << EOF >> "/etc/httpd/conf/httpd.conf"
     321Include conf/vhosts.conf
     322EOF
     323cat << EOF > "/etc/httpd/conf/production.conf"
     324<VirtualHost *:80>
     325  ServerName $hostname.$DOMAIN
     326  ServerAdmin webmaster@$DOMAIN
     327  DocumentRoot /var/www/web2py/applications
     328  WSGIScriptAlias / /var/www/web2py/wsgihandler.py
     329  ## Edit the process and the maximum-requests to reflect your RAM
     330  WSGIDaemonProcess web2py user=web2py group=web2py home=/var/www/web2py processes=4 maximum-requests=100
     331  RewriteEngine On
     332  # Stop GoogleBot from slowing us down
     333  RewriteRule .*robots\.txt$ /eden/static/robots.txt [L]
     334  # extract desired cookie value from multiple-cookie HTTP header
     335  #RewriteCond %{HTTP_COOKIE} registered=([^;]+)
     336  # check that cookie value is correct
     337  #RewriteCond %1 ^yes$
     338  #RewriteRule ^/$ /eden/ [R,L]
     339  #RewriteRule ^/$ /eden/static/index.html [R,L]
     340  RewriteCond %{REQUEST_URI}    !/phpmyadmin(.*)
     341  RewriteCond %{REQUEST_URI}    !/eden/(.*)
     342  RewriteRule /(.*) /eden/$1 [R]
     343  ### static files do not need WSGI
     344  <LocationMatch "^(/[\w_]*/static/.*)">
     345    Order Allow,Deny
     346    Allow from all
     347    SetOutputFilter DEFLATE
     348    BrowserMatch ^Mozilla/4 gzip-only-text/html
     349    BrowserMatch ^Mozilla/4\.0[678] no-gzip
     350    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
     351    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
     352    Header append Vary User-Agent env=!dont-vary
     353    ExpiresActive On
     354    ExpiresByType text/html "access plus 1 day"
     355    ExpiresByType text/javascript "access plus 1 week"
     356    ExpiresByType text/css "access plus 2 weeks"
     357    ExpiresByType image/ico "access plus 1 month"
     358    ExpiresByType image/gif "access plus 1 month"
     359    ExpiresByType image/jpeg "access plus 1 month"
     360    ExpiresByType image/jpg "access plus 1 month"
     361    ExpiresByType image/png "access plus 1 month"
     362    ExpiresByType application/x-shockwave-flash "access plus 1 month"
     363  </LocationMatch>
     364  ### everything else goes over WSGI
     365  <Location "/">
     366    Order deny,allow
     367    Allow from all
     368    WSGIProcessGroup web2py
     369  </Location>
     370  ErrorLog /var/log/httpd/$hostname_error.log
     371  LogLevel warn
     372  CustomLog /var/log/httpd/$hostname_access.log combined
     373</VirtualHost>
     374EOF
     375ln -sf /etc/httpd/conf/production.conf /etc/httpd/conf/vhosts.conf
     376service httpd restart
     377cat << EOF > "/etc/httpd/conf/maintenance.conf"
     378<VirtualHost *:80>
     379  ServerName $hostname.$DOMAIN
     380  ServerAdmin webmaster@$DOMAIN
     381  DocumentRoot /var/www
     382  RewriteEngine On
     383  RewriteCond %{REQUEST_URI} !/phpmyadmin(.*)
     384  RewriteRule ^/(.*) /maintenance.html
     385  <Location "/">
     386    Order deny,allow
     387    Allow from all
     388  </Location>
     389  ErrorLog /var/log/httpd/maintenance_error.log
     390  LogLevel warn
     391  CustomLog /var/log/httpd/maintenance_access.log combined
     392</VirtualHost>
     393EOF
     394# -----------------------------------------------------------------------------
     395# MySQL Database
     396# -----------------------------------------------------------------------------
     397echo "Setting up Database"
     398# Allow root user to access database without entering password
     399cat << EOF > "/root/.my.cnf"
     400[client]
     401user=root
     402EOF
     403echo "password='$rootpw'" >> "/root/.my.cnf"
     404# Create database
     405mysqladmin create sahana
     406# Create user for Sahana application
     407echo "CREATE USER 'sahana'@'localhost' IDENTIFIED BY '$password';" > "/tmp/mypass"
     408echo "GRANT ALL PRIVILEGES ON *.* TO 'sahana'@'localhost' WITH GRANT OPTION;" >> "/tmp/mypass"
     409mysql < /tmp/mypass
     410rm -f /tmp/mypass
     411# Schedule backups for 02:01 daily
     412echo "1 2   * * * * root    /usr/local/bin/backup" >> "/etc/crontab"
     413# -----------------------------------------------------------------------------
     414# Sahana Eden
     415# -----------------------------------------------------------------------------
     416echo "Setting up Sahana"
     417# Copy Templates
     418cp ~web2py/applications/eden/private/templates/000_config.py ~web2py/applications/eden/models
     419sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' ~web2py/applications/eden/models/000_config.py
     420sed -i "s|akeytochange|$sitename$password|" ~web2py/applications/eden/models/000_config.py
     421sed -i "s|127.0.0.1:8000|$sitename|" ~web2py/applications/eden/models/000_config.py
     422sed -i 's|base.cdn = False|base.cdn = True|' ~web2py/applications/eden/models/000_config.py
     423# Configure Database
     424sed -i 's|#settings.database.db_type = "mysql"|settings.database.db_type = "mysql"|' ~web2py/applications/eden/models/000_config.py
     425sed -i "s|#settings.database.password = \"password\"|settings.database.password = \"$password\"|" ~web2py/applications/eden/models/000_config.py
     426# Create the Tables & Populate with base data
     427sed -i 's|settings.base.prepopulate = 0|settings.base.prepopulate = 1|' ~web2py/applications/eden/models/000_config.py
     428sed -i 's|settings.base.migrate = False|settings.base.migrate = True|' ~web2py/applications/eden/models/000_config.py
     429cd ~web2py
     430sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
     431# Configure for Production
     432sed -i 's|settings.base.prepopulate = 1|settings.base.prepopulate = 0|' ~web2py/applications/eden/models/000_config.py
     433sed -i 's|settings.base.migrate = True|settings.base.migrate = False|' ~web2py/applications/eden/models/000_config.py
     434cd ~web2py
     435sudo -H -u web2py python web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
     436# Add Scheduler
     437sed -i 's|exit 0|cd ~web2py \&\& python26 web2py.py -K eden -Q >/dev/null 2>\&1 \&|' /etc/rc.local
     438echo "exit 0" >> /etc/rc.local
     439#read -p "Press any key to Reboot..."
     440echo "Now rebooting.."
     441reboot
     442# END
     443}}}
     444
     445@ToDo: matplotlib config (/etc/matplotlibrc not found)
     446
     447=== CentOS alternate options ===
     448These are notes on some possible alternate options
     449
     450Install a local version of Python27:
     451{{{
     452mkdir -p /opt/python2.7
     453wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
     454tar -jxvf Python-2.7.3.tar.bz2
     455cd Python-2.7.3
     456./configure --prefix=/opt/python2.7 --with-threads --enable-shared
     457make && make install
     458cd ..
     459ln -s /opt/python2.7/lib/libpython2.7.so /usr/lib
     460ln -s /opt/python2.7/lib/libpython2.7.so.1.0 /usr/lib
     461ln -s /opt/python2.7/bin/python /usr/local/bin/python
     462ln -s /opt/python2.7/bin/python /usr/bin/python2.7
     463ln -s /opt/python2.7/lib/python2.7.so /opt/python2.6/lib/python2.7/config/
     464/sbin/ldconfig
     465
     466wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz
     467tar -xzf mod_wsgi-3.3.tar.gz
     468cd mod_wsgi-3.3
     469./configure --with-python=/usr/local/bin/python
     470make &&  make install
     471cd ..
     472echo "LoadModule wsgi_module modules/mod_wsgi.so" > /etc/httpd/conf.d/wsgi.conf
     473
     474Use:
     475/opt/python2.7/bin/python
     476
     477wget http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz
     478tar zxvf MySQL-python-1.2.3.tar.gz
     479cd MySQL-python-1.2.3
     480/opt/python2.7/bin/python setup.py install
     481cd ..
     482
     483# PostgreSQL 8.1.x in CentOS 5! Better to use MySQL
     484#wget http://pkgs.repoforge.org/proj/proj-4.7.0-1.el5.rf.i386.rpm
     485#wget http://pkgs.repoforge.org/postgis/postgis-1.3.6-1.el5.rf.i386.rpm
     486#rpm -ivh proj-4.7.0-1.el5.rf.i386.rpm
     487#rpm -ivh postgis-1.3.6-1.el5.rf.i386.rpm
     488#yum install postgresql postgresql-server postgresql-devel
     489#wget http://initd.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.2.tar.gz
     490#tar zxvf psycopg2-2.4.2.tar.gz
     491#cd psycopg2-2.4.2
     492#/opt/python2.6/bin/python setup.py install
     493#cd ..
     494#/etc/init.d/postgresql start
     495}}}