5# Ghost (this site)
first we create a new jail
iocage create -n ghost.yourdomain.com -b -r 13.1-RELEASE
iocage set ip4_addr="em0|192.168.5.40/24" ghost.yourdomain.com
iocage set defaultrouter=192.168.5.10 ghost.yourdomain.com fire up the jail and install packages
#check ghost.org to see what latest version is supported of npm and mysql
pkg install vim-tiny mysql80-client node16 npm-node16 nginxupdate npm
npm update
npm install -g npm@8.13.0
npm install ghost-cli -gadd ghost user
adduser
#follow prompt, make sure user is not part of wheel group
mkdir /www/yourdomain.com
chown ghost:ghost /www/yourdomain.com
chmod 775 /www/yourdomain.com
cd /www/yourdomain.cominstall ghost
su - ghost
ghost install v5answer the questions accordingly
System checks failed with message: 'Operating system is not Linux'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? Yes
? Enter your blog URL: https://yourdomain.com/
? Enter your MySQL hostname: 192.168.5.30
? Enter your MySQL username: ghost
? Enter your MySQL password: mysupersecretpassword
? Enter your Ghost database name: yourdomain_com
? Do you wish to set up Systemd? No
? Do you want to start Ghost? Nofix permissions
$ chmod 600 /www/yourdomain.com/config.production.json
$ ghost startexit ghost user and configure nginx
my nginx config
#vim /usr/local/etc/nginx/nginx.conf
worker_processes 1;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost yourdomain.com www.yourdomain.com;
root /www/yourdomain.com/;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location /ghost/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368/ghost/;
allow 192.168.0.5; # allow traffic routed through HAproxy.
deny all;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
}start and enable nginx
service nginx enable
service nginx startSince the sql server is located elsewhere, we need to open a
we want to connect to the mysql server to test that the connection is working
CREATE USER 'ghost'@'192.168.5.40' IDENTIFIED BY 'mysupersecretpassword';
CREATE DATABASE yourdomain_com;
GRANT ALL privileges ON `yourdomain_com`.* TO 'ghost'@'192.168.5.40';then we test the connection from the ghost-jail:
mysql -u root -p -h 192.168.5.30 (ip to your mysql server)then configure ghost by editing config.prodction.json
{
"url": "https://yourdomain.com/",
"server": {
"port": 2368,
"host": "192.168.5.40"
},
"database": {
"client": "mysql",
"connection": {
"host": "192.168.5.30",
"user": "ghost",
"password": "mysupersecretpassword",
"database": "mysite_com"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "local",
"paths": {
"contentPath": "/www/mysite.com/content"
}
}that should be it. Log in to https://yourdomain.com/ghost/ and begin setup
We also want to add a service so the site doesn't go down if a reboot should happen.
#vim /usr/local/etc/rc.d/ghost
...
#!/bin/sh
# PROVIDE: ghost
# REQUIRE: mysql
# KEYWORD: shutdown
. /etc/rc.subr
name="ghost"
rcvar="ghost_enable"
extra_commands="status"
load_rc_config ghost
start_cmd="ghost_start"
stop_cmd="ghost_stop"
restart_cmd="ghost_restart"
status_cmd="ghost_status"
PATH=/bin:/usr/bin:/usr/local/bin:/home/ghost/.bin
ghost_start()
{
su ghost -c "/usr/local/bin/ghost start -d /www/yourdomain.com"
}
ghost_stop()
{
su ghost -c "/usr/local/bin/ghost stop -d /www/yourdomain.com"
}
ghost_restart()
{
ghost_stop;
ghost_start;
}
ghost_status()
{
su ghost -c "/usr/local/bin/ghost status -d /www/yourdomain.com"
}
run_rc_command "$1"Then fix the permissions
# chmod 755 /usr/local/etc/rc.d/ghost
# service ghost enable
# service ghost statusFinally: After configuring ghost, I want to install prism (for prettier codeblocks)
Start by downloading the current theme (casper), to your working computer. heading to settings -> design -> change theme -> advanced -> download
Then head over to https://prismjs.com/download
- After you select the options you think will fit your needs, download the generated script and style files.
- Place the files in the proper assets folders in your downloaded theme —
content/themes/theme-name/assets/js/prism.jsandcontent/themes/theme-name/assets/css/prism.css - Now what’s left to do is just include those files in your layout.
To do so, open content/themes/theme-name/default.hbs file and add <link> tag in the head for the style
{{! Styles'n'Scripts}}...<link rel="stylesheet" type="text/css" href="{{asset "css/prism.css"}}and a <script> tag before the closing <body> tag
...
<script type="text/javascript" src="{{asset "js/prism.js"}}></script>
</body>Finally, rename your theme by editing package.json
{
"name": "casper+prism",
....
change the name of the zip-file casper_prism.zip and upload it to your webserver and activate it
thanks to medium.com , Blake Hartshorn and ghost.org for input to this post