此内容的本地化语言页面暂未提供。我们将不断努力以提供本地化语言版本。感谢您的关注。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Elastic Cloud Server/ Best Practices/ Setting Up a Website/ Manually Deploying a Ghost Blog (Ubuntu 20.04)

Manually Deploying a Ghost Blog (Ubuntu 20.04)

Updated on 2024-07-31 GMT+08:00

Ghost is an open-source blog platform based on Node.js and makes writing and release more convenient. This section walks you through the deployment of a Ghost blog on an ECS running Ubuntu 20.04.

Creating a User

Performing operations as user root is not recommended by Ghost. You need to create a user and grant permissions to it.

  1. Run the following command to create a user: The following uses user as an example.

    adduser user

    The following information is displayed:

    Adding user `user' ...
    Adding new group `user' (1000) ...
    Adding new user `user' (1000) with group `user' ...
    Creating home directory `/home/user' ...
    Copying files from `/etc/skel' ...
    New password:
    Retype new password:
    passwd: password updated successfully
    Changing the user information for user
    Enter the new value, or press ENTER for the default
            Full Name []:
            Room Number []:
            Work Phone []:
            Home Phone []:
            Other []:
    Is the information correct? [Y/n] Y
    1. In the New password: and Retype new password: lines, enter and confirm the user password (not displayed by default) as prompted, and press Enter.
    2. In the Enter the new value, or press ENTER for the default line, press Enter to retain the default settings. You can also specify the information as needed.
    3. In the Is the information correct? [Y/n] line, press Y to confirm the information and press Enter to complete the settings.
  2. Run the following command to add the newly created user to the user group:

    usermod -aG sudo user

  3. Run the following command to switch to user:

    su - user

Installing Nginx

Before deploying the Ghost blog, you need to install Nginx and use it as an HTTP server. The following uses Nginx 1.18.0 as an example.

  1. Run the following commands to update the Linux OS and software package:

    sudo apt-get update

    sudo apt-get upgrade -y

  2. Run the following command to install Nginx:

    sudo apt-get install -y nginx

  3. Run the following command to check the Nginx version:

    nginx -v

    The following information is displayed:

    nginx version: nginx/1.18.0 (Ubuntu)
  4. (Optional) Configure the firewall.

    Uncomplicated Firewall (UFW) is an iptables interface that simplifies the firewall configuration. By default, Ubuntu has UFW installed. Run the following command to check the firewall status:

    sudo ufw status

    If you do not want to enable the firewall, skip this step. If you want to enable the firewall, run the following command:

    sudo ufw enable

    Verify that the firewall is enabled.

    Before testing Nginx, you need to reconfigure the firewall to allow access to Nginx. Run the following command to automatically register Nginx with UFW:

    sudo ufw app list

    The following information is displayed:

    Available applications:
      Nginx Full
      Nginx HTTP
      Nginx HTTPS
      ...
    • Nginx Full: Port 80 is enabled to distribute normal and unencrypted web traffic, and port 443 to distribute TLS/SSL-encrypted traffic.
    • Nginx HTTP: Port 80 is enabled to distribute normal and unencrypted web traffic.
    • Nginx HTTPS: Port 443 is enabled to distribute TLS/SSL-encrypted traffic.

    Run the following command to ensure that the firewall allows HTTP and HTTPS connections:

    sudo ufw allow 'Nginx Full'

  5. Verify that Nginx can work properly.

    Use the domain name or IP address to access Nginx. The Welcome to nginx page is displayed if Nginx is started normally.

    Enter http://IP address of the Nginx server in the address bar to access Nginx. If the following page is displayed, Nginx has been installed.

Installing MySQL

MySQL is an open-source database management system, which is usually installed as a part of the popular LAMP (Linux, Apache, MySQL, and PHP/Python/Perl) stack. MySQL uses relational databases and the structured query language (SQL) to manage data.

  1. Run the following command to install MySQL:

    sudo apt-get install -y mysql-server

  2. Run the following command to check the MySQL version:

    mysql -V

    The following information is displayed:

    mysql  Ver 8.0.37-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
  3. Run the following command to access MySQL:

    sudo mysql

  4. Create a database for Ghost. The following uses ghost_data as an example.

    CREATE DATABASE ghost_data;

  5. Run the following commands to set the password for user root:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';

    In the preceding command, xxxxx indicates the password you set for user root.

  6. Run the following command to reload the privilege tables of MySQL to check that the change takes effect:

    FLUSH PRIVILEGES;

  7. Run the following command to exit MySQL:

    exit

Installing Node.js

  1. Run the following commands to install Node.js:

    sudo curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -

    sudo apt-get install -y nodejs

  2. Run the following commands to view the versions of Node.js and Node Package Manager (npm), respectively:

    node -v

    npm -v

    The following information is displayed:

    root@ecs-c47c:~# node -v
    v18.20.3
    root@ecs-c47c:~# npm -v
    10.7.0

Installing and Configuring Ghost

Ghost-CLI has been added to Ghost v1.0.0 and later versions. You can directly install and configure Ghost-CLI.

  1. Run the following command to install Ghost-CLI:

    sudo npm install ghost-cli@latest -g

  2. Create a folder named ghost under /var/www/.

    sudo mkdir -p /var/www/ghost

    NOTE:

    If ghost is created under /root, Ghost cannot work properly.

  3. Run the following command to grant user permissions to ghost:

    sudo chown user:user /var/www/ghost

    sudo chmod 775 /var/www/ghost

    NOTE:

    user is created in step 1.

  4. Run the following command to switch to the created folder:

    cd /var/www/ghost

  5. Run the following command to install Ghost using Ghost-CLI:
    ghost install
    NOTE:

    If a message is displayed indicating that the node version does not match, obtain the required version on the official website of Node.js and reinstall Ghost.

    https://nodejs.org/en/download/

  6. Configure Ghost.

    If ghost install is successfully executed in /var/www/ghost/, follow the prompts to configure related parameters.

    • Enter your blog URL: Enter a resolved domain name, for example, http://example.com.
    • Enter your MySQL hostname: Enter the database connection address. In this example, the MySQL database and Ghost are deployed on the same ECS. Press Enter to retain the default settings.
    • Enter your MySQL username: Enter the database username root and press Enter.
    • Enter your MySQL password: Enter the database password set in step 5 and press Enter.
    • Enter your Ghost database name: Enter the name of the database used by Ghost. Enter ghost_data and press Enter.

    To modify the configuration, run the following command:

    vi config.production.json

    The following example is for your reference.

Verifying Blog Access

If Ghost is successfully installed, you can access the Ghost blog using the domain name.

我们使用cookie来确保您的高速浏览体验。继续浏览本站,即表示您同意我们使用cookie。 详情

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback