Let's Encrypt on website setup with easy install script

Hi,
I have finally managed to setup the site using the Easy Install script ‘python install.py --production --user frappe’

Now I want to secure it with https using Let’s Encrypt. I tried following Setting up TLS SSL certificates Let's Encrypt for ERPNext sites · frappe/erpnext Wiki · GitHub but trying to turn on DNS Mulitenant gives the following error:

frappe@21n-erpnext-singapore:~$ bench config dns_multitenant on
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in ca ll
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in inv oke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in inv oke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invo ke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invo ke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/config.py”, line 46, in config_dns_mu ltitenant
update_config({‘dns_multitenant’: state})
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 47, in upd ate_config
put_config(config, bench_path=bench_path)
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 41, in put _config
with open(config_path, ‘w’) as f:
IOError: [Errno 2] No such file or directory: ‘./sites/common_site_config.json’

If I were to guess, it looks like you haven’t installed a site yet.
bench new-site --site adityas.com ← pro tip: so much easier to include the domain extension at this point, especially for Let’s Encrypt.

As a person who puts up and tears down local and remote Frappe sites all the time, I use a command like this for my sites. I’ll substitute the .local for .com if it’s on my local development machine or getting installed to remote server.

bench new-site agritheory.local --db-name agritheory --mariadb-root-username root --mariadb-root-password adityas'password --verbose --force

What you don’t need in your life is a singe instance of anything called site1.local. A customer of mine used this and I installed the wrong (development) database to a live (production) site for about 30 seconds. I survived the heart attack, thanks for asking.

Well site1.local happens automatically when I run the easy install script - ‘python install.py --production --user frappe’…

Apologies in advance if this sounds stupid, but does what you said mean that the only way for me to get let’s encrypt to work is to do a manual install?

No, not stupid. I missed that you were doing easy install. You should run the appropriate command based on the one I gave above.
Then bench use adityas.com ← where adityas.com is the name of your new site
You can then run Let’s Encrypt.
My (general) complaint about about site1.local is that it invites a lot of confusion because its a default.
Since you have already done the easy install, you don’t have the option of passing install.py any of the optional arguments. If one types python install.py --help it gets you this useful bit:

optional arguments:
  -h, --help            show this help message and exit
  --develop             Install developer setup
  --production          Setup Production environment for bench
  --site SITE           Specifiy name for your first ERPNext site
  --without-site
  --verbose             Run the script in verbose mode
  --user USER           Install frappe-bench for this user
  --bench-branch BENCH_BRANCH
                        Clone a particular branch of bench repository
  --repo-url REPO_URL   Clone bench from the given url
  --frappe-repo-url FRAPPE_REPO_URL
                        Clone frappe from the given url
  --frappe-branch FRAPPE_BRANCH
                        Clone a particular branch of frappe
  --erpnext-repo-url ERPNEXT_REPO_URL
                        Clone erpnext from the given url
  --erpnext-branch ERPNEXT_BRANCH
                        Clone a particular branch of erpnext
  --overwrite           Whether to overwrite an existing bench
  --mysql-root-password MYSQL_ROOT_PASSWORD
                        Set mysql root password
  --admin-password ADMIN_PASSWORD
                        Set admin password
  --bench-name BENCH_NAME
                        Create bench with specified name. Default name is
                        frappe-bench

I also recommend naming your bench to something meaningful; I have one installed locally for each of my customers (they’re all on different versions at different times) or if you want to do some testing between Master and Develop or a clean python 2/3 comparison… There is some additional settings required that are available with a search on the forum.

1 Like

Thanks! That cleared up a lot for me. I think I’ll run the install.py script again with additional parameters to name the site based on my domain. Since it’s a fresh install it’ll only take me a few minutes to spin up a new droplet and do it. Appreciate the help!

You got it. What is best practices for some cases is not for others, and it would be easy for the documentation (especially a quickstart or easy install) to get overwhelmingly dense very fast. To see what I mean, try typing git add --help sometime. Git’s inline help is terribly overwhelming. I think Frappe’s CLI help is very good with a few places where there could be some more details provided.

No need to reinstall just mv site1.local your_site_name and then try this command
bench setup nginx
sudo service nginx reload

2 Likes

Perfect solution
Thanks a lot