Unable to deploy Mezzanine on Digital ocean.

199 views
Skip to first unread message

code...@gmail.com

unread,
Mar 25, 2016, 4:07:35 AM3/25/16
to Mezzanine Users
Hello there!

Trying to deploy Mezzanine on digital ocean since last 2 days, googled most of the tutorial available. But unfortunately, nothing worked. Currently, I've few Mezzanine sites running on Python anywhere. Since last few month Python anywhere performance is not upto mark thus migrating to digital ocean.

Tested with inbuilt Fabric configuration and official Mezzanine documentation, but it gives an error. Now, I'm trying to configure manually with uwsgi and nginx. Sometime, it gives "Internal server error", sometime "Bad gateway" and sometime nothing :)

My configuration files are like this:
---------------
/etc/uwsgi/sites/codenjump.ini
---------------
[uwsgi]
socket = /home/developer/codenjump/codenjump.sock
virtualenv = /home/developer/Env/codenjump
chdir = /home/developer/codenjump
wsgi-file = /home/developer/codenjump/codenjump/wsgi.py
pythonpath = ..
env = DJANGO_SETTINGS_MODULE=codenjump.settings
master = true
processes = 5
workder = 3
chmod-socket = 666
enable-threads = true

--------------------------
/etc/init/uwsgi.conf
------------------------
description "uWSGI application server in Emperor mode"

start on runlevel [2345]
stop on runlevel [!2345]

setuid developer
setgid www-data

exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites

-------------------
/etc/nginx/sites-available/codenjump
-------------------
server {
    listen 80;
    server_name ip_address;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/developer/codenjump;
    }

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/home/user/developer/codenjump/codenjump.sock;
    }
}

------------------------------

Few other points:
-- When i start uwsgi service, socket file is not getting generated. Checked folder permission.
-- Tried with gunicorn also. No luck. I'm open to deploy with gunicorn or uwsgi or other.

Appreciate any help. Thank you.

Sri

code...@gmail.com

unread,
Mar 25, 2016, 4:59:16 AM3/25/16
to Mezzanine Users
Hello there!

I did it :)
Culprit was some typo error in config file. Thank you.

Sri

AdamS

unread,
Mar 25, 2016, 8:31:34 PM3/25/16
to Mezzanine Users
Great job - my site is on digital ocean too - had to put together pieces from four tutorials to get it running!

Eduardo Rivas

unread,
Mar 25, 2016, 8:49:55 PM3/25/16
to mezzani...@googlegroups.com
Hey Adam, Sri.

I helped build the current deployment mechanism, and am curious about
your experience with it. Specifically, I would like to hear what would
you like to see in a definitive tutorial, or what we can do to
streamline the process.

Looking forward to your comments.

AdamS

unread,
Mar 25, 2016, 9:10:12 PM3/25/16
to Mezzanine Users

Hey Eduardo,

I should have taken more notes but my recollection is as follows:

Bad things with respect to digital ocean:

- the "one click" django ubuntu image install did not work for me at all.
- the django ubuntu digital ocean tutorial did not help with the databases and was pretty unnecessary because you can skip to the mezzanine installer
- The postgres ubuntu tutorial was not so clear with respect to django; had to study the postgres site to get a handle on "roles" etc. Even then I had to do a lot of direct manipulation of roles and passwords to get the database working
- the nginx / gunicorn tutorial was only partially integrated with the above; this also required a lot of guess work, I ended up reading several other sites.

it was good for me to read the other sites but that indicates the tutorial is unclear.

Good things:
- the ssh certificate tutorial, well written
- the mezzanine installer worked very well
- pip, etc. of course

The thing I ended up doing, which I strongly recommend, is to delete the digital ocean image and start the installation over every time it doesn't work.  Trying to undo a mistake in configuration is much worse than starting from scratch. Eventually it will work.

Now that its running, I haven't touched the underlying setup, so that is excellent.

Open questions:

- I haven't segmented our site in to a production / development server yet
- The overall security tutorial is opaque though I have done most of the things it recommends

Hope this helps!

Eduardo Rivas

unread,
Mar 28, 2016, 4:54:48 PM3/28/16
to mezzani...@googlegroups.com
Thanks Adam. I see you went with Digital Ocean's tutorials. Did you try
the one in Mezzanine's docs? It should work with a completely blank
Ubuntu VPS.

http://mezzanine.jupo.org/docs/deployment.html#tutorial

The fabfile should handle not only installing the Mezzanine project, but
all system-level dependencies. The Postgres DB, gunicorn, ngnix,
memcache, and all other pieces should have been installed automatically.

Let me know your thoughts on that.

Data Intelligence

