當前安裝過程是在ghost cli 1.9.2上的,因爲ghost更新特別快,我安裝我我的博客 cmlanche.com的時候仍是1.9.1,當時沒碰到啥問題,到1.9.2就有一點點不同了,因此要注意當時你的安裝版本。針對安裝過程我會針對ghost的更新不斷更新文檔mysql
安裝設置官方文檔:https://docs.ghost.org/docs/getting-started-guidenginx
Ubuntu 16.04 or Ubuntu 18.04
見主機購買文章:當即註冊Vultr領取50美金紅包 >=8.9 (Node v8 carbon LTS)
,不支持9+,10+)# 登陸你的Ubuntu系統 ssh root@<yourip> # 添加系統新用戶 adduser <yourusername> # 提升該用戶權限 usermod -aG sudo <yourusername> # 登陸到這個用戶 su <yourusername> # 更新Ubuntu的包管理工具apt-get sudo apt-get update sudo apt-get upgrade # 安裝Nginx sudo apt-get install nginx # 爲http和https打開防火牆 sudo ufw allow 'Nginx Full' # 安裝MySql sudo apt-get install mysql-server # 登陸到mysql,更新root密碼 sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<you-mysql-password>'; # 建立mysql數據庫 create database <yourdatabasename> # 退出mysql exit # 之後你登陸mysql,就須要這樣了: mysql -uroot -p # 安裝NodeJS curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash sudo apt-get install -y nodejs # 安裝Ghost CLI sudo npm i -g ghost-cli # 建立ghost安裝目錄,並賦予權限 sudo mkdir -p /var/www/ghost sudo chown <yourusername>:<yourusername> /var/www/ghost # 好比個人用戶名是test,那就用test:test sudo chmod 775 /var/www/ghost # 賦予該目錄讀寫權限 # 將工做環境切換到ghost安裝目錄 cd /var/www/ghost # 安裝ghost ghost install # 安裝會默認使用mysql數據庫,另外能夠選擇使用sqlite,生產環境固然用mysql了
在使用ghost install安裝的時候,報錯:sql
✔ Checking system Node.js version ✔ Checking logged in user ✔ Checking current folder permissions ✔ Checking operating system compatibility ✔ Checking for a MySQL installation ✔ Checking memory availability ✖ Checking for latest Ghost version A ProcessError occurred. Message: Command failed: yarn info ghost versions --json {"type":"error","data":"An unexpected error occurred: \"EACCES: permission denied, scandir '/home/cmlanche/.config/yarn/link'\"."}
錯誤說/home/cmlanche/.config
沒權限,那麼咱們授予當前用戶這個目錄的權限:shell
sudo chown cmlanche:cmlanche /home/cmlanche/.config
注意這裏的cmlanche是我係統裏面的用戶名,你應該替換成你的用戶名。數據庫
ghost安裝必須在一個空目錄,而剛剛出錯,產生了一個叫yarn-error.log
的文件,咱們須要刪掉它:npm
rm yarn-error.log
而後再次安裝json
ghost install
輸出:bash
cmlanche@vultrhosting:/var/www/ghost$ ghost install ✔ Checking system Node.js version ✔ Checking logged in user ✔ Checking current folder permissions ✔ Checking operating system compatibility ✔ Checking for a MySQL installation ✔ Checking memory availability ✔ Checking for latest Ghost version ✔ Setting up install directory ✔ Downloading and installing Ghost v2.1.0 ✔ Finishing install process ? Enter your blog URL: (http://localhost:2368) https://www.vultrhosting.com
這樣就表示ghost安裝環境一切正常了!微信
咱們固然會要求安裝ssl證書了,ghost利用國人編寫的 acme.sh提供了一整套很是便捷的安裝 Let’s Encrypt ssl數字證書的流程,官方配置看 config
咱們輸入: https://www.vultrhosting.com,這裏咱們須要注意的是要設置爲https,對這個域名vultrhosting.com要提早設置好域名解析,例以下圖:
上圖是阿里雲後臺的截圖,你須要再你的域名註冊商設置@和www這兩個主機記錄,指向你的主機IP地址。注意必定要提早設置好,後續安裝ssl證書的時候會去檢測解析狀態的
默認用localhost就好
咱們用root就好,或者你本身登陸到mysql去建一個新用戶,注意要賦予必要的權限,比較麻煩,咱們就用root就行了。用戶名輸入了,再輸入你的mysql數據庫密碼,密碼就是環境安裝中你重設的root密碼
n,否
Y,固然安裝了
Y,等待ssl安裝完成
Y,必要選擇,文章開頭的環境要求就說了,必需要Systemd
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_www-vultrhosting-com.service Running sudo command: ln -sf /var/www/ghost/system/files/ghost_www-vultrhosting-com.service /lib/systemd/system/ghost_www-vultrhosting-com.service Running sudo command: systemctl daemon-reload ✔ Setting up Systemd ? Do you want to start Ghost? Yes Running sudo command: systemctl is-active ghost_www-vultrhosting-com ✔ Ensuring user is not logged in as ghost user ✔ Checking if logged in user is directory owner ✔ Checking current folder permissions Running sudo command: systemctl is-active ghost_www-vultrhosting-com ✔ Validating config ✔ Checking folder permissions ✔ Checking file permissions ✔ Checking content folder ownership ✔ Checking memory availability Running sudo command: systemctl start ghost_www-vultrhosting-com ✔ Starting Ghost Running sudo command: systemctl is-enabled ghost_www-vultrhosting-com Running sudo command: systemctl enable ghost_www-vultrhosting-com --quiet ✔ Enabling Ghost instance startup on server boot You can access your publication at https://www.vultrhosting.com Next, go to to your admin interface at https://www.vultrhosting.com/ghost/ to complete the setup of your publication Ghost uses direct mail by default To set up an alternative email method read our docs at https://docs.ghost.org/docs/mail-config
好了,ghost已經安裝並啓動了,訪問https://www.vultrhosting.com試試吧(^▽^)
好比操做失誤,你能夠ghost uninstall
來刪除剛剛安裝的ghost,注意須要再ghost工做目錄下執行,全部的ghost命令都要求制定工做目錄,上面我使用的工做目錄是/var/www/ghost
刪除ghost以後,你能夠重試,若是仍是出問題,那麼你能夠:
ghost stop ghost start
ghost後臺管理會再第一次打開會是一個註冊界面,要求輸入管理員帳號和密碼,註冊成功以後再次打開,若是沒有登陸的話,就是一個登陸界面。因此註冊認證只有一次。可是ghost系統並不只僅只有一個用戶,你能夠在後臺管理邀請其餘人加入你的網站系統,經過發郵件邀請的方式。
ghost CMS博客系統崇尚的是簡潔簡便,後臺管理真的是讓人愛不釋手,第一次看到它就喜歡上了,由於它我愛上了寫博客,讓我有了認真寫做的心,謝謝你ghost!