This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

nginx-1.10.3-1 refusing to start after installation (missing directories)


I installed the nginx-1.10.3-1 Cygwin (x86) package today, and while the install
process itself was successful, the program did not work as expected after
installation.

Starting nginx after installing it via Cygwin Setup:

    $ /usr/sbin/nginx.exe
    nginx: [alert] could not open error log file: open()
"/var/log/nginx/error.log" failed (2: No such file or directory)
    2017/02/26 16:45:17 [emerg] 11500#0: mkdir()
"/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)
    $ ps aux
          PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
         8336       1    8336       8336  ?         197609 15:38:50
/usr/bin/mintty
        11596    1412   11596      10568  pty3      197609 17:25:54 /usr/bin/ps
         1412    8336    1412      10028  pty3      197609 15:38:50
/usr/bin/bash

Trying to check nginx configuration file for errors:

    $ /usr/sbin/nginx.exe -T
    nginx: [alert] could not open error log file: open()
"/var/log/nginx/error.log" failed (2: No such file or directory)
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    2017/02/26 16:47:08 [emerg] 8092#0: mkdir()
"/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)
    nginx: configuration file /etc/nginx/nginx.conf test failed

Work-around:

    $ mkdir -p /var/log/nginx
    $ mkdir -p /var/lib/nginx/tmp

After creating the two missing directories, starting nginx works as expected
and the server gives the default nginx site on localhost:

    $ /usr/sbin/nginx.exe -T
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    ...
    $ /usr/sbin/nginx.exe
    $ ps aux | grep nginx
         1964       1    1964       1964  ?         197609 17:27:31
/usr/sbin/nginx
        12424    1964    1964      12424  ?         197609 17:27:31
/usr/sbin/nginx
    $ nc localhost 80
    GET / HTTP/1.1
    Host: localhost

    HTTP/1.1 200 OK
    Server: nginx/1.10.3
    ...

I suspect this problem could be fixed by modifying the package install scripts
to create the missing directories during the install process? I had a quick
look at the postinstall and preremove scripts for the nginx pacakge, and they
do not seem to do anything with regards to /var/log/nginx or /var/lib/nginx.

Proposed addition to /etc/postinstall/nginx.sh:

    if [ ! -d /var/log/nginx ]
    then
        /usr/bin/mkdir -p /var/log/nginx
    fi
    if [ ! -d /var/lib/nginx/tmp ]
    then
        /usr/bin/mkdir -p /var/lib/nginx/tmp
    fi

Proposed addition to /etc/preremove/nginx.sh:

    # Only remove log directroy if it's empty.
    if [ -z "$(ls -A /var/log/nginx)" ]
    then
        /usr/bin/rm -r /var/log/nginx
    fi

    # Always remove tmp directory (assuming that's safe?)
    if [ -d /var/lib/nginx/tmp ]
    then
        /usr/bin/rm -r /var/lib/nginx/tmp
    fi
    # Only remove tmp parent directory if tmp was the only thing in it.
    if [ -z "$(ls -A /var/lib/nginx)" ]
    then
        /usr/bin/rm -r /var/lib/nginx
    fi

I'm not familiar with the details of the Cygwin package install process (and
not very good at Bash scripting either), so I don't know if this is the right
way (or the right places) to fix the issue, but hopefully the intention of the
proposed solution is clear.

I'm also not sure what Cygwin's policy is on removing (user) files when
uninstalling a package, but I think leaving the log files, if any, is the
"right" thing to do?

One might argue that /var/log should also be removed if it did not exist when
nginx was first installed, but that may be outside the scope of the install
script of any single package? I already had /var/log on my system for
unrelated reasons, but others may not. (I don't know if there are other
Cygwin packages that create /var/log during their install or depend on it
being present.)


Regards,

Anders Sandvig

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]