############################################################################### ## An installation guide that should be followed by the System Administrator ## ## of the machine that will host the Server side part of the AKCRS project. ## ## ## ## After the completion of this guide, the source code of the server side ## ## part of the project could be downloaded in /usr/src and build the system. ## ############################################################################### ########################################################### # Part 1. FreeBSD ########################################################### # Find a machine that will host the server side part of the project. # The machine's environment should be clean, dry, secure and preferably with low temperature. # Install the FreeBSD 9.0-RELEASE amd64 version. # Login to the fresh system as root. # Add a new user named 'akcrs' (accept the default answers) adduser # Create the directory where crash reports will arrive mkdir /var/spool/crashreports # Give ownership of the directory to akcrs chown akcrs:akcrs /var/spool/crashreports # Create an auxiliary directory used for various actions mkdir /tmp/crashreports # Create a directory where the invalid crash reports will be keeped for debugging purposes mkdir /tmp/crashreports/invalidreports # Install the FreeBSD Ports Collection portsnap fetch extract update # Install Subversion from the Ports Collection cd /usr/ports/devel/subversion make -DBATCH install clean ########################################################### # Part 2. Apache ########################################################### # Install the default and the most widely used version of the Apache HTTP Server in FreeBSD (Apache HTTP Server 2.2.22) cd /usr/ports/www/apache22 # Make any necessary configuration (THREADS selected) make config-recursive # Build, install and clean make install clean # Start the Apache HTTP Server at system startup echo 'apache22_enable="YES"' >> /etc/rc.conf # Create a copy of the original configuration file cp -v /usr/local/etc/apache22/httpd.conf /usr/local/etc/apache22/httpd.conf.original # Check the Apache configuration for errors. Do this the first time or after every change of the configuration file /usr/local/etc/rc.d/apache22 configtest # Install the Apache module for WSGI cd /usr/ports/www/mod_wsgi3 make install clean # Create a directory for the WSGI scripts mkdir /usr/local/www/apache22/wsgi-scripts # Make the WSGI script accessible (we will place it soon) echo "WSGIScriptAlias /confirm_report /usr/local/www/apache22/wsgi-scripts/confirm_report.wsgi" >> /usr/local/etc/apache22/httpd.conf echo "" >> /usr/local/etc/apache22/httpd.conf echo " Order allow,deny" >> /usr/local/etc/apache22/httpd.conf echo " Allow from all" >> /usr/local/etc/apache22/httpd.conf echo "" >> /usr/local/etc/apache22/httpd.conf # Start the Apache HTTP server /usr/local/etc/rc.d/apache22 start ########################################################### # Part 3. PostgreSQL ########################################################### # Install the default version of PostgreSQL server currently used in FreeBSD (PostgreSQL Server 9.0.8) cd /usr/ports/databases/postgresql90-server make config-recursive make install clean # Start the PostgreSQL Server at system startup echo 'postgresql_enable="YES"' >> /etc/rc.conf # Initialize the PostgreSQL database cluster for the first time. # This command creates the initial database cluster in the /usr/local/pgsql/data directory by default /usr/local/etc/rc.d/postgresql initdb # Start the database server /usr/local/etc/rc.d/postgresql start # Swith to the (system) user that owns the PostgreSQL Server (or stay as root) su pgsql # Create a new PostgreSQL user (role) that will NOT be superuser, create databases and create roles createuser -P akcrs # Create a Unicode database that our PostgreSQL user will have access to /usr/local/bin/createdb akcrsdb -O akcrs --encoding=UNICODE # Download the SQL script that creates the database schema fetch https://socsvn.freebsd.org/socsvn/soc2012/tzabal/server-side/akcrs-setup/database.sql # Using psql connect to the database as the user that owns it psql -d akcrsdb -U akcrs # Execute the SQL script that creates the database schema \i /root/database.sql # Exit psql \q # Create a copy of the original configuration file cp -v /usr/local/pgsql/data/postgresql.conf /usr/local/pgsql/data/postgresql.conf.original # Enable remote connectivity from another machine (replace with your desired WAN IP address) echo "listen_addresses = 'localhost, 46.177.115.22'" >> /usr/local/pgsql/data/postgresql.conf # Create a copy of the original configuration file of Client Authentication cp -v /usr/local/pgsql/data/pg_hba.conf /usr/local/pgsql/data/pg_hba.conf.original # Allow connections to the akcrsdb with the user akcrs with providing a password for authentication echo "host akcrsdb akcrs 0.0.0.0/0 md5" >> /usr/local/pgsql/data/pg_hba.conf # Restart the PostgreSQL Server to apply changes /usr/local/etc/rc.d/postgresql restart ########################################################### # Part 4. Python ########################################################### # Install Python (default: python 2.7.3) cd /usr/ports/lang/python make config-recursive make install clean # Install the module psycopg2 (DB API 2.0 driver of PostgreSQL for Python) cd /usr/ports/databases/py-psycopg2 make config-recursive make install clean # Install the module lxml (Library for processing XML and HTML in Python) cd /usr/ports/devel/py-lxml make config-recursive make install clean # Change into your home directory (root) cd ~ # Download the latest code of the handler (crashreportd) from the repository svn checkout https://socsvn.freebsd.org/socsvn/soc2012/tzabal/server-side/akcrs-handler/ # Change into your newly created working copy of handler cd akcrs-handler # Install it python setup.py install # Fill the values for: DBPASS, EMAIL_PASSWORD or change anything else that you may need ee /usr/local/lib/python2.7/site-packages/crashreportd/settings.py # Create a Python path configuration file for crashreportd echo "crashreportd" > /usr/local/lib/python2.7/site-packages/crashreportd.pth # Rename the crashreportd.py to crashreportd mv /usr/sbin/crashreportd.py /usr/sbin/crashreportd # Set execute permissions for crashreportd chmod 755 /usr/sbin/crashreportd # Set execute permission for confirm_report.wsgi chmod 755 /usr/local/www/apache22/wsgi-scripts/confirm_report.wsgi # Install setuptools (start of Pyramid installation) cd /usr/ports/devel/py-setuptools make install clean # Install the virtualenv package (if not found, logout and login again) easy_install virtualenv # Log out from root and become a normal user exit # As the normal user, change into your home directory cd ~ # Create a container directory mkdir modwsgi # Change into the container directory cd modwsgi # Create a virtual environment virtualenv --no-site-packages env # Change into your virtual environment cd env # Install the Pyramid Web Framework and its dependencies bin/easy_install pyramid # Download the latest code of the website from the repository svn checkout https://socsvn.freebsd.org/socsvn/soc2012/tzabal/server-side/akcrs-website/ # Change into the akcrs-website directory cd akcrs-website # Edit the value of the variable sqlalchemy.url in the production.ini and development.ini files ee production.ini ee development.ini # Change the value of the secret argument of the AuthTktAuthenticationPolicy constructor (and keep it secret!) ee akcrswebsite/__init__.py # Build and install the website (dependencies are downloaded and installed) ../bin/python setup.py install # Go back to the root of your virtual env directory cd .. # Create a WSGI script touch pyramid.wsgi # Append the following lines echo "from pyramid.paster import get_app, setup_logging" > pyramid.wsgi echo "ini_path = '/home/tzabal/modwsgi/env/akcrs-website/production.ini'" >> pyramid.wsgi echo "setup_logging(ini_path)" >> pyramid.wsgi echo "application = get_app(ini_path, 'main')" >> pyramid.wsgi # Make the WSGI script executable chmod 755 pyramid.wsgi # Edit the main Apache configuration