Installer og konfigurer en Ghost v1.0.0-blog på Ubuntu 16.04

Ghost er en moderne open source-publiceringsplatform bygget på Node.js med en Ember.js-adminklient , en JSON API og en tema-API drevet af Handlebars.js . Ghost-teamet udgav for nylig en ny version af Ghost med en masse nye funktioner og forbedringer: ny markdown-editor med værktøjslinjen til at hjælpe dig med at style dit indlæg, UI/UX-forbedringer, træk og slip flere billeder, forbedret installation og opdateringsproces med nye værktøj kaldet Ghost-CLI , nyt standardtema Casper v2.0.0 og meget mere. Jeg overlader det til dig at udforske mere, når du har installeret det.

I denne tutorial skal vi installere, opsætte og konfigurere en Ghost v1.0.0 på Ubuntu 16.04 LTS ved hjælp af MySQL, Let's Encrypt, Node.js, NPM, Ghost-CLI og NGINX.

NOTE: Ubuntu 16.04 LTS is the only officially supported Linux distribution. It is not possible to install Ghost v1.0.0 on other Linux distributions. In future, it will probably be possible to install it when they add support for other distributions in Ghost-CLI tool.

Ghost-teamet anbefaler følgende serverstak og opsætning til produktionsinstallation af Ghost v1.0.0 blog:

  • Ubuntu 16.04 som operativsystem med minimum 1 GB RAM (swap kan bruges)
  • Systemd (for at styre Ghost-processen)
  • MySQL som den anbefalede databasemotor
  • NGINX (minimum 1.9.5 for SSL)
  • Node.js v6 installeret via NodeSource repository
  • NPM eller Garnpakkemanager
  • C++ compiler
  • En ikke-root bruger til at køre ghostkommandoer

Før du begynder

  1. Tjek Ubuntu-versionen:

    lsb_release -ds
    # Ubuntu 16.04.3 LTS
    
  2. Opret en ny ikke-root brugerkonto med sudoadgang og skift til den:

    NOTE: Replace johndoe with your username

    adduser johndoe --gecos "John Doe"
    usermod -aG sudo johndoe
    su - johndoe
    
  3. Indstil tidszonen:

    sudo dpkg-reconfigure tzdata
    
  4. Sørg for, at dit system er opdateret:

    sudo apt update && sudo apt upgrade -y
    
  5. Installer build-essentialpakke:

    sudo apt install -y build-essential
    

Trin 1 - Installer MySQL

Først skal vi installere MySQL-databasen, da Ghost anbefaler den som database til produktionsmiljø.

  1. Download og installer MySQL:

    sudo apt install -y mysql-server
    

    NOTE: You will be prompted to enter password for the MySQL "root" user. Enter strong password!

  2. Tjek MySQL version:

    mysql --version
    # mysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using  EditLine wrapper
    
  3. Hærd MySQL Server ved at køre mysql_secure_installationscript:

    sudo mysql_secure_installation
    

Trin 2 - Installer NGINX

Dernæst skal vi installere NGINX-software. Det vil blive brugt som en omvendt proxy til vores Ghost-applikation. Ghost-CLI kan konfigurere NGINX som en omvendt proxy for dig automatisk.

  1. Download og installer NGINX:

    sudo apt install -y nginx
    
  2. Tjek NGINX version:

    sudo nginx -v
    # nginx version: nginx/1.10.3 (Ubuntu)
    

Trin 3 - Installer Node.js og NPM

Ghost v1.0.0 currently supports Node.js versions 6.9+ and 4.5+ only. The recommended version of Node.js to use with Ghost v1.0.0 is currently Node.js v6 Boron LTS.

Ghost er bygget på Node.js. Ghost følger Nodes LTS-plan og understøtter kun LTS-versioner af Node.js. Så vi bliver nødt til at installere den nyeste LTS-version af Node.js.

  1. Download og installer Node.js og NPM:

    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    sudo apt install -y nodejs
    
  2. Tjek Node.js og NPM version:

    node -v && npm -v
    # v6.11.3
    # 3.10.10
    

Trin 4 - Installer Ghost-CLI

