WebFaction
Community site: login faq

Good afternoon everybody.

The goal of this post is to make a system with the next specifications and later publish here the updated tutorial step by step. I'm missing something from the new docs I cannot get, so I ask for help.

  • Virtual environment in the app folder (python3.4 -m venv ~/webapps/app)
  • Django 1.6.6
  • Python 3.4
  • Celery 3.1
  • RabbitMQ 3.3.5
  • Flower

There are many tutorials a bit old around there, in python 2.7 or Celery < 3.0 with djcelery, etc. Also many posts in this forum still waiting for reply.

I published today a project for a revenue of $15 in a known freelancer's website. As this is an open cooperative community I will not offer it here, but a donation to any ONG you want. If in this case the community cannot offer the solution, I will share the one I get from the other side in this post.

This profile has been opened for this purpouse, ask me for the account details if necessary.

After we do it, I will publish the step by step guide for public future references here.

Thanks


PD

Anyone who doesn't care about the security and keep his system updated, there are very good tutorials I list here just for reference:

1 - September 29, 2011 A bit old, Rabbit 2.6.1 and Celery 2.x, but is an essencial reference out there.

2 - June 16, 2013 This is an updated from the previous one, in fact make references to go from one to other. Rabbit 3.1

3 - April 24, 2014 Really good and updated with Celery 3.1, but is not fully step by step and use Redis.

4 - Updated Official Celery 3.1 + Django guide, first steps.

asked 27 Aug '14, 11:10

davidvld
41116
accept rate: 0%

I'm not sure I follow you here. Exactly what sort of help are you looking for? Are you asking how to install all of the above?

(27 Aug '14, 16:03) seanf

Hello Sean I read it again and you are right, I didn't explain myself properly. Everything is already installed, and I have no problems using the old software. For the new ones, I will publish here the steps one by one tomorrow, and in this way someone will be able to tell which one is the step I'm falling at. I'm thinking about making some other general stuffs for publishing like connecting to git, etc. Suggestions are accepted.

(27 Aug '14, 16:19) davidvld

Part 1 - Virtual environment

This part of the tutorial has been possible thanks to Michal Karzynski. If you want to follow his tutorial for Python 2.7 check his amazing tutorial here.

I suppose you already have a Webfaction account and you can loggin in your control panel.

In this part we are going to create a working virtual environment with Python 3.4 and configure our httpd.conf file.

Point 1. Create the next app in the Webfaction's control panel, Screenshot. Once created, go in again and remember the port number because we will need it in the point 9 Screenshot.

    a) App name: test_app
    b) App category: mod_wsgi
    c) App type: "mod_wsgi 3.5/Python 3.4"

Point 2. Add the app to a website, and call it test_website. I will use the one provided for free by Webfaction (username.webfactional.com) In my case davidvld.webfactional.com. Screenshot

Point 3. Connect by SSH to your server. I use putty client, step 1, step 2. Data you need: a) Username: In my case davidvld b) Password: If you don't know it, check this Screenshot. c) Server's address: If you don't know it, check this Screenshot.

Point 4. Create your vitual environment with Python 3.4. Remember that this version already has his own module, so you don't need to download virtualenv:

SSH console:

cd ~/webapps/test_app
python3.4 -m venv .
source bin/activate

Point 5. Now you are inside your vitual environtment, check if in your console you can see something like (test_app) [username@web461 test_app]$ instead of [username@web461 test_app]$. To activate or desactivate your virtual environtment, you can use source ~/webapps/test_app/bin/activate and deactivate Screenshot

Point 6. From inside your vitual environtment, install the latest django (in my case 1.6.6) and make a project called test_django:

SSH console:

pip install django
django-admin.py --version
django-admin.py startproject test_django

Point 7. Now let's configure Apache. For this you will need an SFTP conexion. I will use FireFTP from Firefox, but there are many other alternatives. Once you have FireFTP working, you will need the same data as in point 3, and choose SFTP conexion and Port 22: Screenshot 1, Screenshot 2.

Point 8. Go to /home/username/webapps/test_app/apache2/conf , in my case /home/davidvld/webapps/test_app/apache2/conf Screenshot. Make a backup of your file httpd.conf and call it httpd_backup.conf. you also can do this from your SSH console with the next order:

cp ~/webapps/test_app/apache2/conf/httpd.conf ~/webapps/test_app/apache2/conf/httpd_backup.conf

Point 9. Now you have to replace the content from your httpd.conf with the next template, but making sure you put your own data (Username, port number from point 1, app's name, django's project and if you are not using Python 3.4, your own version). Download 1, Download 2, Download 3. Clean Screenshot, Screenshot with data you need to customize.

Point 10. At this point, let's make sure everything is working. Go out from your virtualenv (deactivate) and run . ~/webapps/test_app/apache2/bin/restart Screenshot. Now, visit your website to test if it appears Django's welcome message. Screenshot