unread,
May 27, 2018, 11:10:06 AM5/27/18
to Mezzanine Users
Hey Eduardo,
I am aware your comment was years ago, but I suggest editing it because the instructions given on the mezzanine site DO NOT work, so I suggest either updating them or taking them off all together as to keep others from wasting time.
What I mean by DO NOT WORK is this:
1- Mezzanine is not compatible with python 3
2- The dependencies it supposedly automatically installs ARE NOT compatible with each other meaning:
3- Fabric that is installed is not compatible with the fabfile.py that is generated.
4- When you get done with all that and the days it takes to figure that out and you get to run
5- NOT SO FAB ALL you end up with:
6- "[localhost] local: rsync  --exclude "*.pyc" --exclude "*.pyo" --exclude "*.db" --exclude ".DS_Store" --exclude ".coverage" --exclude "local_settings.py" --exclude "/static" --exclude "/.git" --exclude "/.hg" -pthrvz  --rsh='ssh  -p 22  ' C:\Users\~\blog_iq\ us...@xxx.xx.xxx.xx:/home/user/mezzanine/blog_iq
The source and destination cannot both be remote.
rsync error: syntax or usage error (code 1) at main.c(1292) [Receiver=3.1.2]

7- So after weeks of trying I no longer have the patience for outdated instructions- SO please either update your instructions or ADD a note at the beginning listing the exact version of the dependencies and even better yet the PYTHON VERSION to begin with.

Don't you agree???

Eduardo Rivas

unread,
May 27, 2018, 5:40:26 PM5/27/18
to mezzani...@googlegroups.com

Hello there 👋🏻

I'm very sorry about all the trouble you've had with the deployment process. I know the feeling of spending days on a bug without progress. I hope you are able to deploy your site eventually.