Ghost-CLI er et CLI-værktøj til installation og opdatering af Ghost. Det gør installation og opdatering af Ghost let. Den kan konfigurere databasen for dig, konfigurere NGINX som en omvendt proxy, konfigurere TLS-sikkerhed ved at bruge Let's Encrypt, automatisk SSL-fornyelse og konfigurere ghost som en systemd service. Det vil tage sig af grundlæggende sikkerhed for dig, ved at oprette dedikerede systembrugere kaldet ghosttil at køre Ghost blog.

  1. Installer Ghost-CLI via npm:

    sudo npm install -g ghost-cli@latest
    
  2. Tjek Ghost-CLI version:

    ghost version
    # Ghost-CLI version: 1.1.1
    
  3. Kør ghost doctorkommando for at kontrollere, at dit miljø er kompatibelt med Ghost-CLI:

    ghost doctor
    ✔ Checking system Node.js version
    ✔ Checking current folder permissions
    ✔ Checking operating system
    ✔ Checking MySQL is installed
    ✔ All install checks passed
    
  4. Få hjælp til ghostkommando:

    ghost help
    
  5. For at få mere specifik hjælp om ghostunderkommandoer kan du køre ghost help <command>. For at få hjælp til ghost configkommando, skal du køre:

    ghost help config
    

Trin 5 - Installer Ghost

NOTE: Make sure DNS records for your domain are set up. This tutorial uses example domain blog.example.tld. Replace blog.example.tld with your domain/hostname.

Nu er vi klar til at installere Ghost CMS. Den eneste måde at installere Ghost v1.0.0 på er ved at bruge Ghost-CLI-værktøjet.

  1. Opret dokumentets rodmappe:

    sudo mkdir -p /var/www/ghost
    
  2. Skift ejerskabet af /var/www/ghostmappen til den ikke-rodbruger med sudoprivilegier, som du har oprettet i begyndelsen af ​​denne vejledning:

    sudo chown <johndoe>:<johndoe> /var/www/ghost
    
  3. Naviger til dokumentets rodmappe:

    cd /var/www/ghost
    

    NOTE: Make sure /var/www/ghost directory is empty before installing Ghost and your user must own this directory.

  4. Installer Ghost i en produktionstilstand:

    ghost install
    
  5. Besvar de spørgsmål, den stiller med. Besøg Ghost docs for at få flere oplysninger om de spørgsmål, det stiller :

    ? Enter your blog URL: https://blog.example.tld
    ? Enter your MySQL hostname: localhost
    ? Enter your MySQL username: root
    ? Enter your MySQL password: [Enter password you created when you installed MySQL]
    ? Enter your Ghost database name: [Whatever you want]
    ? Do you wish to set up Nginx? yes
    ? Do you wish to set up SSL? yes
    ? Enter your email (used for Let's Encrypt notifications) [Your email for Let's Encrypt]
    ? Do you wish to set up "ghost" mysql user? yes
    ? Do you wish to set up Systemd? yes
    ? Do you want to start Ghost? yes
    

    NOTE: After installation, NGINX configuration files will be in /var/www/ghost/system/files directory. Ghost-CLI will ask you Do you wish to set up Nginx? and if your answer is yes, then it will configure NGINX as a reverse proxy for you automatically. Your NGINX config files will be in {your_ghost_installation_dir}/system/files directory.

  6. Når installationen er fuldført, kan du køre for ghost lsat se kørende Ghost-proces:

    ghost ls
    
  7. For også at kontrollere, om Ghost er installeret, kan du køre ghost versionigen fra /var/www/ghostmappen:

    ghost version
    # Ghost-CLI version: 1.1.1
    # Ghost Version (at /var/www/ghost): 1.8.4
    
  8. I fremtiden, når en nyere version af Ghost frigives, skal du bare køre ghost updatekommandoen ind fra /var/www/ghostmappen for at opdatere ghost. Før du opdaterer, skal du også lave en sikkerhedskopi af din blog fra admin-grænsefladen.

  9. For at fuldføre opsætningsprocessen og oprette en Ghost-administratorkonto skal du navigere til Ghost-konfigurationssiden ved at tilføje /ghosttil slutningen af ​​din blogs URL. Dette eksempel bruger https://blog.example.tld/ghost.

Konklusion

Vi har med succes installeret og konfigureret vores nye Ghost v1.0.0 blog til produktion. Ghost-CLI værktøj gør vores liv meget lettere ved at eliminere manuelle trin, vi havde at gøre med ældre v0.11.xGhost. Du kan også gøre alt manuelt uden hjælp fra Ghost-CLI-værktøjet, men du vil miste muligheden for nemt at opdatere din blog med ghost updatekommando. At gøre alt manuelt er besværligt og anbefales ikke. Den eneste ulempe er det faktum, at andre Linux-distributioner ikke understøttes i øjeblikket.

Efterlad en kommentar

Blog