{"id":42906,"date":"2024-10-04T08:46:48","date_gmt":"2024-10-04T00:46:48","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42906\/"},"modified":"2024-10-04T08:46:48","modified_gmt":"2024-10-04T00:46:48","slug":"centos-7-2-%e6%90%ad%e5%bb%ba-ghost-%e5%8d%9a%e5%ae%a2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42906\/","title":{"rendered":"CentOS 7.2 \u642d\u5efa Ghost \u535a\u5ba2"},"content":{"rendered":"<h1 id=\"centos-7-2-%e6%90%ad%e5%bb%ba-ghost-%e5%8d%9a%e5%ae%a2-cgiADeHNyG\">CentOS 7.2 \u642d\u5efa Ghost \u535a\u5ba2<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u4f4d\u6642\u4ee3\uff0c\u64c1\u6709\u4e00\u500b\u500b\u4eba\u535a\u5ba2\u5df2\u6210\u70ba\u8a31\u591a\u4eba\u7684\u9700\u6c42\u3002Ghost \u662f\u4e00\u500b\u6d41\u884c\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\u559c\u611b\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728 CentOS 7.2 \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-cgiADeHNyG\">\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<\/li>\n<li>MySQL \u6216 SQLite<\/li>\n<li>Nginx \u6216 Apache<\/li>\n<li>Git<\/li>\n<\/ul>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd Node.js \u548c Git\uff1a<\/p>\n<pre><code>sudo yum install -y epel-release\nsudo yum install -y nodejs git<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-ghost-cgiADeHNyG\">\u5b89\u88dd Ghost<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u65b0\u7684\u76ee\u9304\u4f86\u5b89\u88dd Ghost\uff1a<\/p>\n<pre><code>mkdir -p \/var\/www\/ghost\ncd \/var\/www\/ghost<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528 Git \u514b\u9686 Ghost \u7684\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<pre><code>git clone -b stable https:\/\/github.com\/TryGhost\/Ghost.git .<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd Ghost \u7684\u4f9d\u8cf4\u9805\uff1a<\/p>\n<pre><code>npm install --production<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-ghost-cgiADeHNyG\">\u914d\u7f6e Ghost<\/h2>\n<p>\u5728\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Ghost\u3002\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u52d5 Ghost \u914d\u7f6e\u5411\u5c0e\uff1a<\/p>\n<pre><code>npm start<\/code><\/pre>\n<p>\u9019\u5c07\u5f15\u5c0e\u60a8\u5b8c\u6210\u914d\u7f6e\u904e\u7a0b\uff0c\u5305\u62ec\u8a2d\u7f6e\u60a8\u7684\u7db2\u7ad9 URL\u3001\u6578\u64da\u5eab\u7b49\u3002\u60a8\u53ef\u4ee5\u9078\u64c7\u4f7f\u7528 SQLite \u4f5c\u70ba\u6578\u64da\u5eab\uff0c\u9019\u5c0d\u65bc\u5c0f\u578b\u535a\u5ba2\u4f86\u8aaa\u662f\u8db3\u5920\u7684\u3002<\/p>\n<h2 id=\"%e8%a8%ad%e7%bd%ae-nginx-%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86-cgiADeHNyG\">\u8a2d\u7f6e Nginx \u53cd\u5411\u4ee3\u7406<\/h2>\n<p>\u70ba\u4e86\u8b93\u60a8\u7684\u535a\u5ba2\u80fd\u5920\u901a\u904e HTTP \u8a2a\u554f\uff0c\u60a8\u9700\u8981\u8a2d\u7f6e Nginx \u4f5c\u70ba\u53cd\u5411\u4ee3\u7406\u3002\u9996\u5148\uff0c\u5b89\u88dd Nginx\uff1a<\/p>\n<pre><code>sudo yum install -y 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 vi \/etc\/nginx\/conf.d\/ghost.conf<\/code><\/pre>\n<p>\u5728\u8a72\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>server {\n    listen 80;\n    server_name your_domain.com;  # \u66ff\u63db\u70ba\u60a8\u7684\u57df\u540d\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:2368;  # Ghost \u9ed8\u8a8d\u7aef\u53e3\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\uff0c\u7136\u5f8c\u6aa2\u67e5 Nginx \u914d\u7f6e\u662f\u5426\u6b63\u78ba\uff1a<\/p>\n<pre><code>sudo nginx -t<\/code><\/pre>\n<p>\u5982\u679c\u6c92\u6709\u932f\u8aa4\uff0c\u5247\u91cd\u65b0\u555f\u52d5 Nginx\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e5%95%9f%e5%8b%95-ghost-cgiADeHNyG\">\u555f\u52d5 Ghost<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Ghost\uff1a<\/p>\n<pre><code>npm start<\/code><\/pre>\n<p>\u70ba\u4e86\u8b93 Ghost \u5728\u4f3a\u670d\u5668\u91cd\u555f\u5f8c\u81ea\u52d5\u555f\u52d5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 PM2 \u4f86\u7ba1\u7406 Ghost \u9032\u7a0b\u3002\u9996\u5148\uff0c\u5b89\u88dd PM2\uff1a<\/p>\n<pre><code>npm install pm2 -g<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528 PM2 \u555f\u52d5 Ghost\uff1a<\/p>\n<pre><code>pm2 start index.js --name \"ghost\"<\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u8a2d\u7f6e PM2 \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>pm2 startup\npm2 save<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-cgiADeHNyG\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u6210\u529f\u5728 CentOS 7.2 \u4e0a\u642d\u5efa\u4e86 Ghost \u535a\u5ba2\u3002\u9019\u500b\u904e\u7a0b\u4e0d\u50c5\u5e6b\u52a9\u60a8\u5b78\u7fd2\u4e86\u5982\u4f55\u914d\u7f6e\u4f3a\u670d\u5668\uff0c\u9084\u8b93\u60a8\u80fd\u5920\u64c1\u6709\u4e00\u500b\u5c6c\u65bc\u81ea\u5df1\u7684\u535a\u5ba2\u5e73\u53f0\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\u9019\u5c07\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u826f\u597d\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up a Ghost blog on CentOS 7.2 with this step-by-step guide, covering installation, configuration, and optimization tips.<\/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-42906","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42906","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=42906"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42906\/revisions"}],"predecessor-version":[{"id":42907,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42906\/revisions\/42907"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}