Reason for error: used in multiple configuration files server_name localhost
or used multiple times in the server of one configuration fileserver_name localhost
Solution: Delete the redundant server_name localhost
, or modify the suffix of other configuration files, not .conf.
You can use the following command to check:
grep -r localhost /usr/local/nginx/
find out all the files and their lines that contain localhost in this directory.