I think the main cause of all trouble is the release of Fabric 2 just 18 days ago (https://github.com/fabric/fabric/releases/tag/2.0.0). I'm not aware of the specifics related to this release, but a major version change might indicate that many things will break if not updated. The fabfile included with Mezzanine was written for Fabric 1 and Python 2. Mezzanine itself has been compatible with Python 3 for many years now, but the default deployment process assumes Python 2.

Besides that, I don't think deploying with rsync will work on Windows since no such command exists in Windows (though I'm unaware if a port exists and if you've installed it). I also develop on Windows and deploy with git without issue.

My advice to get this sorted would be:

- Destroy and rebuild your Droplet in DO.

- Do not create a new user on the droplet, you only need the root user for the deployment process. A non-root user will be created for you if you follow the deployment tutorial. In fact you only need to SSH into your Droplet once to change the root password. You don't need to install system nor Python dependencies.

- Create a new git repository in your development machine and commit all relevant files to it. In local_settings.py change the deployment method to git.

- Install Fabric 1 with: pip install -U "fabric<2" (quotes are important when specifying versions to pip)

- Assuming you installed Mezzanine from pip, you may not have the latest version of the fabfile on your system. Go to https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/project_template/fabfile.py and replace your local fabfile with that.

- Follow the Deployment tutorial (Case 1). http://mezzanine.jupo.org/docs/deployment.html#case-1-deploying-to-a-brand-new-server

If you encounter any other issues, I'd be happy to help troubleshoot further. Please include your Mezzanine, Django, Fabric, and Python versions, as well as full tracebacks of the errors you're seeing, and the details of your droplet.

Finally, I would like to remind you Mezzanine is built and maintained by a community of volunteers. If the software is making you upset and you come here looking for help, the least you can do is assume the volunteers who wrote Mezzanine and who are going to help you out have good intentions. We are not wasting your time, we are not responsible for the changes in the tools we depend on (like Fabric), we have zero obligation to help you develop and deploy a website (yet, we will gladly do it as we've done many times in the past for others). If you've found a bug in the code or an error in the docs, report it without parading how broken or outdated things are. Thanks! :)

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Data Intelligence

unread,
May 27, 2018, 10:36:09 PM5/27/18
to Mezzanine Users
Droplet:
1- Ubuntu 16.04.4 x64
2- Changed root password and nothing else

Local Windows 10:
1- virtualenv --python=c:\Python27\python.exe blog_env
2- blog_env\Scripts\activate
3- pip install -U "fabric<2"
4-  ~pip install mezzanine  
5-  mezzanine-project blog_iq
6-  cd blog_iq
7- pip freeze > requirements.txt
8- python manage.py createdb
9- copied over fabfile.py from your link > gave me an error: Aborting: no hosts defined (will get back to this later)
10- deleted fabfile and went back to the original one
11-  Edited local_settings.py to this:

ALLOWED_HOSTS = ["blah.com"]

# These settings are used by the default fabfile.py provided.
# Check fabfile.py for defaults.

FABRIC = {
    "DEPLOY_TOOL": "git",  # Deploy with "git", "hg", or "rsync"
    "SSH_USER": "santa",  # VPS SSH username
    "HOSTS": ["xxx.xxx.xxx.xxx"],  # The IP address of your VPS
    "DOMAINS": ALLOWED_HOSTS,  # Edit domains in ALLOWED_HOSTS
    "REQUIREMENTS_PATH": "requirements.txt",  # Project's pip requirements
    "LOCALE": "en_US.UTF-8",  # Should end with ".UTF-8"
    "DB_PASS": "bingo",  # Live database password
    "ADMIN_PASS": "dingo",  # Live admin user password
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

12- Created a git repository in the same directory as my project

DEPLOYMENT:
1- fab secure (error see #9 and #10  above)
2- reverted to original fabfile.py
3- fab secure - worked - created user
4- fab deploy
ERROR:

[206.189.210.135] out:
[206.189.210.135] out:  Traceback (most recent call last):
  File "c:\~\lib\site-packages\fabric\main.py", line 757, in main
    *args, **kwargs
  File "c:\~\lib\site-packages\fabric\tasks.py", line 386, in execute
    multiprocessing
  File "c:~\lib\site-packages\fabric\tasks.py", line 276, in _execute
    return task.run(*args, **kwargs)
  File "c:\~\lib\site-packages\fabric\tasks.py", line 173, in run
    return self.wrapped(*args, **kwargs)
  File "C:\~\blog_iq\fabfile.py", line 218, in logged
    return func(*args, **kawrgs)
  File "C:~\fabfile.py", line 691, in all
    deploy()
  File "c:\~\blog_env\lib\site-packages\fabric\tasks.py", line 170, in __call__
    return self.run(*args, **kwargs)
  File "c:\~\blog_env\lib\site-packages\fabric\tasks.py", line 173, in run
    return self.wrapped(*args, **kwargs)
  File "C:\~\blog_iq\fabfile.py", line 218, in logged
    return func(*args, **kawrgs)
  File "C:\~\blog_iq\fabfile.py", line 642, in deploy
    rsync_upload()
  File "c:\Python27\Lib\contextlib.py", line 24, in __exit__
    self.gen.next()
  File "C:~\blog_iq\fabfile.py", line 160, in update_changed_requirements
    for req in new_reqs.split("\n"):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
Disconnecting from 206.189.210.135... done.

REQUIREMENTS.TXT:
asn1crypto==0.24.0
bcrypt==3.1.4
beautifulsoup4==4.6.0
bleach==2.1.3
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
cryptography==2.2.2
Django==1.10.8
django-contrib-comments==1.8.0
enum34==1.1.6
Fabric==1.14.0
filebrowser-safe==0.4.7
future==0.16.0
grappelli-safe==0.4.7
html5lib==1.0.1
idna==2.6
ipaddress==1.0.22
Mezzanine==4.2.3
oauthlib==2.1.0
paramiko==2.4.1
Pillow==5.1.0
pyasn1==0.4.3
pycparser==2.18
PyNaCl==1.2.1
pytz==2018.4
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
tzlocal==1.5.1
urllib3==1.22
webencodings==0.5.1

Melvyn Sopacua

unread,
May 28, 2018, 4:27:08 PM5/28/18
to mezzani...@googlegroups.com
I do not for the life of me understand why people develop on Windows. It's
only complicating things and there's no upside.

In other words:

> File "C:~\blog_iq\fabfile.py", line 160, in update_changed_requirements
> for req in new_reqs.split("\n"):
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0:

Remove the Byte Order Marks from all your files.
--
Melvyn Sopacua

Scott Lee

unread,
Jun 13, 2018, 5:28:13 PM6/13/18
to Mezzanine Users
Hi Eduardo, 

Thank you for the detailed instruction, its awesome, I have managed to get the basic Mezzanine up and running in my Digitalocean droplet, however, I am unable to use Theme, as soon as I enable the Theme (in this case, its the Solid theme), I am getting "Internal Server Error". 

Are you able to see why and how to fix it ? 

Cheers,
Scott 

Eduardo Rivas

unread,
Jun 15, 2018, 1:08:19 AM6/15/18
to mezzani...@googlegroups.com

Hi Scott.

 

To debug a production site, I recommend you enable email error reporting. This will deliver an email with a complete traceback whenever a 500 error occurs in your server. The instructions are here: https://groups.google.com/d/msg/mezzanine-users/x4rV1JckP2I/2EyJak17BQAJ

Eduardo Rivas

unread,
Jun 15, 2018, 1:21:33 AM6/15/18
to Mezzanine Users
Can you try again now that Mezzanine 4.3 has been released? You'll need to apply the changes to settings.py, local_settings.py, and fabfile.py (you can copy them from the repo, or from a blank project created with 4.3). Also, make sure you change your FABRIC settings in local_settings.py before executing any of the Fabric tasks.
Reply all
Reply to author
Forward
0 new messages