Date: Sat, 25 Aug 2012 18:36:24 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r240848 - soc2012/tzabal/server-side/akcrs-setup Message-ID: <20120825183624.1B972106566B@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tzabal Date: Sat Aug 25 18:36:23 2012 New Revision: 240848 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240848 Log: Updates for the server setup guide. Modified: soc2012/tzabal/server-side/akcrs-setup/setup Modified: soc2012/tzabal/server-side/akcrs-setup/setup ============================================================================== --- soc2012/tzabal/server-side/akcrs-setup/setup Sat Aug 25 18:33:04 2012 (r240847) +++ soc2012/tzabal/server-side/akcrs-setup/setup Sat Aug 25 18:36:23 2012 (r240848) @@ -65,10 +65,15 @@ # 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 @@ -78,7 +83,7 @@ # Build, install and clean make -DBATCH install clean -# Launch Apache at system startup +# Start the Apache HTTP Server at system startup echo 'apache22_enable="YES"' >> /etc/rc.conf # Create a copy of the original configuration file @@ -94,29 +99,27 @@ # Create a directory for the WSGI scripts mkdir /usr/local/www/apache22/wsgi-scripts -# Place the WSGI script inside the WSGI directory -cp -v /home/tzabal/confirm_report.wsgi /usr/local/www/apache22/wsgi-scripts - -# Set proper permissions (others need to have execute permissions) -chmod 755 /usr/local/www/apache22/wsgi-scripts/confirm_report.wsgi - -# Make the WSGI script accessible +# 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 "<Directory /usr/local/www/apache22/wsgi-scripts>" >> /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 "</Directory>" >> /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 make install clean -# Run the PostgreSQL Server at startup +# Start the PostgreSQL Server at system startup echo 'postgresql_enable="YES"' >> /etc/rc.conf # Initialize the PostgreSQL database cluster for the first time. @@ -132,18 +135,36 @@ # 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 has access to +# 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 /home/tzabal/akcrs/server-side/akcrs-setup/database.sql +\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 @@ -154,14 +175,86 @@ make -DBATCH install clean # Install the module psycopg2 (DB API 2.0 driver of PostgreSQL for Python) -easy_install psycopg2 +cd /usr/ports/databases/py-psycopg2 +make install clean # Install the module lxml (Library for processing XML and HTML in Python) -easy_install lxml +cd /usr/ports/devel/py-lxml +make install clean + +# Download the crashreportd program from repo + +# Install it +python setup.py install + +# 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 -# Install the pip installer -cd /usr/ports/devel/py-pip +# 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 Django -pip install Django \ No newline at end of file +# 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 +cd 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 variable sqlalchemy.url and add the variable mako.directories in the production.ini file (check the development.ini for guidance) +ee production.ini + +# Change the secret code of the authn_policy variable to something else +ee akcrs/__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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120825183624.1B972106566B>