|
@@ -0,0 +1,129 @@
|
|
|
+# Production-configured Wagtail installation
|
|
|
+# (secure services/account for full production use).
|
|
|
+# Tested on Debian 7.0.
|
|
|
+# Tom Dyson and Neal Todd
|
|
|
+
|
|
|
+# NB: Ensure the system locale is okay before running (dpkg-reconfigure locales).
|
|
|
+
|
|
|
+PROJECT=mywagtail
|
|
|
+PROJECT_ROOT=/usr/local/django
|
|
|
+
|
|
|
+echo "This script overwrites key files, and should only be run on a new box."
|
|
|
+read -p "Type 'yes' to confirm: " CONFIRM
|
|
|
+[ “$CONFIRM” == “yes” ] || exit
|
|
|
+
|
|
|
+read -p "Enter a name for your project [$PROJECT]: " U_PROJECT
|
|
|
+if [ ! -z "$U_PROJECT" ]; then
|
|
|
+ PROJECT=$U_PROJECT
|
|
|
+fi
|
|
|
+
|
|
|
+read -p "Enter the root of your project, without trailing slash [$PROJECT_ROOT]: " U_PROJECT_ROOT
|
|
|
+if [ ! -z "$U_PROJECT_ROOT" ]; then
|
|
|
+ PROJECT_ROOT=$U_PROJECT_ROOT
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -z "$PROJECT_ROOT" ]; then
|
|
|
+ mkdir -p $PROJECT_ROOT || exit
|
|
|
+fi
|
|
|
+
|
|
|
+echo -e "\nPlease come back in a few minutes, when we'll need you to create an admin account."
|
|
|
+sleep 5
|
|
|
+
|
|
|
+SERVER_IP=`ifconfig eth0 |grep "inet addr" | cut -d: -f2 | cut -d" " -f1`
|
|
|
+
|
|
|
+aptitude update
|
|
|
+aptitude -y install git python-pip nginx postgresql redis-server
|
|
|
+aptitude -y install postgresql-server-dev-all python-dev libxml2-dev libxslt-dev libjpeg62-dev
|
|
|
+
|
|
|
+wget -nv http://nodejs.org/dist/v0.10.20/node-v0.10.20.tar.gz
|
|
|
+tar xzf node-v0.10.20.tar.gz
|
|
|
+cd node-v0.10.20
|
|
|
+./configure && make -s && make -s install
|
|
|
+cd ..
|
|
|
+rm -r node-v0.10.20 node-v0.10.20.tar.gz
|
|
|
+npm install -g less
|
|
|
+
|
|
|
+perl -pi -e "s/^(local\s+all\s+postgres\s+)peer$/\1trust/" /etc/postgresql/9.1/main/pg_hba.conf
|
|
|
+service postgresql reload
|
|
|
+
|
|
|
+aptitude -y install openjdk-7-jre-headless
|
|
|
+curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.0.deb
|
|
|
+dpkg -i elasticsearch-1.0.0.deb
|
|
|
+rm elasticsearch-1.0.0.deb
|
|
|
+update-rc.d elasticsearch defaults 95 10
|
|
|
+service elasticsearch start
|
|
|
+
|
|
|
+cd $PROJECT_ROOT
|
|
|
+git clone https://github.com/torchbox/wagtaildemo.git $PROJECT
|
|
|
+cd $PROJECT
|
|
|
+mv wagtaildemo $PROJECT
|
|
|
+perl -pi -e"s/wagtaildemo/$PROJECT/" manage.py $PROJECT/wsgi.py $PROJECT/settings/*.py
|
|
|
+rm -r etc README.md Vagrantfile* .git .gitignore
|
|
|
+
|
|
|
+dd if=/dev/zero of=/tmpswap bs=1024 count=524288
|
|
|
+mkswap /tmpswap
|
|
|
+swapon /tmpswap
|
|
|
+pip install -r requirements/production.txt
|
|
|
+swapoff -v /tmpswap
|
|
|
+rm /tmpswap
|
|
|
+
|
|
|
+echo SECRET_KEY = \"`python -c 'import random; print "".join([random.SystemRandom().choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'`\" > $PROJECT/settings.local.py
|
|
|
+echo ALLOWED_HOSTS = [\'$SERVER_IP\',] >> $PROJECT/settings/local.py
|
|
|
+createdb -Upostgres $PROJECT
|
|
|
+./manage.py syncdb --settings=$PROJECT.settings.production
|
|
|
+./manage.py migrate --settings=$PROJECT.settings.production
|
|
|
+./manage.py update_index --settings=$PROJECT.settings.production
|
|
|
+./manage.py collectstatic --settings=$PROJECT.settings.production --noinput
|
|
|
+
|
|
|
+pip install uwsgi
|
|
|
+cp $PROJECT/wsgi.py $PROJECT/wsgi_production.py
|
|
|
+perl -pi -e"s/($PROJECT.settings)/\1.production/" $PROJECT/wsgi_production.py
|
|
|
+
|
|
|
+curl -O https://raw2.github.com/nginx/nginx/master/conf/uwsgi_params
|
|
|
+cat << EOF > /etc/nginx/sites-enabled/default
|
|
|
+upstream django {
|
|
|
+ server unix://$PROJECT_ROOT/$PROJECT/uwsgi.sock;
|
|
|
+}
|
|
|
+server {
|
|
|
+ listen 80;
|
|
|
+ charset utf-8;
|
|
|
+ client_max_body_size 75M; # max upload size
|
|
|
+ location /media {
|
|
|
+ alias $PROJECT_ROOT/$PROJECT/media;
|
|
|
+ }
|
|
|
+ location /static {
|
|
|
+ alias $PROJECT_ROOT/$PROJECT/static;
|
|
|
+ }
|
|
|
+ location / {
|
|
|
+ uwsgi_pass django;
|
|
|
+ include $PROJECT_ROOT/$PROJECT/uwsgi_params;
|
|
|
+ }
|
|
|
+}
|
|
|
+EOF
|
|
|
+
|
|
|
+cat << EOF > $PROJECT_ROOT/$PROJECT/uwsgi_conf.ini
|
|
|
+[uwsgi]
|
|
|
+chdir = $PROJECT_ROOT/$PROJECT
|
|
|
+module = $PROJECT.wsgi_production
|
|
|
+master = true
|
|
|
+processes = 10
|
|
|
+socket = $PROJECT_ROOT/$PROJECT/uwsgi.sock
|
|
|
+chmod-socket = 666
|
|
|
+vacuum = true
|
|
|
+EOF
|
|
|
+
|
|
|
+mkdir -p /etc/uwsgi/vassals/
|
|
|
+ln -s $PROJECT_ROOT/$PROJECT/uwsgi_conf.ini /etc/uwsgi/vassals/
|
|
|
+
|
|
|
+curl -o /etc/init.d/uwsgi https://gist.githubusercontent.com/nealtodd/9364691/raw/43f0bdb1304995ab73e3d22e62e14111d40d4e90/uwsgi-init.d
|
|
|
+mkdir /var/log/uwsgi
|
|
|
+chmod 755 /etc/init.d/uwsgi
|
|
|
+update-rc.d uwsgi defaults
|
|
|
+
|
|
|
+service uwsgi start
|
|
|
+service nginx restart
|
|
|
+
|
|
|
+URL="http://$SERVER_IP"
|
|
|
+echo -e "\n\nWagtail lives!\n\n"
|
|
|
+echo "The public site is at $URL/"
|
|
|
+echo "and the admin interface is at $URL/admin/"
|