Knowledgebase

Setting up Ghost Professional Publishing Platform on OpenBSD Print

  • 0

Ghost is the latest and greatest upstart to rival WordPress. Theme development is quick and easy to learn because the Ghost developers decided to use both the ember.js and handlebars.js frameworks to remove some of the learning curve. The install and setup time should take approximately 45-60 minutes and makes use of the following technologies: Node.js, Relayd, and Httpd.

Note: Please replace example.org with your domain name and 192.0.2.x with your assigned Rcs IP address. We will also be using self-signed certificates which are really good for testing only. If you decide to use Ghost in production, it is extremely important to be using a real certificate. Real certificates can be obtained for free using Let's Encrypt.

Configuring OpenBSD

Enable Httpd and relayd.

# rcctl enable httpd relayd
	

Create the /etc/httpd.conf configuration file for Httpd. In this example, the only purpose of Httpd is to redirect requests to https. Relayd will actually be the one listening on the https port and proxying requests to Ghost.

prefork 3
types { include "/usr/share/misc/mime.types" }

server "www.example.org" {
	listen on 192.0.2.1 port 80 
	# Redirect to https
	block return 301 "https://$SERVER_NAME:$REQUEST_URI"
}

Create the testing SSL certificates for your Ghost deployment. Since this will only really be for testing, you can leave most of the fields blank. The only one that you will need to complete is the Common Name field and that should match the fully-qualified domain name of the server. When you are ready to replace the self-signed certificate with ones that are true and valid, just remember to keep the file names the same. Relayd expects to find its key and certificate with the naming convention <ip address>.crt and <ip address>.key.

# cd /etc/ssl
# openssl req -x509 -new -nodes -newkey rsa:4096 -keyout private/192.0.2.1.key -out 192.0.2.1.crt -days 364 -sha256
# chmod 0400 private/192.0.2.1.key
    

Create the /etc/relayd.conf configuration file for Relayd. Relayd does the magic that proxies and redirects requests to Ghost.

prefork 3

http protocol https {
	match request header append "X-Forwarded-For" value "$REMOTE_ADDR"
	match request header append "X-Forwarded-By" \
		value "$SERVER_ADDR:$SERVER_PORT"

	tcp { nodelay, sack, socket buffer 65536, backlog 128 }

	tls { no tlsv1, ciphers HIGH }
	tls no session tickets
}
relay ghost {
	listen on 192.0.2.1 port 443 tls
	protocol https
	forward to 127.0.0.1 port 2368
}

Add the following packages. pkg_add -r node unzip wget

Install and Configure Ghost

Create a user and home directory for the Ghost installation. For example, create a user named ghost with a home directory called /var/www/ghost. Use a very strong password for this account.

# user add -m -c "Ghost User" -d /var/www/ghost -G wheel -g =uid -u 5000 -s /bin/ksh ghost
# passwd ghost 
	

Change to the ghost user and download the latest version of Ghost.

# doas su ghost
# cd /var/www/ghost
# mkdir blog
# cd blog/
# wget https://ghost.org/zip/ghost-latest.zip
# unzip ghost-latest.zip

Install Ghost.

# npm install sqlite3 --sqlite=/usr/local
# npm install --production
# npm install forever
# doas npm install -g knex-migrator

Configure Ghost. Replace the database section of config.production.json with the database clause below if you would like to use sqlite instead of mysql. Sqlite will easily handle about 100,000 connections a day. If you already have MySQL installed, you can always choose to use it instead. For the defaults.json file, change the domain part of the url to your domain.

# cd core/server/config/env/config/
# vi config.production.json

