Ad Widget

Collapse

Nginx/Posgres as Frontend/Backend(Same Server)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bacil123
    Junior Member
    • Feb 2025
    • 4

    #1

    Nginx/Posgres as Frontend/Backend(Same Server)

    Hello All. We are setting up Zabbix with Nginx/Posgres combo as Frontend/Backend(Same Server).
    Created initial DB as per Zabbix documentation:
    sudo -u postgres createuser --pwprompt zabbix
    sudo -u postgres createdb -O zabbix zabbix

    Imported initial schema and data:
    zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql Zabbix

    Configure DB for Zabbix.

    After that stuck, as the manual has no info on how to configure Nginx for Zabbix further.
    Nginx-1.27.4 was installed successfully manually via nginx-1.27.4.tar and pcre2-10.45.tar.
    # /usr/local/nginx/sbin/nginx -V
    nginx version: nginx/1.27.4
    built by gcc 11.4.1 20231218 (Red Hat 11.4.1-3) (GCC)
    configure arguments: --with-http_stub_status_module

    ./configure; make; 'make install' were run for both Nginx & PCRE, with no errors at all.

    # ps -eaf | grep -i nginx
    root 69056 1 0 Mar19 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
    nginx 69057 69056 0 Mar19 ? 00:00:00 nginx: worker process
    root 183791 183091 0 10:14 pts/0 00:00:00 grep --color=auto -i nginx

    # /usr/local/nginx/sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    But not sure what will be the next steps to do. also, it gives error Unit nginx.service not found.
    # sudo systemctl status nginx
    Unit nginx.service could not be found.
    # sudo systemctl start nginx
    Failed to start nginx.service: Unit nginx.service not found. <= This Unit nginx.service not found has been now resolved: UPDATE

    So, the issue mentioned earlier(Unit nginx.service not found) has been resolved as of now. From a non-zabbix google search, a file was modified at this location: /lib/systemd/system/nginx.service
    [Unit]
    Description=The NGINX HTTP and reverse proxy server
    After=syslog.target network-online.target remote-fs.target nss-lookup.target
    Wants=network-online.target

    [Service]
    Type=forking
    PIDFile=/usr/local/nginx/logs/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target
    And, then restarting nginx brought back it up fine.

    http:/<IP Address>
    Welcome to nginx!
    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

    # sudo systemctl restart nginx
    # sudo systemctl status nginx
    ● nginx.service - The NGINX HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: disabled)
    Active: active (running) since Thu 2025-03-20 15:26:59 -05; 9s ago
    Process: 230537 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 230539 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
    Main PID: 230540 (nginx)
    Tasks: 2 (limit: 203362)
    Memory: 1.6M
    CPU: 13ms
    CGroup: /system.slice/nginx.service
    ├─230540 "nginx: master process /usr/local/nginx/sbin/nginx"
    └─230541 "nginx: worker process"

    Mar 20 15:26:59 somebody.corp systemd[1]: Starting The NGINX HTTP and reverse proxy server...
    Mar 20 15:26:59 somebody.corp nginx[230537]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    Mar 20 15:26:59 somebody.corp nginx[230537]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    Mar 20 15:26:59 somebody.corp systemd[1]: Started The NGINX HTTP and reverse proxy server.

    As per Zabbix manual, next steps is to Configure PHP for Zabbix frontend, but I don't find zabbix.conf file in the system

    Please advise on the next steps. Thanks in advance.
    Last edited by Bacil123; 20-03-2025, 22:48.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    What s the reason of compiling it by yourself?
    https://www.zabbix.com/download?zabb...red_hat_enterp rise_linux&os_version=9&components=server_frontend _agent&db=pgsql&ws=nginx (random redhat example, but others are similar, just different installation tool)
    b. Install Zabbix server, frontend, agent
    # dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
    If you would use normal packaged version you would get also those packages installed in correct places and your worries would be over...
    If you want to go hard way and install from sources, then https://www.zabbix.com/documentation...-web-interface follow examples...
    find web content and all config files from source package, place them where you have put your webserver, modify all the config to work with your custom setup...

    Comment


    • Bacil123
      Bacil123 commented
      Editing a comment
      Hi. Thanks. Since I don't have proper access to the web to donwload packages seamlessly, and sudo yum install, fails mostly. So, was doing it a manual(hard) way.

      I have as of now reached too far and almost there. Took some time to install PHP as well as there were some issues related to libxml etc:
      configure: error: Package requirements (libxml-2.0 >= 2.9.4) were not met:
      Package 'libxml-2.0', required by 'virtual:world', not found >= But now all resolved and done.

      One thing now noticing is:
      # systemctl | grep zabbix
      zabbix-agent.service loaded activating auto-restart Zabbix Agent
      zabbix-agent2.service loaded active running Zabbix Agent 2
      zabbix-server.service loaded active running
      So, currently looking on how to resolve this. agent.service things.

      Thanks for the link shared above for 'Installation from sources'. Will follow it and see how it goes.
      Best.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #3
    Choose either agentd or agent2. No point running both. They cannot be running at same time on same port anyway. Just disable the one you dont want.

    Comment


    • Bacil123
      Bacil123 commented
      Editing a comment
      Hi. Thanks. So after dabbling with nginx without success(always says port 80 in use, and even if changed to port 8080, it says in use), I completely uninstall nginx, and re-installed apache a fresh from tar.gz source. Had to uninstall apache earlier(prior to attempting nginx) which came back to bite me as apache came with original OS install. So, had to install apache with tar.gz. Apache running fine as of now.
      # systemctl status httpd
      ● httpd.service - The Apache HTTP Server
      Loaded: loaded (/etc/systemd/system/httpd.service; enabled; preset: disabled)
      Drop-In: /usr/lib/systemd/system/httpd.service.d
      └─php-fpm.conf
      Active: active (running) since Wed 2025-03-26 14:07:48 -05; 52min ago
      Main PID: 231135 (httpd)
      Tasks: 7 (limit: 203368)
      Memory: 5.8M
      CPU: 122ms
      CGroup: /system.slice/httpd.service
      ├─231135 /usr/sbin/httpd -k start
      ├─231136 /usr/sbin/httpd -k start
      ├─231137 /usr/sbin/httpd -k start
      ├─231138 /usr/sbin/httpd -k start
      ├─231139 /usr/sbin/httpd -k start
      ├─231140 /usr/sbin/httpd -k start
      └─231351 /usr/sbin/httpd -k start
      Mar 26 14:07:48 sbmdebvs06v.bancolombia.corp systemd[1]: Starting The Apache HTTP Server...
      Mar 26 14:07:48 sbmdebvs06v.bancolombia.corp systemd[1]: Started The Apache HTTP Server.

      # sudo systemctl status zabbix-server.service
      ● zabbix-server.service - Zabbix Server
      Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; preset: disabled)
      Active: active (running) since Wed 2025-03-26 17:16:07 -05; 7min ago
      Process: 1769 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
      Main PID: 1854 (zabbix_server)
      Tasks: 52 (limit: 203368)

      ]# systemctl status zabbix-web-service.service
      ● zabbix-web-service.service - Zabbix Web Service
      Loaded: loaded (/usr/lib/systemd/system/zabbix-web-service.service; enabled; preset: disabled)
      Active: active (running) since Thu 2025-03-27 12:07:05 -05; 36min ago
      Main PID: 17040 (zabbix_web_serv)
      Tasks: 7 (limit: 203368)
      Memory: 6.7M
      CPU: 7ms
      CGroup: /system.slice/zabbix-web-service.service
      └─17040 /usr/sbin/zabbix_web_service -c /etc/zabbix/zabbix_web_service.conf
      Web_service is now Active, and running. Still can't open the web-page.

      Thanks.
      Last edited by Bacil123; 27-03-2025, 19:44.
Working...