[Vuejs]-How can I change port on nginx.conf by command line mac os?

1👍

You can use sed to edit your nginx.conf from the command-line like this:

sed -E 's/listen[[:space:]]+[[:digit:]]+/listen 80/' nginx.conf 

That says… “wherever you see the word listen followed by one or more spaces then one or more digits, replace that with listen 80

If the output looks correct, you can edit the file in place with the -i switch:

sed -E -i.bak 's/listen[[:space:]]+[[:digit:]]+/listen 80/' nginx.conf

which also makes a backup file in case something goes wrong.

-1👍

  1. Change 8080 to 80 and save.
  2. Restart nginx:
# Make sure the syntax is OK.
sudo nginx -t
# Then restart
sudo systemctl restart nginx

Leave a comment