Suppose you enter the following command on windows:
E:\mywamp\apache2.2\bin>E:\mywamp\nginx-1.6.2\nginx.exe -s reload
Then the input result is like this:
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
2015/01/26 22:07:10 [emerg] 5164#5196: CreateFile() "E:\mywamp\apache2.2\bin/conf/nginx.conf" failed (3: The system cannot find the path specified)
The solution is to first cd to the directory E:\mywamp\apache2.2\bin>E:\mywamp\nginx-1.6.2\
, and then run nginx -s reload
, I feel like this is too troublesome. I would like to ask if there is an easier way.
nginx’s -c option can specify the path to the configuration file, so you can try specifying the absolute path when specifying the log file in the configuration file, such as E:mywampnginx-1.6.2logsaccess.log(prevent the log from opening Log file error), and then use the absolute path of the configuration file when executing nginx reload:
However, it seems that there are still problems above, all of which are path problems. nginx relies too much on the current path.
Then try to find a way to reset the current directory before executing the nginx command. Under Windows, you can use the start command and the /D parameter to specify the starting directory. That will work. So just like thisstart /D E:mywampnginx-1.6.2 nginx -s reload
First of all, since you choose nginx, don’t use it under windows. The efficiency is much worse than under Linux.
Secondly, the reason why this file cannot be opened is obviously that the default relative path is not recognized. Modify the nginx.conf file and adjust the path address of access_log.
Finally, it is recommended that the nginx command be added directly to the environment variables. The same is true under Linux. Please refer to Java to configure environment variables
Add the parameter -p to specify the path and the solution will be perfect
E:mywampapache2.2bin>E:mywampnginx-1.6.2nginx.exe -p E:mywampnginx-1.6.2 -s reload
Do not add Nginx to the path, create an nginx.cmd file under any of your own paths:
The solution that suddenly came to my mind today, even though this problem has been around for two years (
https://gist.github.com/hyrio...