Changes between Version 26 and Version 27 of SysAdmin/Pootle


Ignore:
Timestamp:
04/04/20 21:22:07 (5 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SysAdmin/Pootle

    v26 v27  
    55
    66== Installation ==
    7 http://docs.translatehouse.org/projects/pootle/en/stable-2.5.0/server/installation.html
     7http://docs.translatehouse.org/projects/pootle/en/stable-2.8.x/server/installation.html
    88
    9 Assuming a base Debian stable (6.x):
     9Assuming a base Debian stable (10.x) - Python 2.7 as default:
    1010{{{
    1111apt-get update
    1212apt-get upgrade -y
    13 apt-get install -y bzip2 less lrzsz unzip
    14 apt-get install -y libapache2-mod-wsgi
    15 apt-get install -y mysql-server python-mysqldb phpmyadmin mytop
    16 apt-get install -y isocodes python-setuptools python-dev gcc
    17 apt-get install -y exim4-config exim4-daemon-light
     13apt-get install -y exim4
    1814dpkg-reconfigure exim4-config
    1915
    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 ..
     16apt-get install -y build-essential libxml2-dev libxslt-dev python-dev python-pip zlib1g-dev
     17apt-get install -y nginx python-certbot-nginx
     18certbot --nginx -n --agree-tos --email webmaster@sahanafoundation.org -d pootle.sahanafoundation.org
     19# Copy to server: /etc/nginx/sites-available/default
     20cd /tmp
     21wget https://projects.unbit.it/downloads/uwsgi-2.0.18.tar.gz
     22zxvf uwsgi-2.0.18.tar.gz
     23cd uwsgi-2.0.18
     24python uwsgiconfig.py --build pyonly
     25cp uwsgi /usr/local/bin
     26chmod 755 /usr/local/bin/uwsgi
     27# Copy to server: /etc/init.d/uwsgi-pootle
     28chmod 755 /etc/init.d/uwsgi-pootle
     29/etc/init.d/uwsgi-pootle defaults
     30apt-get -y install "postgresql-11" "pgtop"
     31cat << EOF >> "/etc/sysctl.conf"
     32## Increase Shared Memory available for PostgreSQL
     33# 1024Mb (may need more)
     34kernel.shmmax = 552992768
     35kernel.shmall = 2097152
     36EOF
     37sysctl -w kernel.shmmax=552992768 # For 1024 MB RAM
     38sysctl -w kernel.shmall=2097152
     39sed -i 's|#track_counts = on|track_counts = on|' /etc/postgresql/11/main/postgresql.conf
     40sed -i 's|#autovacuum = on|autovacuum = on|' /etc/postgresql/11/main/postgresql.conf
     41sed -i 's|max_connections = 100|max_connections = 20|' /etc/postgresql/11/main/postgresql.conf
     42# 1024Mb RAM: (e.g. t2.micro)
     43sed -i 's|#effective_cache_size = 4GB|effective_cache_size = 512MB|' /etc/postgresql/11/main/postgresql.conf
     44sed -i 's|#work_mem = 4MB|work_mem = 8MB|' /etc/postgresql/11/main/postgresql.conf
     45service postgresql restart
    2546
    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
     47su postgres
     48createuser -P pootle
     49createdb --encoding='utf8' --locale=en_US.utf8 --template=template0 --owner=pootle pootledb
     50exit
     51apt-get install -y redis-server
     52adduser pootle
     53# Copy to server: /home/pootle/uwsgi.ini
     54# Copy to server: /home/pootle/wsgihandler.py
    5455pip install virtualenv
    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
     56su pootle
     57cd
     58virtualenv env
     59source env/bin/activate
     60pip install --upgrade pip setuptools
     61pip install psycopg2
     62pip install Pootle
     63pip install django-appconf==1.0.3
     64pip install redis==2.10.6
     65pootle init
     66# Copy to server: /home/pootle/env/pootle.conf
     67chown pootle /home/pootle/env/pootle.conf
     68mkdir -p /home/pootle/translations/eden
     69chown --recursive /home/pootle/translations
     70# Extract templates.pot using --pot in s3translate.py
     71# Copy to server: /home/pootle/translations/eden/templates.pot
     72pootle rqworker &
     73pootle migrate
     74pootle initdb
     75pootle createsuperuser
     76pootle verify_user admin
     77# Copy to server: /etc/init.d/rqworker
     78chmod 755 /etc/init.d/rqworker
     79/etc/init.d/rqworker defaults
     80reboot
    11481}}}
    11582== Usage ==