Point 11. Configure Media and Static to serve files. As the final step, we create both folders from our SSH console, configure settings.py, collect static files and create 2 symbolic links:

SSH console:

mkdir ~/webapps/test_app/media
mkdir ~/webapps/test_app/static

/home/davidvld/webapps/test_app/test_django/test_django/settings.py:

MEDIA_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../media/').replace('\\','/'))
STATIC_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '../../static/').replace('\\','/'))

Collect static files from our virtual environment

source ~/webapps/test_app/bin/activate
python manage.py collectstatic

Create 2 Apps for our Symbolic links from our Webfaction's control panel, Screenshot test app media:

Name: test_app_media
Category: Symbolic link
Type: Symbolic link to static-only app

Name: test_app_static
Category: Symbolic link
Type: Symbolic link to static-only app

If you have any question, some point is not clear or it fails, please feel free to contact me.

Thanks for your support.

permanent link

answered 28 Aug '14, 04:15

davidvld
41116
accept rate: 0%

edited 28 Aug '14, 05:51

First, some preparatory steps:

mkdir -p ~/lib/python3.4 ~/tmp ~/src ~/rabbitm
export TMPDIR=~/tmp

Create a "mod_wsgi 3.4/Python 3.4" application in the control panel and assign it to a site.

Create a 'custom app listening on port' application in the control panel to reserver a port for epmd.

Create a 'custom app listening on port' application in the control panel to reserver a port for RabbitMQ.

Create a Python 3.4 virtual environment in the app directory:

python3.4 -m venv ~/webapps/app_name

Activate the virtualenv:

cd ~/webapps/app_name
source bin/activate

Install Django, Celery, and Flower:

pip install django==1.6.6 celery==3.1 flower django-celery

Create your Django project:

django-admin.py startproject myproject

Configure Apache to serve your project - edit `~/webapps/app_name/apache2/conf/httpd.conf

# add this above WSGIDaemonProcess
WSGIPythonHome /home/username/webapps/app_name

# Delete the entire <Directory> block and add this at the end:
WSGIScriptAlias / /home/username/webapps/app_name/myproject/myproject/wsgi.py

Restart your Apache:

~/webapps/app_name/apache2/bin/restart

Install Erlang and run epmd:

cd ~/src
wget http://www.erlang.org/download/otp_src_17.1.tar.gz
tar zxf otp_src_17.1.tar.gz
cd otp_src_17.1
./configure --prefix=$HOME
make
make install
epmd -port 54321 -daemon

Install RabbitMQ:

cd ~/src
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.5/rabbitmq-server-generic-unix-3.3.5.tar.gz
tar zxf rabbitmq-server-generic-unix-3.3.5.tar.gz
ln -s $PWD/rabbitmq_server-3.3.5 ~/lib/erlang/lib/
mkdir ~/logs/user/rabbitmq

Set CONFIG_FILE, LOG_BASE, and MNESIA_BASE in ~/src/rabbitmq_server-3.3.5/sbin/rabbitmq-defaults (replace username with your username)

CONFIG_FILE=/home/testweb461/rabbitmq/rabbitmq_server-3.3.5/sbin/
LOG_BASE=/home/testweb461/logs/user/rabbitmq
MNESIA_BASE=/home/testweb461/rabbitmq/rabbitmq_server-3.3.5/sbin/

Set your epmd and RabbitMQ ports at end of ~/src/rabbitmq_server-3.3.5/sbin/rabbitmq-env:

export ERL_EPMD_PORT=54321
export RABBITMQ_NODE_PORT=54322
export ERL_INETRC=$HOME/.erl_inetrc

Create ~/hosts with the following contents (replace webNNN with your server hostname):

127.0.0.1 localhost.localdomain localhost
::1      localhost6.localdomain6 localhost6
127.0.0.1 webNNN webNNN.webfaction.com

Create ~/.erl_inetrc with the following contents (replace username with your username):

{hosts_file, "/home/username/hosts"}.
{lookup, [file,native]}

Configure your Django project to use Celery as described in the official docs:

http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

Install supervisor with easy_install configure as outlined in the docs,

http://supervisord.org/installing.html
http://supervisord.org/running.html

Install Flower with pip and configure,

https://pypi.python.org/pypi/flower
http://flower.readthedocs.org/
permanent link

answered 30 Aug '14, 01:11

johns
5.3k212
accept rate: 23%

when I try python2.7 -m venv . I get /usr/local/bin/python2.7: No module named venv I've tried it with and without the dot incase it was a typo

(10 Nov '15, 08:13) six_wars

The venv module was introduced with the python 3.3 release. You need to use a python interpreter of that version or newer. For 2.7 you will need to use virtualenv.

(10 Nov '15, 12:55) iliasr ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×906
×55
×21
×12

question asked: 27 Aug '14, 11:10

question was seen: 14,627 times

last updated: 10 Nov '15, 12:55

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM