{"id":51221,"date":"2024-10-08T16:57:16","date_gmt":"2024-10-08T08:57:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/51221\/"},"modified":"2024-11-14T10:44:12","modified_gmt":"2024-11-14T02:44:12","slug":"debian-8-x-ubuntu-16-04-x-%e6%90%ad%e5%bb%ba-ghost-%e5%8d%9a%e5%ae%a2%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/51221\/","title":{"rendered":"Debian 8.x \/ Ubuntu 16.04.x \u642d\u5efa Ghost \u535a\u5ba2\u6559\u7a0b"},"content":{"rendered":"<h1 id=\"debian-8-x-ubuntu-16-04-x-%e6%90%ad%e5%bb%ba-ghost-%e5%8d%9a%e5%ae%a2%e6%95%99%e7%a8%8b-KRkEXgyqRz\">Debian 8.x \/ Ubuntu 16.04.x \u642d\u5efa Ghost \u535a\u5ba2\u6559\u7a0b<\/h1>\n<p>Ghost \u662f\u4e00\u500b\u5c08\u70ba\u5beb\u4f5c\u800c\u8a2d\u8a08\u7684\u958b\u6e90\u535a\u5ba2\u5e73\u53f0\uff0c\u56e0\u5176\u7c21\u6f54\u7684\u754c\u9762\u548c\u5f37\u5927\u7684\u529f\u80fd\u800c\u53d7\u5230\u5ee3\u6cdb\u6b61\u8fce\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 Debian 8.x \u6216 Ubuntu 16.04.x \u7cfb\u7d71\u4e0a\u642d\u5efa Ghost \u535a\u5ba2\uff0c\u8b93\u60a8\u80fd\u5920\u8f15\u9b06\u958b\u59cb\u60a8\u7684\u5beb\u4f5c\u4e4b\u65c5\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-KRkEXgyqRz\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u4e0a\u5df2\u5b89\u88dd\u4ee5\u4e0b\u8edf\u4ef6\uff1a<\/p>\n<ul>\n<li>Node.js\uff08\u7248\u672c 14.x \u6216\u66f4\u9ad8\uff09<\/li>\n<li>npm\uff08Node.js \u7684\u5305\u7ba1\u7406\u5668\uff09<\/li>\n<li>MySQL \u6216 SQLite\uff08\u4f5c\u70ba\u6578\u64da\u5eab\uff09<\/li>\n<li>Git\uff08\u53ef\u9078\uff0c\u7528\u65bc\u7248\u672c\u63a7\u5236\uff09<\/li>\n<\/ul>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\u9019\u4e9b\u4f9d\u8cf4\u9805\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt install nodejs npm mysql-server git<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-node-js-KRkEXgyqRz\">\u5b89\u88dd Node.js<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd Node.js\u3002\u53ef\u4ee5\u4f7f\u7528 NodeSource \u63d0\u4f9b\u7684\u5b89\u88dd\u8173\u672c\u4f86\u5b89\u88dd\u6700\u65b0\u7248\u672c\u7684 Node.js\uff1a<\/p>\n<pre><code>curl -sL https:\/\/deb.nodesource.com\/setup_14.x | sudo -E bash -\nsudo apt install -y nodejs<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5 Node.js \u548c npm \u7684\u7248\u672c\uff1a<\/p>\n<pre><code>node -v\nnpm -v<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-ghost-KRkEXgyqRz\">\u5b89\u88dd Ghost<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 npm \u5b89\u88dd Ghost\u3002\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u65b0\u7684\u76ee\u9304\u4f86\u5b58\u653e Ghost\uff1a<\/p>\n<pre><code>mkdir -p ~\/ghost\ncd ~\/ghost<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528 npm \u5b89\u88dd Ghost\uff1a<\/p>\n<pre><code>npm install ghost<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-ghost-KRkEXgyqRz\">\u914d\u7f6e Ghost<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Ghost\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>cp config.example.json config.json<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b config.json \u6587\u4ef6\uff0c\u6839\u64da\u60a8\u7684\u9700\u6c42\u9032\u884c\u4fee\u6539\u3002\u7279\u5225\u662f\uff0c\u60a8\u9700\u8981\u8a2d\u7f6e\u60a8\u7684\u7db2\u7ad9 URL \u548c\u6578\u64da\u5eab\u914d\u7f6e\u3002<\/p>\n<h3 id=\"%e8%a8%ad%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab-KRkEXgyqRz\">\u8a2d\u7f6e\u6578\u64da\u5eab<\/h3>\n<p>\u5982\u679c\u60a8\u9078\u64c7\u4f7f\u7528 MySQL\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u6578\u64da\u5eab\u548c\u7528\u6236\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u5165 MySQL\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u5275\u5efa\u6578\u64da\u5eab\u548c\u7528\u6236\uff1a<\/p>\n<pre><code>CREATE DATABASE ghost_db;\nCREATE USER 'ghost_user'@'localhost' IDENTIFIED BY 'your_password';\nGRANT ALL PRIVILEGES ON ghost_db.* TO 'ghost_user'@'localhost';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<p>\u5728 config.json \u4e2d\uff0c\u5c07\u6578\u64da\u5eab\u914d\u7f6e\u66f4\u6539\u70ba\uff1a<\/p>\n<pre><code>\"database\": {\n    \"client\": \"mysql\",\n    \"connection\": {\n        \"host\": \"127.0.0.1\",\n        \"user\": \"ghost_user\",\n        \"password\": \"your_password\",\n        \"database\": \"ghost_db\"\n    }\n}<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-ghost-KRkEXgyqRz\">\u555f\u52d5 Ghost<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Ghost\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Ghost\uff1a<\/p>\n<pre><code>npm start<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\u60a8\u7684 Ghost \u535a\u5ba2\uff0c\u7db2\u5740\u70ba <code>http:\/\/your_server_ip:2368<\/code>\u3002<\/p>\n<h2 id=\"%e8%a8%ad%e7%bd%ae%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%ef%bc%88%e5%8f%af%e9%81%b8%ef%bc%89-KRkEXgyqRz\">\u8a2d\u7f6e\u53cd\u5411\u4ee3\u7406\uff08\u53ef\u9078\uff09<\/h2>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u901a\u904e\u6a19\u6e96\u7684 HTTP \u7aef\u53e3\uff0880\uff09\u8a2a\u554f\u60a8\u7684\u535a\u5ba2\uff0c\u60a8\u53ef\u4ee5\u8a2d\u7f6e Nginx \u4f5c\u70ba\u53cd\u5411\u4ee3\u7406\u3002\u9996\u5148\uff0c\u5b89\u88dd Nginx\uff1a<\/p>\n<pre><code>sudo apt install nginx<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u5275\u5efa\u4e00\u500b\u65b0\u7684 Nginx \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/nginx\/sites-available\/ghost<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>server {\n    listen 80;\n    server_name your_domain.com;\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:2368;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection 'upgrade';\n        proxy_set_header Host $host;\n        proxy_cache_bypass $http_upgrade;\n    }\n}<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u555f\u7528\u914d\u7f6e\u4e26\u91cd\u555f Nginx\uff1a<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/ghost \/etc\/nginx\/sites-enabled\/\nsudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KRkEXgyqRz\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u6210\u529f\u5728 Debian 8.x \u6216 Ubuntu 16.04.x \u7cfb\u7d71\u4e0a\u642d\u5efa\u4e86 Ghost \u535a\u5ba2\u3002\u9019\u662f\u4e00\u500b\u5f37\u5927\u4e14\u9748\u6d3b\u7684\u5beb\u4f5c\u5e73\u53f0\uff0c\u9069\u5408\u5404\u7a2e\u9700\u6c42\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u4f3a\u670d\u5668\u4f86\u904b\u884c\u60a8\u7684\u535a\u5ba2\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u63d0\u4f9b\u9ad8\u6548\u80fd\u548c\u53ef\u9760\u6027\uff0c\u8b93\u60a8\u7684\u7db2\u7ad9\u904b\u884c\u7121\u6182\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up a Ghost blog on Debian 8.x or Ubuntu 16.04.x with this step-by-step tutorial, perfect for beginners and enthusiasts alike.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-51221","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=51221"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51221\/revisions"}],"predecessor-version":[{"id":51222,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51221\/revisions\/51222"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=51221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=51221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=51221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}