jonatansalemes / nginx-admin

Nginx admin is an open source multiplatform manager for nginx software to easy administration
Other
378 stars 142 forks source link

Nginx configuration file syntax is not ok : sudo: sorry, you must have a tty to run sudo #17

Closed shuangxi588 closed 6 years ago

shuangxi588 commented 6 years ago

I already added user nginx-agent in sudoers file.

1.

tail -n 1 /etc/sudoers

nginx-agent ALL=(ALL) NOPASSWD:/usr/sbin/nginx,/usr/bin/pgrep nginx,/usr/bin/killall nginx

2.

su - nginx-agent

Last login: Mon Feb 26 14:30:45 CST 2018 on pts/3 su: warning: cannot change directory to /home/nginx-agent: No such file or directory -bash-4.2$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful -bash-4.2$ exit

shuangxi588 commented 6 years ago

image

riclava commented 6 years ago

use visudo and comment "Default requiretty" may help you ;-)

shuangxi588 commented 6 years ago

Thanks. image

shuangxi588 commented 6 years ago

Thanks for your help, but I still have two questions.

  1. can i change database use maridb instead of mysql.
  2. i want to use the default nginx directory "/etc/nginx" instead of nginx-agent directory "/opt/nginx-agent-2.0.1/settings" ??
riclava commented 6 years ago

@shuangxi588

  1. I guess it will works well as you use mariadb
  2. it can be, but you should not do like that because you need to change tpl and some other code like:
    
    user  nginx;
    worker_processes  1;

error_log /opt/nginx-admin/settings/log/error.log warn; pid /opt/nginx-admin/settings/nginx.pid;

and
<#if virtualHost.https == 1>
    listen               443 ssl;
    ssl_certificate      /opt/nginx-admin/settings/ssl/${ virtualHost.sslCertificate.resourceIdentifierCertificate.hash };
    ssl_certificate_key  /opt/nginx-admin/settings/ssl/${ virtualHost.sslCertificate.resourceIdentifierCertificatePrivateKey.hash };
    ......
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_dhparam  /opt/nginx-admin/settings/ssl/dhparam.pem;
<#else>
    listen               80;
</#if>
shuangxi588 commented 6 years ago

OK,thanks very much.

jonatansalemes commented 6 years ago

@shuangxi588

Disable/Comment entire tty its not best way to do that.

You can add single user directive to disable tty when activated using:
Defaults:nginx-agent !requiretty

To use mariadb as database you can follow mysql steps in theory i guess (not tested yet):

login as root and create database and user

create database nginx_admin; grant all privileges on nginx_admin.* to nginx_admin@'%' identified by 'password'; flush privileges;

Go to nginx-admin folder default installation /opt/nginx-admin/conf/nginx-admin.conf

and change settings to your database settings like :

NGINX_ADMIN_DB_DRIVER=mysql NGINX_ADMIN_DB_HOST=localhost NGINX_ADMIN_DB_PORT=3306 NGINX_ADMIN_DB_NAME=nginx_admin NGINX_ADMIN_DB_USERNAME=nginx_admin NGINX_ADMIN_DB_PASSWORD=password

Restart service. After that your database will be installed on mariadb/mysql with default username and password

service nginx-admin restart

Can you try and give some feedback ?

About changing default settings there is no plan to mixing folders yet or setting another folder as default because nginx-admin doesnt know about previous files (only nginx knows). There is a plan to add an import feature to nginx admin that resolve this kind of situation.

jonatansalemes commented 6 years ago

Added official support to mariadb. Added directive to avoid tty in nginx-admin-agent user script install. Will be released to the 2.0.2 with new documentation site