yum update -y
yum groupinstall -y "Development Tools"
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
yum -y install nodejs
npm config set registry https://registry.npm.taobao.org //配置加速
npm i -g cnpm
安装成功后通过运行node -v及npm -v 出现版本号即可表示安装成功。
因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。
安装mysql
rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum -y install mysql-server mysql
systemctl start mysqld.service
配置mysql
mysql
mysql> create database ghost;
mysql> grant all on ghost.* to 'ghost'@localhost identified by 'ghost';//密码:ghost
mysql> flush privileges;
cnpm i -g ghost-cli
安装成功后通过运行 ghost -v,出现版本号即可表示安装成功。
创建ghost用户
adduser ghost
mkdir /var/www
mkdir /var/www/ghost
chown ghost /var/www/ghost
配置sudo权限
groupadd sudo
chown -R ghost:sudo /home/ghost/
chmod 775 /home/ghost/
usermod -aG sudo ghost
切换用户安装
su ghost
cd /var/www/ghost
ghost install local --db mysql
根据提示输入相关信息,即可
[ghost@ming ghost]$ ghost install local --db mysql
✔ Checking system Node.js version
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
☱ Downloading and installing Ghost v1.22.3 > Installing dependencies > [3/5] Fetching packages...
等得花儿都谢了,music...唱,跳,rab,篮球。。。。。
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
✔ Configuring Ghost
✔ Setting up instance
✔ Running database migrations
ℹ Ensuring user is not logged in as ghost user [skipped]
ℹ Checking if logged in user is directory owner [skipped]
✔ Checking current folder permissions
✔ Validating config
✔ Checking memory availability
✔ Starting Ghost
You can access your blog at http://localhost:2368/
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 ls
可以看到ghost现在是运行在开发模式development下,下面修改为生产模式
ghost stop
cp config.development.json config.production.json
在配置文件里面修改url,改成你自己的域名即可
vi config.production.json
"url": "http://www.pplibaby.com/" //例如本站的域名或者主机的ip地址
ghost start//重启ghost
使用以下命令切换到 root 用户
su root
添加 CentOS 7 Nginx yum 资源库:
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装Nginx
yum install -y nginx
启动Nginx
systemctl start nginx.service
将Nginx加入开机启动项
systemctl enable nginx.service
修改Nginx配置文件
cd /etc/nginx/conf.d/
vi ghost.conf
server {
listen 80;
server_name www.pplibaby.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
proxy_redirect default;
root /usr/share/nginx/html;
index index.html index.htm;
}
}
运行 nginx -s reload 重启 Nginx。
到此为止,一个属于你的个人博客就搭建成功啦
https://segmentfault.com/a/1190000014442264
https://cloud.tencent.com/developer/labs/search?keyword=ghost