Skip to content
Chris Churas edited this page Jul 12, 2022 · 18 revisions

Software Dependencies

The App Store requires the following software packages:

  • Python 3.7
  • Django 2.2.28
  • Whoosh 2.7.4
  • python-geoip (not sure if these is needed anymore)
  • django-social-auth 0.7.28
  • social-auth-app-django 3.1.0
  • django-haystack 2.8.1
  • sphinx
  • urllib3
  • Pillow
  • gevent
  • Database Server and appropriate client (AppStore uses Mysql)

NOTE: For exact requirements see requirements.txt file in this repo. Once python 3.7 is setup pip install -r requirements.txt will install all required packages

Migration

If you want to move the App Store to another machine running Ubuntu, here is what to do:

NOTE: These steps are derived from the bootstrap.sh script, available in this repo, used to spin up Vagrant Virtual Machine with AppStore installed.

  1. Install the following packages:

    apt-get -y install apache2 apache2-dev apache2-utils ssl-cert wget
    apt-get -y install libapache2-mod-wsgi-py3 gcc g++ git
    apt-get -y install mysql-server
    apt-get -y install geoip-database # this may not be needed anymore
  2. Install Miniconda (Anaconda could also be used with adjustments to paths below) to /opt/miniconda3 and set PATH so that python calls use that Python.

    # as root
    pushd /tmp
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
    chmod a+x Miniconda3-latest-Linux-x86_64.sh
    /bin/rm Miniconda3-latest-Linux-x86_64.sh
    popd
    
    # Set paths 
    export PATH=/opt/miniconda3/bin:$PATH
    echo "export PATH=/opt/miniconda3/bin:$PATH" >> /root/.bash_profile
    echo "export PATH=/opt/miniconda3/bin:$PATH" >> /root/.bashrc
  3. Install mysqlclient which is most easily done with conda:

    conda install -y mysqlclient
  4. Install mod_wsgi:

    pip install mod_wsgi
  5. Configure mod_wsgi. These commands are derived from instructions found here:

    # as root
    # update wsgi.conf configuration
    WSGI_CONF="/etc/apache2/mods-available/wsgi.conf"
    SITE_PKG=`find /opt/miniconda3 -regex "/opt/miniconda3/lib/python.*/site-packages$" -type d 2> /dev/null`
    echo "<IfModule mod_wsgi.c>" > $WSGI_CONF
    echo "   WSGIPythonHome /opt/miniconda3" >> $WSGI_CONF
    echo "   WSGIPythonPath $SITE_PKG" >> $WSGI_CONF
    echo "</IfModule>" >> $WSGI_CONF
    
    # update wsgi.load file
    mod_wsgi-express install-module | egrep "^LoadModule" > /etc/apache2/mods-available/wsgi.load 
    
    # enable wsgi
    a2enmod wsgi
    
    # updates shared library cache (might not be needed anymore)
    ldconfig
  6. Create database

    # as root
    mysqladmin create AppStore
  7. Create database user

    # log into mysql with superuser account
    # as root
    mysql -u root
    
    # run these commands replacing @@PASSWORD@@ with a password that needs to be set in settings file later
    CREATE USER 'appstoreuser'@'localhost' IDENTIFIED BY '@@PASSWORD@@';
    CREATE USER 'appstoreuser'@'127.0.0.1' IDENTIFIED BY '@@PASSWORD@@';
    GRANT ALL PRIVILEGES ON AppStore.* to 'appstoreuser'@'localhost';
    GRANT ALL PRIVILEGES ON AppStore.* to 'appstoreuser'@'127.0.0.1';
    GRANT ALL PRIVILEGES ON test_AppStore.* to 'appstoreuser'@'localhost';
    GRANT ALL PRIVILEGES ON test_AppStore.* to 'appstoreuser'@'127.0.0.1';
    FLUSH PRIVILEGES;
  8. Check out the App Store GitHub repository to the new machine under /var/www directory: http://github.com/cytoscape/appstore

    # as root
    pushd /var/www
    git clone http://github.com/cytoscape/appstore
    cd appstore
    # make some needed directories
    mkdir logs
    mkdir /var/www/html/media
    mkdir /var/www/html/misc
    cp favicon.ico /var/www/html/misc/.
    cp google_oauth2_logo.png /var/www/html/misc/.
  9. Install needed Python modules:

    # as root and in /var/www/appstore directory with /opt/miniconda/bin in PATH
    pip install -r requirements.txt
  10. Create settings/production.py from settings/vagrant.py and update the following:

    • Update values in ADMINS
    • Update EMAIL_HOST, EMAIL_HOST_USER, EMAIL_ADDR, and EMAIL_HOST_PASSWORD
    • Check FULL_URL is correct
    • Update SOCIAL_AUTH_GOOGLE_OAUTH2_KEY, SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET, & GOOGLE_API_KEY
    • Comment out EMAIL_BACKEND line since we want to use regular SMTP
    • Set EMAIL CONFIGURATION
    • Generate new SECRET_KEY and keep it secret. Click here for more information
    • Update database @@PASSWORD@@ to match value set above
  11. Create the following daily cron jobs on the new machine:

    • Database backups described above in the subsection Backup System.

    • As root run:

      cd /var/www/appstore
      /opt/miniconda/bin/python manage.py rebuild_index`
      chown -R www-data.www-data /var/www/appstore/whoosh_index
  12. Populate /var/www/html/static data

    cd /var/www/appstore
    /opt/miniconda3/bin/python manage.py collectstatic
  13. Take a snapshot of the database using mysqldump then load it to the new machine's database:

    Run this on the old machine:

    mysqldump -u USER_NAME DB_NAME > CyAppStoreDbDump.sql
    

    Transfer CyAppStoreDbDump.sql from the old to new machine:

    Run this on the new machine:

    mysql -u USER_NAME DB_NAME < CyAppStoreDbDump.sql
    
  14. Setup Lets Encrypt

  15. Using bootstrap.sh as a guide copy over appstore.http.conf and appstore.include.conf

  16. Restart Apache and run the test protocol that's described below.

    systemctl restart apache2
Clone this wiki locally