The Perfect SpamSnake - Ubuntu 12.04 - Nginx, uWSGI & Baruwa

Discussion in 'HOWTO-Related Questions' started by Eike, Dec 3, 2012.

  1. Eike

    Eike New Member

    Hey guys,

    first of all I'm still "learning" and got stuck on this great howto. I did it a few years ago with Ubuntu 8.04 and the server still works well. Now I am trying to put a new version on a new server with Ubuntu 12.04.
    Most of the 10.10-howto still works good but I am having problems with the installation of Nginx, uWSGI & Baruwa. The biggest problem ist that there are no Packages for 12.04 on https://launchpad.net/~chris-lea/+archive/uwsgi. I tried using the Ubuntu repository, but then folders like /etc/uwsgi/uwsgi-python2.6/ are missing because there is no uwsgi-python2.6 on 12.04.
    I would even install more from the repository, but when I install Baruwa, it doesn't find Mailscanner, needs to install/replace it and crashes because it cannot remove the folders. When I even install Mailscanner (from the Baruwa repo) with Aptitude the folders completely differ from the howto.
    Can anyone help me, especially with uWSGI? Or is it easy to use Apache, instead of nginx?

    Thanks a lot & best regards
    Eike
     
  2. Rocky

    Rocky Member

    What errors do you get with uwsgi and nginx?
     
  3. Eike

    Eike New Member

    There is no Precise-/Quantal-.deb for uWSGI on Chris Lea's Launchpad and when I install nginx and uWSGI with Aptitude I need Python 2.7, instead of 2.6. The folder /etc/uwsgi/uwsgi-python2.6/ doesn't exist and currently my Linux skills are (by far...) not good enough to find the solution...

    Is it difficult to use Apache, instead of nginx? Or would it end up in a mess when I try to install Mailscanner, Baruwa and Apache with Aptitude?
     
  4. Rocky

    Rocky Member

    Try This

    Let me know if the following steps are successful:

    apt-get install nginx uwsgi uwsgi-extra uwsgi-plugin-python

    vi /etc/nginx/sites-available/baruwa.conf

    [uwsgi]
    workers = 2
    chdir = /usr/share/pyshared/baruwa
    env = DJANGO_SETTINGS_MODULE=baruwa.settings
    module = django.core.handlers.wsgi:WSGIHandler()

    vi /etc/uwsgi/apps-available/baruwa.ini

    server {
    server_name spamsnake.mcrirents.com;
    access_log /var/log/nginx/access.log;
    location / {
    uwsgi_pass unix:///var/run/uwsgi/app/baruwa/socket;
    include uwsgi_params;
    }
    }

    Create symlinks
    rm -r /etc/nginx/sites-enabled/default
    cp /usr/share/doc/uwsgi-extra/nginx/uwsgi_params /etc/nginx/
    ln -s /etc/nginx/sites-available/baruwa.conf /etc/nginx/sites-enabled/baruwa.conf
    ln -s /etc/uwsgi/apps-available/baruwa.ini /etc/uwsgi/apps-enabled/baruwa.ini

    Restart both nginx and uwsgi
    /etc/init.d/nginx restart && /etc/init.d/uwsgi restart
     
    Last edited: Dec 7, 2012
  5. Eike

    Eike New Member

    Hey Rocky,
    thanks for answering. Sorry, I had not much time in the last few days.

    I've changed the files and commented out the content of /etc/nginx/sites-available/baruwa.conf.
    But when I restart nginx and uwsgi I get this:

    Code:
    Restarting nginx: nginx: [emerg] unknown directive "[uwsgi]" in /etc/nginx/sites-enabled/baruwa.conf:25
    nginx: configuration file /etc/nginx/nginx.conf test failed
    Do you know what I did wrong?
     
  6. falko

    falko Super Moderator Howtoforge Staff

    Can you post your /etc/nginx/sites-enabled/baruwa.conf file?
     
  7. lctn

    lctn New Member

    nginx failes on restart

    I see others are having similar issues. Any help is appreciated with this problem:

    I had to install baruwa via apt, since the file in the tutorial could not be found. Maybe that caused the issue. I see it also installed apache2, but not sure if that causes a problem.



    /etc/init.d/uwsgi restart && /etc/init.d/nginx restart
    * Restarting app server(s) uwsgi [ OK ]
    Restarting nginx: nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/baruwa.conf:7
    nginx: configuration file /etc/nginx/nginx.conf test failed



    /etc/nginx/sites-enabled/baruwa.conf
    [uwsgi]
    workers = 2
    chdir = /usr/share/pyshared/baruwa
    env = DJANGO_SETTINGS_MODULE=baruwa.settings
    module = django.core.handlers.wsgi:WSGIHandler()

    /etc/uwsgi/apps-available/baruwa.ini:

    server_name relay-2.lctn.org;
    root /usr/share/pyshared/baruwa;
    autoindex on;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location /static {
    root /usr/share/pyshared/baruwa/static/;
    }

    # static resources
    location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
    {
    expires 30d;
    break;
    }

    location / {
    uwsgi_pass unix:///var/run/uwsgi/app/baruwa/socket;
    include uwsgi_params;
    }
    }
     
  8. Rocky

    Rocky Member

    Hey,

    Unfortunately, you have to use my sn package for the install. I've removed a few things from the binary from my custom setup, so that's why you're having issues. I've updated the link, let me know if it works. Google is not really document friendly anymore and I don't have a storage for it.

    Rocky
     
  9. JhonKa

    JhonKa New Member


    Rocky,

    I used your SN package for the install and I'm getting this same error.
     
  10. flashingcurser

    flashingcurser New Member

    The config file and ini file for uwsgi are mixed up in the tutorial. Swap the info between and you'll be golden.
     
  11. Rocky

    Rocky Member

    Good catch. I must have mixed it up somehow.
     
  12. JhonKa

    JhonKa New Member

    That did it for me! Wow you guys are great! I spent hours trying to figure out what was wrong, I guess I learned quite a bit out of the whole ordeal. Thanks again, I can't thank you enough!
     
  13. lctn

    lctn New Member

    postfix.sh errors

    I am getting the following errors when running postfix.sh. It keeps the script from finishing, unless I comment spf info out.


    root@relay-1:/etc/postfix# /usr/src/postfix.sh
    postconf: warning: ???e: unknown parameter
    postconf: warning: policy-spf_time_limit = 3600s: unknown parameter
    postconf: fatal: -e or -# accepts no comment input


    FYI: There is a typo with instructions on installing baruwa.

    Had to change it to the following to get it to work:

    mv uc?id=0B9cN15Q3pKnwLW1WNG9rN0dQNzg baruwa_1.1.2-4sn_all.deb
    mv uc?id=0B9cN15Q3pKnwMHFUMFhWMW4ycU0 baruwa-doc_1.1.2-4sn_all.deb
     
  14. Rocky

    Rocky Member

    Hi,

    Try retyping the spf section within your ssh session and see if that fixes it. Sometimes copy and paste could cause some issues.
     
  15. lctn

    lctn New Member

    No MailScanner found running; none killed.

    I did the complete install according to the tutorial many times now, because of problems of getting it to work. This time I snapshot my vm at different stages. Reverting to the snapshot just after installing MailScanner, I get the following when starting or stopping it:

    No MailScanner found running; none killed.

    I also get the following in syslog:

    Cannot write pid file /opt/MailScanner/var/MailScanner.pid, Permission denied


    I am not sure if it is related, but with the full install, Baruwa does not log messages, even though the database settings are correct and celeryd often does not start. Could be those are different issues altogether.
     
  16. lctn

    lctn New Member

    Follow up

    Back tracking to find the problem and see this wget request is not working:

    wget http http://launchpadlibrarian.net/85191561/libdigest-sha1-perl_2.13-2build2_$(uname -m | sed -e 's/x86_64/amd64/' -e 's/i686/i386/').deb && dpkg -i libdigest-sha1-perl_2.13-2build2_$(uname -m | sed -e 's/x86_64/amd64/' -e 's/i686/i386/').deb

    Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.229|:80... connected.
    HTTP request sent, awaiting response... 404 Not Found
    2013-01-08 21:50:03 ERROR 404: Not Found
     

Share This Page