Ghost is an outstanding open-source blog website developed with Node.js. It uses MySQL, SQLite, or PostgreSQL to store data. This topic describes how to set up a Ghost blog website for a production environment on the Linux operating system.
Compared to Wordpress, Ghost offers advantages such as instant preview, simplicity, and ease of use:
- Architecturally, Ghost is developed by using Node.js, enabling higher concurrency.
- In terms of design, Ghost features a more streamlined interface, native Markdown support, and a writing-focused environment that minimizes distractions.
- Ghost supports multiple capabilities such as online preview and online writing, facilitating seamless content creation anytime, anywhere.
Software versions
- Operating system: In the example provided in this topic, Ubuntu 18.04 is used.
- Nginx: A high-performance, lightweight web server that supports HTTP and reverse proxy. In the example provided in this topic, Nginx 1.14.0 is used.
- MySQL: A database management system. In the example provided in this topic, MySQL 14.14 is used.
- Node.js: A server-side scripting language embedded in HTML documents. In the example provided in this topic, Node.js 14.18.1 is used.
- Ghost: In the example provided in this topic, Ghost 4.24.0 is used.
Step 1: Create a user
The official Ghost website recommends that you do not perform operations directly as the root user. Before you set up a Ghost blog website, create a user.
- Execute the following command to create a user.
- Do not use ghost as a username. Otherwise, conflicts with Ghost-CLI may arise. In the example provided in this topic, ghostuser is used as the username.
- The following output is displayed. You need to specify the password and other information for ghostuser. If you do not want to specify other information, you can press the Enter key to skip the configuration.
- Execute the following command to add user permissions.
- Execute the following command to switch to the ghostuser user.
- If the following output is displayed, you are switched to the ghostuser user.
-
Step 2: Install Nginx
- Execute the following command to update the software package.
- Execute the following command to install Nginx.
- Execute the following command to view the Nginx version.
- If the following output is displayed, the installation is successful.
- In the local browser, enter http://<ECS instance EIP>/ to access Nginx.
- If the following output is displayed, Nginx is set up successfully.
-
Step 3: Install Node.js
- Execute the following commands in sequence to install Node.js.
- Execute the following command to view the Node.js version.
- If the following output is displayed, Node.js is set up successfully.
Step 4: Install MySQL
- Execute the following command to install MySQL.
- Execute the following command to connect to MySQL.
- Execute the following command to create the database used by Ghost. In the example provided in this topic, ghostdata is created.
- Execute the following command to specify the password for the root account.
- Execute the following command to exit MySQL.
- Execute the following command to view the MySQL version.
- If the following output is displayed, MySQL is set up successfully.
Step 5: Install and configure Ghost
- Execute the following command to install the Ghost-CLI tool.
- Execute the following command to create a folder for installing Ghost.
- Execute the following command to configure permissions for the ghostuser user.
- Execute the following command to enter the Ghost folder.
- Execute the following command to install Ghost by using Ghost-CLI.
- The following output is displayed. Complete the configuration in sequence.
- You can perform simple configurations based on your business requirements. If you want to make changes later, execute the vi config.production.json command to open the configuration file and make the necessary changes.
- Follow the onscreen instructions to perform operations.
Step 6: Visit the Ghost blog website
Enter the Ghost domain name in your local browser to access the Ghost blog website.
Step 7 (Optional): Enable HTTPS for the website
When a user accesses your website over the HTTP protocol, the browser warns the user that the connection is not secure. We recommend that you enable HTTPS secure communication for your website. This ensures encrypted data transmission between users and your website, effectively defending against network hijacking, information leakage, and other threats.