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:
npm start -- --port 8080
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:
config: { ... server: { host: '127.0.0.1', port: process.env.PORT || '2368', }, ... },
The port parameter specifies the port number used by Ghost, which defaults to 2368.
config: { ... server: { host: '127.0.0.1', port: process.env.PORT || '8080', }, ... },
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!