Installation Error - NGINX

aafpl@aafpl:~$ sudo bash setup_frappe.sh --setup-production
Installing for Ubuntu trusty amd64
In case you encounter an error, you can post on https://discuss.frappe.io

Adding ubuntu mariadb repo
Installing packages for Ubuntu. This might take time…
Installing wkhtmltopdf
mysql stop/waiting
mysql start/running, process 2758
Adding frappe user
Installing frappe-bench
Setting up first site
Restarted supervisord

  • Restarting nginx nginx
    nginx: [emerg] “server_names_hash_bucket_size” directive is duplicate in /etc/nginx/conf.d/frappe.conf:2
    nginx: configuration file /etc/nginx/nginx.conf test failed
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 9, in
    load_entry_point(‘bench==0.0.0’, ‘console_scripts’, ‘bench’)()
    File “/home/aafpl/bench-repo/bench/cli.py”, line 60, in cli
    bench()
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
    File “/home/aafpl/bench-repo/bench/cli.py”, line 456, in setup_production
    _setup_production(user=user)
    File “/home/aafpl/bench-repo/bench/production_setup.py”, line 69, in setup_production
    restart_service(‘nginx’)
    File “/home/aafpl/bench-repo/bench/production_setup.py”, line 11, in restart_service
    exec_cmd("{service_manager} {service} restart ".format(service_manager=‘service’, service=service))
    File “/home/aafpl/bench-repo/bench/utils.py”, line 105, in exec_cmd
    raise CommandFailedError(cmd)
    bench.utils.CommandFailedError: service nginx restart

please suggest how to rectify this error.

sudo nginx -t

If there are duplicate “server_names_hash_bucket_size” in any of the nginx config files, remove it.

Check files /etc/nginx/nginx.conf and files in /etc/nginx/sites-available/* for duplicate directive.

Restart / Reload nginx

sudo service nginx restart

I have deleted the NGINX Server and Reinstalled it .
Now please tell how to put the installation file in the same.
I am getting following error.

root@aafpl:~# bench setup nginx
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.0.0’, ‘console_scripts’, ‘bench’)()
File “/home/aafpl/bench-repo/bench/cli.py”, line 60, in cli
bench()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1057, in invoke
Command.invoke(self, ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/aafpl/bench-repo/bench/cli.py”, line 151, in bench
setup_logging(bench=bench)
File “/home/aafpl/bench-repo/bench/utils.py”, line 237, in setup_logging
hdlr = logging.FileHandler(log_file)
File “/usr/lib/python2.7/logging/init.py”, line 903, in init
StreamHandler.init(self, self._open())
File “/usr/lib/python2.7/logging/init.py”, line 928, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: ‘/home/aafpl/frappe-bench/logs/bench.log’

Please revert at the earliest possible.

Don’t run bench commands as root.

Run bench commands from frappe-bench directory.

again the same error. I tried running from Frappe-bench directory

which error? duplicate directive?
Probably there is line for server_names_hash_bucket_size in /etc/nginx/nginx.conf, comment that line and restart nginx.

aafpl@aafpl:~$ cd frappe-bench
aafpl@aafpl:~/frappe-bench$ bench setup nginx
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.0.0’, ‘console_scripts’, ‘bench’)()
File “/home/aafpl/bench-repo/bench/cli.py”, line 60, in cli
bench()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1057, in invoke
Command.invoke(self, ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/home/aafpl/bench-repo/bench/cli.py”, line 151, in bench
setup_logging(bench=bench)
File “/home/aafpl/bench-repo/bench/utils.py”, line 237, in setup_logging
hdlr = logging.FileHandler(log_file)
File “/usr/lib/python2.7/logging/init.py”, line 903, in init
StreamHandler.init(self, self._open())
File “/usr/lib/python2.7/logging/init.py”, line 928, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: ‘/home/aafpl/frappe-bench/logs/bench.log’
aafpl@aafpl:~/frappe-bench$

Permission denied? I don’t know why that is happening.
you can try

sudo chown -R aafpl:aafpl ~/frappe-bench
cd ~/frappe-bench/
bench setup nginx

Or perhaps backup current frappe-bench (for sites) and initiate a new bench as non root user.

In production setup: it is not working. I am getting

~/frappe-bench$ bench restart
$ supervisorctl restart frappe:
unix:///var/run/supervisor.sock no such file```