Home > Web Front-end > Front-end Q&A > nodejs ghost change port

nodejs ghost change port

WBOY
Release: 2023-05-17 10:59:07
Original
589 people have browsed it

Ghost is an open source blog platform written based on Node.js. It provides an easy-to-use management panel and flexible theme customization functions. It is widely used in personal blogs, news websites and other fields. In most cases, Ghost uses port 80 to provide services, but in some cases, we may need to change it to another port.

This article will introduce how to change the port in Ghost of Node.js, and provide 2 options for readers to choose.

Option 1: Specify the port number directly in the command line parameters

When starting Ghost, you can use the --port parameter to specify the port number to be used. The specific steps are as follows:

  1. Open the command line terminal and enter the Ghost installation directory.
  2. Enter the following command to start Ghost:
npm start -- --port 8080
Copy after login

Among them, the --port parameter specifies the port number to be used, and port 8080 is used here. After successful startup, you can visit http://localhost:8080 in the browser to view Ghost's homepage.

If you need to change the port number, just modify the value of the --port parameter.

Option 2: Modify Ghost’s configuration file

In the Ghost installation directory, there is a configuration file named config.js, which contains various configuration information of Ghost, including ports Number. By modifying the config.js file, you can change the Ghost port.

The specific steps are as follows:

  1. Open the command line terminal and enter the Ghost installation directory.
  2. Open the config.js file and find the following code in it:
config: {
  ...
  server: {
    host: '127.0.0.1',
    port: process.env.PORT || '2368',
  },
  ...
},
Copy after login

The port parameter specifies the port number used by Ghost, which defaults to 2368.

  1. Modify the value of the port parameter to the port number you want, for example:
config: {
  ...
  server: {
    host: '127.0.0.1',
    port: process.env.PORT || '8080',
  },
  ...
},
Copy after login
  1. Save the config.js file.
  2. Restart Ghost for the changes to take effect.

Both of the above two solutions can be used to change the port in Ghost of Node.js. Readers can choose one of the options based on their actual needs. In actual use, you need to pay attention to the port number not to conflict with other running programs.

The above is the detailed content of nodejs ghost change port. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template