{"id":13650,"date":"2021-03-09T03:22:57","date_gmt":"2021-03-08T19:22:57","guid":{"rendered":"http:\/\/blog.idc.net\/13650\/"},"modified":"2021-03-09T03:22:57","modified_gmt":"2021-03-08T19:22:57","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:\/\/idc.net\/help\/13650\/","title":{"rendered":"Debian 8.x \/ Ubuntu 16.04.x \u642d\u5efa Ghost\u535a\u5ba2\u6559\u7a0b"},"content":{"rendered":"<div class=\"idc_table\">\n<p>\u672c\u6587\u6240\u6709\u64cd\u4f5c\u5747\u5728 root \u7528\u6237\u4e0b\u8fdb\u884c\uff0c\u8bf7\u81ea\u884c\u5207\u6362<\/p>\n<p>\u9996\u5148\uff0c\u66f4\u65b0\u7cfb\u7edf<\/p>\n<pre><code>apt-get <span>update &amp;&amp; apt-<span>get <span>upgrade <\/span><\/span><\/span><\/code><\/pre>\n<p>\u5982\u679c\u60a8\u7528\u7684 Debian 8.x \u5f00\u542f\u4e86 backports \u4e5f\u53ef\u4ee5\u66f4\u65b0\u4e0b<\/p>\n<pre><code>apt-get -t jessie-backports <span>update &amp;&amp; apt-<span>get -t jessie-backports <span>upgrade <\/span><\/span><\/span><\/code><\/pre>\n<h3><span>1\u3001\u5b89\u88c5 Node.js 6.x LTS<\/span><\/h3>\n<p>\u7531\u4e8e\u7cfb\u7edf\u81ea\u5e26\u7684 Node.js \u8f83\u8001\uff0c\u8fd9\u91cc\u6211\u4eec\u91c7\u7528&nbsp;NodeSource&nbsp;\u7f16\u8bd1\u7684 Node.js \u6e90<\/p>\n<p>Ubuntu \u4e0b<\/p>\n<pre><code>curl -sL https:<span>\/\/deb.nodesource.com\/setup_6.x | sudo -E bash - sudo apt-<span>get install nodejs <\/span><\/span><\/code><\/pre>\n<p>Debian \u4e0b<\/p>\n<pre><code>curl -sL https:<span>\/\/deb.nodesource.com\/setup_6.x | bash - apt-<span>get install nodejs <\/span><\/span><\/code><\/pre>\n<h3><span>2\u3001\u5b89\u88c5 Nginx<\/span><\/h3>\n<p>Ubuntu \u4e0b\u53ef\u4ee5\u7528 PPA<\/p>\n<p>Debian \u4e0b\u53ef\u4ee5\u7528 Dotdeb<\/p>\n<p>\u7136\u540e\u5b89\u88c5 Nginx \u4ee5\u53ca\u4e00\u4e9b\u5fc5\u8981\u7684\u8f6f\u4ef6<\/p>\n<pre><code>apt-<span>get install nginx unzip wget curl sudo sqlite3 <\/span><\/code><\/pre>\n<h3><span>3\u3001\u4e0b\u8f7d Ghost<\/span><\/h3>\n<p>\u8fd9\u91cc\u6211\u4eec\u6f14\u793a\u628a Ghost \u4e0b\u8f7d\u5e76\u89e3\u538b\u5728 \/var\/www\/ghost \u76ee\u5f55<\/p>\n<pre><code><span>cd \/var\/www\/ &amp;&amp; wget https:\/\/ghost.org\/zip\/ghost-latest.zip &amp;&amp; unzip ghost-latest.zip <span>-d ghost &amp;&amp; rm -rf ghost-latest.zip <\/span><\/span><\/code><\/pre>\n<h3><span>4\u3001\u6dfb\u52a0 ghost \u7528\u6237\u5e76\u4fee\u6539\u6743\u9650<\/span><\/h3>\n<pre><code>useradd ghost\r\nchown -R ghost:ghost \/<span>var\/www\/ghost <\/span><\/code><\/pre>\n<h3><span>5\u3001\u4fee\u6539 config.js<\/span><\/h3>\n<pre><code><span>cd \/var\/www\/ghost cp -r config.example.js config.js <\/span><\/code><\/pre>\n<p>\u63a5\u7740\u5c31\u53ef\u4ee5\u4fee\u6539&nbsp;<code>config.js<\/code>&nbsp;\u6309\u7167\u5b9e\u9645\u60c5\u51b5\uff0c\u4fee\u6539&nbsp;<code>config<\/code>&nbsp;\u6bb5\uff0c\u4e3e\u4f8b\u5982\u4e0b<\/p>\n<pre><code>config = {\r\n    <span>\/\/ ### Production <span>\/\/ When running Ghost in the wild, use the production environment. <span>\/\/ Configure your URL and mail settings here production: { url: <span>'http:\/\/example.com', <span>\/\/\u4fee\u6539\u4e3a\u4f60\u535a\u5ba2\u7684\u57df\u540d\uff0c\u5982\u9700\u8981\u542f\u52a8 SSL \u5219\u6539\u4e3a https mail: {}, database: { client: <span>'sqlite3', connection: { filename: path.<span>join(__dirname, <span>'\/content\/data\/ghost.db') }, debug: <span>false }, server: { host: <span>'127.0.0.1', port: <span>'2368' } }, <\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/code><\/pre>\n<p>\u5982\u679c\u9700\u8981\u540e\u53f0\u53d1\u9001\u90ae\u4ef6\u7ed9\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u914d\u7f6e mail \u53c2\u6570\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code><span>mail: { <span>transport: <span>'SMTP', options: { service: <span>'Mailgun', auth: { user: <span>'', \/\/ mailgun username pass: <span>'' \/\/ mailgun password } } }, <\/span><\/span><\/span><\/span><\/span><\/span><\/code><\/pre>\n<p>Ghost \u7528\u7684\u662f&nbsp;Nodemailer\uff0c\u5982\u679c\u60a8\u9700\u8981\u5176\u4ed6\u670d\u52a1\u5546\u7684 service \u540d\u5b57\uff0c\u53ef\u4ee5\u5728\u5b98\u7f51\u6587\u6863\u91cc\u67e5\u770b\u3002<\/p>\n<h3><span>6\u3001\u5b89\u88c5\u5e76\u542f\u52a8 Ghost<\/span><\/h3>\n<pre><code>cd \/var\/www\/ghost\r\nnpm <span>install <span>--production npm <span>start <span>--production <\/span><\/span><\/span><\/span><\/code><\/pre>\n<p>\u5982\u679c\u5728 Ubuntu 16.04 \u4e0b\u63d0\u793a<\/p>\n<pre><code><span>Error: Cannot find <span>module <span>'\/var\/www\/ghost\/node_modules\/sqlite3\/lib\/binding\/node-v48-linux-x64\/node_sqlite3.node' <\/span><\/span><\/span><\/code><\/pre>\n<p>\u5219\u9700\u8981\u5b89\u88c5 nodejs \u7684 sqlite3<\/p>\n<pre><code>npm <span>install sqlite3 <span>--save <\/span><\/span><\/code><\/pre>\n<p>\u53ef\u4ee5\u5728\u672c\u673a\u4e0a\u6253\u5f00&nbsp;<code>http:\/\/127.0.0.1:2368\/<\/code>&nbsp;\u67e5\u770b\u5728\u7ebf\u7248\u672c<\/p>\n<h3><span>7\u3001\u914d\u7f6e Nginx<\/span><\/h3>\n<p>\u6309&nbsp;ctrl + c&nbsp;\u505c\u6b62 Ghost \uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u4fee\u6539 Nginx \u914d\u7f6e\u6587\u4ef6\uff0c\u4e3e\u4f8b\u5982\u4e0b<\/p>\n<pre><code><span>server { <span>listen <span>80; <span>listen [::]:<span>80; <span>server_name example.com; <span>location \/ { <span>proxy_pass http:\/\/127.0.0.1:2368; <span>proxy_redirect default; <span>proxy_set_header Host <span>$http_host; <span>proxy_set_header X-Real-IP <span>$remote_addr; <span>proxy_set_header X-Forwarded-For <span>$proxy_add_x_forwarded_for; <span>proxy_set_header X-Forward-For <span>$proxy_add_x_forwarded_for; <span>proxy_set_header X-Forward-IP <span>$remote_addr; <span>proxy_set_header X-Forwarded-Proto <span>$scheme; <span>client_max_body_size <span>10m; <span>client_body_buffer_size <span>512k; <span>proxy_connect_timeout <span>5; <span>proxy_read_timeout <span>60; <span>proxy_send_timeout <span>5; <span>proxy_buffer_size <span>16k; <span>proxy_buffers <span>4 <span>64k; <span>proxy_busy_buffers_size <span>128k; <span>proxy_hide_header X-Powered-By; } } <\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/code><\/pre>\n<p>\u68c0\u67e5\u5e76\u91cd\u65b0\u52a0\u8f7d nginx<\/p>\n<pre><code>nginx -t\r\nnginx <span>-s reload <\/span><\/code><\/pre>\n<h3><span>8\u3001\u5b89\u88c5 PM2 \u4f7f Ghost \u4fdd\u6301\u540e\u53f0\u8fd0\u884c<\/span><\/h3>\n<p>PM2&nbsp;\u662f\u4e00\u6b3e\u5f88\u6d41\u884c\u7684 Node.js \u8fdb\u7a0b\u7ba1\u7406\u5668\uff0c\u53ef\u4ee5\u505a\u5230\u5f00\u673a\u542f\u52a8\u548c\u91cd\u65b0\u5173\u95ed\u7b49\u64cd\u4f5c<\/p>\n<p>\u9996\u5148\u6211\u4eec\u901a\u8fc7 npm \u5b89\u88c5 PM2<\/p>\n<pre><code><span>cd \/var\/www\/ghost npm install pm2 -g <\/span><\/code><\/pre>\n<p>\u914d\u7f6e\u5f53\u524d\u73af\u5883\uff0c\u5e76\u8bbe\u7f6e\u5f00\u542f\u542f\u52a8\uff0c\u7136\u540e\u4fdd\u5b58<\/p>\n<pre><code>NODE_ENV=production pm2 <span>start index.js <span>--name ghost pm2 <span>startup pm2 <span>save <\/span><\/span><\/span><\/span><\/code><\/pre>\n<p>\u540e\u7eed\u53ef\u80fd\u9700\u8981\u7528\u5230\u7684\u547d\u4ee4\u6709<\/p>\n<h4><span>\u542f\u52a8 Ghost<\/span><\/h4>\n<pre><code><span>pm2 start ghost <\/span><\/code><\/pre>\n<h4><span>\u505c\u6b62 Ghost<\/span><\/h4>\n<pre><code><span>pm2 stop ghost <\/span><\/code><\/pre>\n<h4><span>\u91cd\u542f Ghost<\/span><\/h4>\n<p><em>\u4e00\u822c\u7528\u4e8e\u4fee\u6539\u4e86\u4e3b\u9898\u6587\u4ef6\u6216\u8fdb\u7a0b\u9694\u5c41\u7684\u60c5\u51b5<\/em><\/p>\n<pre><code><span>pm2 restart ghost <\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6240\u6709\u64cd\u4f5c\u5747\u5728 root \u7528\u6237\u4e0b\u8fdb\u884c\uff0c\u8bf7\u81ea\u884c\u5207\u6362 \u9996\u5148\uff0c\u66f4\u65b0\u7cfb\u7edf apt-get update &amp;&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-13650","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/13650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=13650"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/13650\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=13650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=13650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=13650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}