"database": {
	"client": "sqlite3",
	"connection": {
			"filename": "content/data/ghost.db"
	}, 

# cd core/server/config/
# vi defaults.json

"url": "http://www,example.org",
"server": {
		"host": "127.0.0.1",
		"port": 2368
},

Now we have to populate the database and start Ghost.

# cd ~/blog
# NODE_ENV=production knex-migrator init
# NODE_ENV=production ~/blog/node_modules/forever/bin/forever start ~/blog/index.js

Perform a netstat -na -f inet and look for a 127.0.0.1:2368 entry. You can also do a ps ax | grep node to verify that Ghost is running.

Open your favorite web browser and browse to http://www.example.org. You will automatically be redirected to https://www.example.org. You will be greeted with the default Ghost page.

Browse to http://www.example.org/ghost to finish the installation.

Ghost is the latest and greatest upstart to rival WordPress. Theme development is quick and easy to learn because the Ghost developers decided to use both the ember.js and handlebars.js frameworks to remove some of the learning curve. The install and setup time should take approximately 45-60 minutes and makes use of the following technologies: Node.js, Relayd, and Httpd. Note: Please replace example.org with your domain name and 192.0.2.x with your assigned Rcs IP address. We will also be using self-signed certificates which are really good for testing only. If you decide to use Ghost in production, it is extremely important to be using a real certificate. Real certificates can be obtained for free using Let's Encrypt. Configuring OpenBSD Enable Httpd and relayd. # rcctl enable httpd relayd Create the /etc/httpd.conf configuration file for Httpd. In this example, the only purpose of Httpd is to redirect requests to https. Relayd will actually be the one listening on the https port and proxying requests to Ghost. prefork 3 types { include "/usr/share/misc/mime.types" } server "www.example.org" { listen on 192.0.2.1 port 80 # Redirect to https block return 301 "https://$SERVER_NAME:$REQUEST_URI" } Create the testing SSL certificates for your Ghost deployment. Since this will only really be for testing, you can leave most of the fields blank. The only one that you will need to complete is the Common Name field and that should match the fully-qualified domain name of the server. When you are ready to replace the self-signed certificate with ones that are true and valid, just remember to keep the file names the same. Relayd expects to find its key and certificate with the naming convention .crt and .key. # cd /etc/ssl # openssl req -x509 -new -nodes -newkey rsa:4096 -keyout private/192.0.2.1.key -out 192.0.2.1.crt -days 364 -sha256 # chmod 0400 private/192.0.2.1.key Create the /etc/relayd.conf configuration file for Relayd. Relayd does the magic that proxies and redirects requests to Ghost. prefork 3 http protocol https { match request header append "X-Forwarded-For" value "$REMOTE_ADDR" match request header append "X-Forwarded-By" \ value "$SERVER_ADDR:$SERVER_PORT" tcp { nodelay, sack, socket buffer 65536, backlog 128 } tls { no tlsv1, ciphers HIGH } tls no session tickets } relay ghost { listen on 192.0.2.1 port 443 tls protocol https forward to 127.0.0.1 port 2368 } Add the following packages. pkg_add -r node unzip wget Install and Configure Ghost Create a user and home directory for the Ghost installation. For example, create a user named ghost with a home directory called /var/www/ghost. Use a very strong password for this account. # user add -m -c "Ghost User" -d /var/www/ghost -G wheel -g =uid -u 5000 -s /bin/ksh ghost # passwd ghost Change to the ghost user and download the latest version of Ghost. # doas su ghost # cd /var/www/ghost # mkdir blog # cd blog/ # wget https://ghost.org/zip/ghost-latest.zip # unzip ghost-latest.zip Install Ghost. # npm install sqlite3 --sqlite=/usr/local # npm install --production # npm install forever # doas npm install -g knex-migrator Configure Ghost. Replace the database section of config.production.json with the database clause below if you would like to use sqlite instead of mysql. Sqlite will easily handle about 100,000 connections a day. If you already have MySQL installed, you can always choose to use it instead. For the defaults.json file, change the domain part of the url to your domain. # cd core/server/config/env/config/ # vi config.production.json "database": { "client": "sqlite3", "connection": { "filename": "content/data/ghost.db" }, # cd core/server/config/ # vi defaults.json "url": "http://www,example.org", "server": { "host": "127.0.0.1", "port": 2368 }, Now we have to populate the database and start Ghost. # cd ~/blog # NODE_ENV=production knex-migrator init # NODE_ENV=production ~/blog/node_modules/forever/bin/forever start ~/blog/index.js Perform a netstat -na -f inet and look for a 127.0.0.1:2368 entry. You can also do a ps ax | grep node to verify that Ghost is running. Open your favorite web browser and browse to http://www.example.org. You will automatically be redirected to https://www.example.org. You will be greeted with the default Ghost page. Browse to http://www.example.org/ghost to finish the installation.

Was this answer helpful?
Back

Powered by WHMCompleteSolution