Results 1 to 2 of 2

Thread: systemd and nginx on 13.1

  1. #1

    Default systemd and nginx on 13.1

    I have nginx installed in /opt/nginx and was installed by Passenger.

    I can start it up with
    Code:
    /opt/ngix/sbin/nginx
    and my rails app runs fine.

    I created a systemd service and when using that,
    Code:
    systemctl start nginx
    hangs forever, but nginx is started.

    Trying to access my website results in an error where rails is complaining that it can't talk to the database, even though the database is running and I can connect and query it. After a few minutes nginx crashes.

    [Unit]
    Description=HTTP server
    After=syslog.target network.target remote-fs.target nss-lookup.target

    [Service]
    Type=forking
    PIDFile=/opt/nginx/conf/nginx.pid
    ExecStartPre=/opt/nginx/sbin/nginx -t
    ExecStart=/opt/nginx/sbin/nginx
    ExecReload=/bin/kill -s HUD $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID

    [Install]
    WantedBy=multi-user.target

    Am I missing something or have something misconfigured here?

    The problem is definitely not ngix or my rails app. I can get a rails console and interact with the database.

    Code:
    /opt/nginx/sbin/nginx -t
    nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

  2. #2

    Default Re: systemd and nginx on 13.1

    I got it worked out.

    For any that have a similar issue, I deleted the nginx.service file.

    I copied and changed the paths in this file and placed it in /etc/init.d/nginx.

    The two lines that I changed were

    114: NGINX_BIN=/opt/nginx/sbin/nginx
    118: NGINX_PID=/opt/nginx/logs/nginx.pid


    Ran these:

    chkconfig --set nginx on
    systemctl daemon-reload
    /etc/init.d/nginx start

    And everything is working correctly.

    Using systemctl start/stop/status/etc niginx.service works as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •