Trouble setting up Ruby with Nginx on CentOS 6.5

eComEvo asked:

Following the instructions here:

I get to the point of “Use vim /etc/init.d/nginx to create the start/restart/stop script for nginx” but I can’t get the server to start after creating this file and giving it permission to execute. I just get the error env: /etc/init.d/nginx: No such file or directory but I can clearly see that the file is where it is supposed to be.

When I try to start nginx directly using /etc/init.d/nginx start I get the error -bash: /etc/init.d/nginx: /bin/sh^M: bad interpreter: No such file or directory.

What could be causing this?

My answer:

Be careful what text editors you use on your local Windows computer. Some create Windows-style line endings (\r\n, CR-LF), which cause problems like this on Unix-like systems such as Linux or Mac OS X.

If you use such an editor, adjust its settings so that it creates files with Unix-style line endings. If the editor has no such setting, you should not be using it at all.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.