| 20 | | wget http://downloads.sourceforge.net/project/translate/python-Levenshtein/0.10.1/python-Levenshtein-0.10.1.tar.bz2 |
| 21 | | tar jxvf python-Levenshtein-0.10.1.tar.bz2 |
| 22 | | cd python-Levenshtein-0.10.1 |
| 23 | | python setup.py install |
| 24 | | cd .. |
| | 16 | apt-get install -y build-essential libxml2-dev libxslt-dev python-dev python-pip zlib1g-dev |
| | 17 | apt-get install -y nginx python-certbot-nginx |
| | 18 | certbot --nginx -n --agree-tos --email webmaster@sahanafoundation.org -d pootle.sahanafoundation.org |
| | 19 | # Copy to server: /etc/nginx/sites-available/default |
| | 20 | cd /tmp |
| | 21 | wget https://projects.unbit.it/downloads/uwsgi-2.0.18.tar.gz |
| | 22 | zxvf uwsgi-2.0.18.tar.gz |
| | 23 | cd uwsgi-2.0.18 |
| | 24 | python uwsgiconfig.py --build pyonly |
| | 25 | cp uwsgi /usr/local/bin |
| | 26 | chmod 755 /usr/local/bin/uwsgi |
| | 27 | # Copy to server: /etc/init.d/uwsgi-pootle |
| | 28 | chmod 755 /etc/init.d/uwsgi-pootle |
| | 29 | /etc/init.d/uwsgi-pootle defaults |
| | 30 | apt-get -y install "postgresql-11" "pgtop" |
| | 31 | cat << EOF >> "/etc/sysctl.conf" |
| | 32 | ## Increase Shared Memory available for PostgreSQL |
| | 33 | # 1024Mb (may need more) |
| | 34 | kernel.shmmax = 552992768 |
| | 35 | kernel.shmall = 2097152 |
| | 36 | EOF |
| | 37 | sysctl -w kernel.shmmax=552992768 # For 1024 MB RAM |
| | 38 | sysctl -w kernel.shmall=2097152 |
| | 39 | sed -i 's|#track_counts = on|track_counts = on|' /etc/postgresql/11/main/postgresql.conf |
| | 40 | sed -i 's|#autovacuum = on|autovacuum = on|' /etc/postgresql/11/main/postgresql.conf |
| | 41 | sed -i 's|max_connections = 100|max_connections = 20|' /etc/postgresql/11/main/postgresql.conf |
| | 42 | # 1024Mb RAM: (e.g. t2.micro) |
| | 43 | sed -i 's|#effective_cache_size = 4GB|effective_cache_size = 512MB|' /etc/postgresql/11/main/postgresql.conf |
| | 44 | sed -i 's|#work_mem = 4MB|work_mem = 8MB|' /etc/postgresql/11/main/postgresql.conf |
| | 45 | service postgresql restart |
| 26 | | apt-get install -y memcached |
| 27 | | wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.51.tar.gz |
| 28 | | tar zxvf python-memcached-1.51.tar.gz |
| 29 | | cd python-memcached-1.51 |
| 30 | | python setup.py install |
| 31 | | cd .. |
| 32 | | |
| 33 | | wget http://downloads.sourceforge.net/project/translate/Translate%20Toolkit/1.10.0/translate-toolkit-1.10.0.tar.bz2 |
| 34 | | tar jxvf translate-toolkit-1.10.0.tar.bz2 |
| 35 | | cd translate-toolkit-1.10.0 |
| 36 | | python setup.py install |
| 37 | | cd .. |
| 38 | | |
| 39 | | wget --no-check-certificate -O Django-1.4.5.tar.gz https://www.djangoproject.com/download/1.4.5/tarball/ |
| 40 | | tar zxvf Django-1.4.5.tar.gz |
| 41 | | cd Django-1.4.5 |
| 42 | | python setup.py install |
| 43 | | cd .. |
| 44 | | |
| 45 | | # @ToDo: https://lucene.apache.org/pylucene/ |
| 46 | | |
| 47 | | wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz |
| 48 | | tar zxvf pip-1.3.1.tar.gz |
| 49 | | cd pip-1.3.1 |
| 50 | | python setup.py install |
| 51 | | cd .. |
| 52 | | |
| 53 | | apt-get install -y libxslt1-dev |
| | 47 | su postgres |
| | 48 | createuser -P pootle |
| | 49 | createdb --encoding='utf8' --locale=en_US.utf8 --template=template0 --owner=pootle pootledb |
| | 50 | exit |
| | 51 | apt-get install -y redis-server |
| | 52 | adduser pootle |
| | 53 | # Copy to server: /home/pootle/uwsgi.ini |
| | 54 | # Copy to server: /home/pootle/wsgihandler.py |
| 55 | | #virtualenv /var/www/pootle/env/ |
| 56 | | #source /var/www/pootle/env/bin/activate |
| 57 | | pip install pootle |
| 58 | | |
| 59 | | # Reduce MaxClients |
| 60 | | sed -i 's|150|20|' /etc/apache2/apache2.conf |
| 61 | | |
| 62 | | cd /var/www |
| 63 | | ln -s /usr/local/lib/python2.6/dist-packages/pootle |
| 64 | | |
| 65 | | adduser --system --disabled-password --home /var/www/pootle pootle |
| 66 | | addgroup pootle |
| 67 | | |
| 68 | | chown www-data /var/www/pootle/po |
| 69 | | |
| 70 | | mysql -u root -p |
| 71 | | > CREATE DATABASE pootle CHARACTER SET = 'utf8'; |
| 72 | | > GRANT ALL PRIVILEGES ON pootle.* TO pootle@localhost IDENTIFIED BY 'pootlepassword'; |
| 73 | | > FLUSH PRIVILEGES; |
| 74 | | |
| 75 | | #sed -i "s|'localhost'|'pootle.sahanafoundation.org'|" /var/www/pootle/settings/90-local.conf.sample |
| 76 | | sed -i 's|django.db.backends.sqlite3|django.db.backends.mysql|' /var/www/pootle/settings/20-backends.conf |
| 77 | | sed -i "s|working_path('dbs/pootle.db')|'pootle'|" /var/www/pootle/settings/20-backends.conf |
| 78 | | sed -i "s|'USER': ''|'USER': 'pootle'|" /var/www/pootle/settings/20-backends.conf |
| 79 | | sed -i "s|'PASSWORD': ''|'PASSWORD': 'pootlepassword'|" /var/www/pootle/settings/20-backends.conf |
| 80 | | sed -i "s|'BACKEND': 'django.core.cache.backends.db.DatabaseCache'|'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache'|" /var/www/pootle/settings/20-backends.conf |
| 81 | | sed -i "s|'LOCATION': 'pootlecache'|'LOCATION': '127.0.0.1:11211'|" /var/www/pootle/settings/20-backends.conf |
| 82 | | sed -i "s|# ('Your Name', 'your_email@domain.com')| ('Fran Boon', 'fran@sahanafoundation.org')|" /var/www/pootle/settings/30-site.conf |
| 83 | | sed -i "s|info@YOUR_DOMAIN.com|pootle@sahanafoundation.org|" /var/www/pootle/settings/30-site.conf |
| 84 | | |
| 85 | | pootle --config=/var/www/pootle/settings/20-backends.conf syncdb --noinput |
| 86 | | pootle --config=/var/www/pootle/settings/20-backends.conf initdb |
| 87 | | |
| 88 | | cat << EOF > "/var/www/pootle/wsgi.py" |
| 89 | | import os, site |
| 90 | | site.addsitedir('/var/www/pootle/apps') |
| 91 | | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pootle.settings") |
| 92 | | from django.core.wsgi import get_wsgi_application |
| 93 | | application = get_wsgi_application() |
| 94 | | EOF |
| 95 | | |
| 96 | | cat << EOF > "/etc/apache2/sites-available/pootle" |
| 97 | | WSGIScriptAlias / /var/www/pootle/wsgi.py |
| 98 | | WSGIDaemonProcess pootle processes=2 threads=3 stack-size=1048576 maximum-requests=5000 inactivity-timeout=900 display-name=%{GROUP} |
| 99 | | WSGIProcessGroup pootle |
| 100 | | Alias /assets /var/www/pootle/assets |
| 101 | | <Directory /var/www/pootle/assets> |
| 102 | | Order deny,allow |
| 103 | | Allow from all |
| 104 | | </Directory> |
| 105 | | Alias /export /var/www/pootle/po |
| 106 | | <Directory /var/www/pootle/po> |
| 107 | | Order deny,allow |
| 108 | | Allow from all |
| 109 | | </Directory> |
| 110 | | EOF |
| 111 | | |
| 112 | | a2ensite pootle |
| 113 | | /etc/init.d/apache2 restart |
| | 56 | su pootle |
| | 57 | cd |
| | 58 | virtualenv env |
| | 59 | source env/bin/activate |
| | 60 | pip install --upgrade pip setuptools |
| | 61 | pip install psycopg2 |
| | 62 | pip install Pootle |
| | 63 | pip install django-appconf==1.0.3 |
| | 64 | pip install redis==2.10.6 |
| | 65 | pootle init |
| | 66 | # Copy to server: /home/pootle/env/pootle.conf |
| | 67 | chown pootle /home/pootle/env/pootle.conf |
| | 68 | mkdir -p /home/pootle/translations/eden |
| | 69 | chown --recursive /home/pootle/translations |
| | 70 | # Extract templates.pot using --pot in s3translate.py |
| | 71 | # Copy to server: /home/pootle/translations/eden/templates.pot |
| | 72 | pootle rqworker & |
| | 73 | pootle migrate |
| | 74 | pootle initdb |
| | 75 | pootle createsuperuser |
| | 76 | pootle verify_user admin |
| | 77 | # Copy to server: /etc/init.d/rqworker |
| | 78 | chmod 755 /etc/init.d/rqworker |
| | 79 | /etc/init.d/rqworker defaults |
| | 80 | reboot |