Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx service not starting on Windows 10 - nginx: [alert] could not open error log file: CreateFile()

I have an Nginx service that's configured to start automatically on my Windows 10; however, this morning, the service wouldn't start. The error log says: nginx: [alert] could not open error log file: CreateFile() "C:\someForlderName\build\distribution\.\nginx/logs/error.log" failed (3: The system cannot find the path specified)

Looking at the path in the error log above, I do NOT have the /logs/ folder on my local system so it looks like Nginx doesn't have the proper permissions to create that folder?

I'm setup as an admin user and my service is set to Log On As - Local System Account

This only happens on Windows 10; but the service starts and works on older Windows i.e 8.1

So does anyone know how to grant administrator's permissions to Nginx so that Nginx can create folders and files on Windows 10 ?

like image 721
pelican Avatar asked Feb 19 '16 17:02

pelican


People also ask

Why is nginx not starting?

If nginx does not start, look for the reason in the error log file logs\error. log . If the log file has not been created, the reason for this should be reported in the Windows Event Log. If an error page is displayed instead of the expected page, also look for the reason in the logs\error.

How can I tell if nginx is running on Windows?

Check Nginx is running or not We can verify that the Nginx is installed and running by using the following command: $ ps -ef | grep nginx.

How do I disable nginx in Windows 10?

Make a . bat file in the nginx.exe folder with the command: nginx.exe -s quit . Then make a shortcut to desktop or whereever needed.


2 Answers

You need:

To install nginx/Windows, download the latest mainline version distribution (1.13.8), since the mainline branch of nginx contains all known fixes. Then unpack the distribution, go to the nginx-1.13.8 directory, and run nginx. Here is an example for the drive C: root directory: (Run cmd as administrator)

cd c:\
unzip nginx-1.13.8.zip
cd nginx-1.13.8
start nginx

Go to: http://localhost:80 -> test install

Goback to console cmd: "nginx -s stop"

Run for next time:

  1. Config with file: "C:\nginx-1.13.8\conf\nginx.conf"
  2. Open cmd as administrator
  3. Run bash: "cd C:\nginx-1.13.8"
  4. Run nginx with bash: "start nginx" . If you run with bash: "nginx", will get trouble for exit nginx.
  5. And

    nginx -s stop #fast shutdown

    nginx -s quit #graceful shutdown

    nginx -s reload #changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes

    nginx -s reopen #re-opening log files

like image 158
Diep Gepa Avatar answered Sep 19 '22 06:09

Diep Gepa


Under the directory that you run nginx.exe, try to create a directory named logs, and a file named error.log under log. It should pass this error.

like image 45
Richard Li Avatar answered Sep 18 '22 06:09

Richard Li