While editing files on a machine running Windows and uploading them to a Linux server is convenient, but this may lead to problems. Windows-based text editors put special characters at the end of lines to denote a line return or newline. Some applications on a Linux server cannot understand these characters and can cause the service to not respond correctly. There is a simple way to correct this problem: dos2unix.
Below is an example from a php.ini file showing what the hidden characters look like:
;;;;;;;;;;;;;;;;;;;^M
; Resource Limits ;^M
;;;;;;;;;;;;;;;;;;;^M
;^M
max_execution_time = 30^M
max_input_time = 60^M
memory_limit = 32M^M
This will not be appear in windows editors but appear in Linux editors. We can convert this using the command: dos2unix /path/to/file
For example :
root@host [~]# dos2unix /usr/local/lib/php.ini
dos2unix: converting file /usr/local/lib/php.ini to UNIX format ...
That's it now the file will not contain any special windows characters.
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
;
max_execution_time = 30
max_input_time = 60
memory_limit = 32M