腾讯云搭建Ghost
- 安装 Ghost-CLI
html sudo npm install ghost-cli@latest -g
安装完成后,可运行命令 ghost help
查看命令列表。
- 安装 Ghost
出于安全考虑,在接下来的操作中不能使用 root
用户,所以我们要新建一个用户,把下面的 <user>
换成用户名(不要起名 ghos,容易起冲突)。
# Create a new user and follow prompts
adduser <user>
# Add user to superuser group to unlock admin privileges
usermod -aG sudo <user>
# Then log in as the new user
su - <user>
接着需要创建一个空文件夹,用来安装 Ghost。
# We'll name ours 'ghost' in this example; you can use whatever you want
sudo mkdir -p /var/www/ghost
# Replace <user> with the name of your user who will own this directory
sudo chown <user>:<user> /var/www/ghost
# Set the correct permissions
sudo chmod 775 /var/www/ghost
# Then navigate into it
cd /var/www/ghost
安装 Ghost。
ghost install
安装过程根据主机性能来决定,下面是选项配置讲解:
Enter your blog URL:
博客展示地址,格式:http(s):(www.)example.com
,不支持ip地址。Enter your MySQL hostname:
数据库主机地址,回车默认是localhost
。Enter your MySQL username: / Enter your MySQL password:
数据库用户名/密码,上面安装的数据库用户名是root
,密码是自己设置的。Enter your Ghost database name:
Ghost博客数据库名Do you wish to set up "ghost" mysql user?
设置数据库用户名为ghost
,这个为了避免权限太大导致数据瞎搞,Ghost官方推荐是y
。Do you wish to set up Nginx?
自动化Nginx,推荐y
。Do you wish to set up SSL?
配置SSL
证书,推荐y
,如果你有证书问题,请查看文章最下面的问题。Enter your email (For SSL Certificate):
个人邮箱,配置ssl证书需要的邮箱地址。Do you wish to set up Systemd?
使用ghost进程管理工具,推荐y
,个人觉得海星。Do you want to start Ghost?
启动Ghost博客就可以进入网址访问。
注意:
System checks failed with message: 'Linux version is not Ubuntu 16 or 18'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? Yes #提示系统不是ubuntu,是否继续?当然
- 还有个问题就是在安装的过程中会碰到下载失败的问题,再次安装就会提示
A SystemError occurred.
Message: Current directory is not empty, Ghost cannot be installed here.
#对应的解决办法是:
#只需要执行 rm -rf *,删除全部文件,然后再次执行安装命令即可;、
#如果还是提示目录非空的话,那就删除 .ghost-cli 文件
如果可以正常启动那么恭喜你,你已经可以访问你的博客了。如果不可以那么大概率是 Nginx 配置的问题。那么接下来我们继续
