Mac restarts nginx error: & quot; failed (2: No such file or directory) "

Posted May 27, 20201 min read

Since the file was lost due to restarting nginx, I searched many solutions on the Internet, but in fact only the first step was used, and be sure to note that the system used by everyone is different, and the installation path of nginx will also be somewhat The difference, for example, the storage path of the nginx.conf file is /usr/local/nginx/nginx.conf, but mine is /usr/local/etc/nginx/nginx.conf.
My solution:
The first step is to delete the "#" in the sentence #pid logs/ in the nginx.conf file;
The second step is to create a new logs folder in the error directory(/usr/local/Cellar/nginx/1.17.6/). At the beginning, I did n t know which directory the logs file was built in, but just posted it according to the online solution. The picture will level the logs folder with the nginx.conf file:/usr/local/etc/nginx/logs, and finally found that it should not be built in this path, but the new log is created in the path of the error prompt;
The last step is to create a new file in the logs folder and execute nginx -s reload. You will find that the nginx command can be used without error. The methods found on the Internet are first nginx -s reload, and then execute nginx -c /usr/local/etc/nginx/nginx.conf and other various commands to generate file, but my nginx command I ca n t use it, let alone execute nginx -s reload and nginx -c /usr/local/etc/nginx/nginx.conf, I will only report that this command has not been found. Touch, then execute nginx -s reload and find that the nginx command can be used!