Ghost: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
==Installation== | ==Installation== | ||
First install mysql | First install mysql | ||
< | <pre>apt-get install mysql-server</pre> | ||
Open mysql and set a password for root | Open mysql and set a password for root | ||
< | <pre>mysql -u root | ||
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';</ | ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; | ||
</pre> | |||
And put the password in '''/root/.my.cnf''' | And put the password in '''/root/.my.cnf''' | ||
Install postfix | Install postfix | ||
< | <pre>apt-get install mailutils</pre> | ||
Install Node.js | Install Node.js | ||
< | <pre>curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash | ||
apt-get install -y nodejs</ | apt-get install -y nodejs | ||
</pre> | |||
Install Ghost-CLI | Install Ghost-CLI | ||
< | <pre>npm install ghost-cli@latest -g | ||
</pre> | |||
Install Ghost | Install Ghost | ||
< | <pre> | ||
mkdir -p /var/www/sitename | |||
chown <user>:<user> /var/www/sitename | chown <user>:<user> /var/www/sitename | ||
chmod 775 /var/www/sitename | chmod 775 /var/www/sitename | ||
cd /var/www/sitename | cd /var/www/sitename | ||
ghost install</ | ghost install | ||
</pre> | |||
Instalation questions: | Instalation questions: | ||
Line 41: | Line 46: | ||
Edit '''/var/www/blog/config.production.json''' to make it listen on the VM's IP instead of just local | Edit '''/var/www/blog/config.production.json''' to make it listen on the VM's IP instead of just local | ||
< | <pre> "server": { | ||
"port": 2368, | "port": 2368, | ||
"host": "0.0.0.0" | "host": "0.0.0.0" | ||
},</ | },</pre> | ||
Edit the same file and configure ghost to use the local SMTP server to send emails | Edit the same file and configure ghost to use the local SMTP server to send emails | ||
< | <pre> | ||
"mail": { | |||
"transport": "SMTP", | "transport": "SMTP", | ||
"options": { | "options": { | ||
Line 56: | Line 62: | ||
} | } | ||
} | } | ||
},</ | }, | ||
</pre> | |||
Restart the ghost service | Restart the ghost service | ||
< | <pre>systemctl restart ghost_blog-oxfordarchaeology-com.service</pre> | ||
On the proxy point the domain to port 2368 instead of the default 80/443. The proxy vhost should look like this: | On the proxy point the domain to port 2368 instead of the default 80/443. The proxy vhost should look like this: | ||
< | <pre> | ||
<VirtualHost *:443> | |||
ServerName blog.oxfordarchaeology.com | ServerName blog.oxfordarchaeology.com | ||
Line 82: | Line 90: | ||
SSLCertificateKeyFile /etc/letsencrypt/live/blog.oxfordarchaeology.com/privkey.pem | SSLCertificateKeyFile /etc/letsencrypt/live/blog.oxfordarchaeology.com/privkey.pem | ||
Include /etc/letsencrypt/options-ssl-apache.conf | Include /etc/letsencrypt/options-ssl-apache.conf | ||
</VirtualHost></ | </VirtualHost> | ||
</pre> | |||
Now you can go to the link provided by the ghost installer at the end and finish the installation on the web interface | Now you can go to the link provided by the ghost installer at the end and finish the installation on the web interface | ||
Line 90: | Line 99: | ||
Here are the steps (taken from [https://ghost.org/docs/migration/ghost/ here]): | Here are the steps (taken from [https://ghost.org/docs/migration/ghost/ here]): | ||
* Make sure the new server is updated and has ghost installed to the latest version | * Make sure the new server is updated and has ghost installed to the latest version | ||
* Run < | * Run <pre>ghost backup</pre> on the source server. | ||
* Run < | * Run <pre>ghost doctor</pre> to make sure everything checks out before you start to migrate data. | ||
* Navigate to the '''Labs''' view, and click '''Export''' to download the content archive | * Navigate to the '''Labs''' view, and click '''Export''' to download the content archive | ||
* Staying on the '''Labs''' page, click '''Download current redirects''' | * Staying on the '''Labs''' page, click '''Download current redirects''' | ||
Line 98: | Line 107: | ||
* Navigate to the '''Design''' view, open the '''Advanced''' tab to see all themes and click the '''Download''' button next to the Active label. This will export your current theme. | * Navigate to the '''Design''' view, open the '''Advanced''' tab to see all themes and click the '''Download''' button next to the Active label. This will export your current theme. | ||
* To download your images, you’ll need shell access to your server. | * To download your images, you’ll need shell access to your server. | ||
< | <pre>cd /var/www/ghost/content</pre> | ||
< | <pre>zip -r images.zip images/*</pre> | ||
Ensure your images folder only contains images. Any other file types may cause import errors. | Ensure your images folder only contains images. Any other file types may cause import errors. | ||
* Now go to the new server and do the steps in the same order: | * Now go to the new server and do the steps in the same order: | ||
Line 108: | Line 118: | ||
* Head over to the '''Design''' view, and click '''Upload a theme''', select your theme .zip file, and '''activate it'''. | * Head over to the '''Design''' view, and click '''Upload a theme''', select your theme .zip file, and '''activate it'''. | ||
* The final step is to upload the images by unzipping the archive into content folder on the new server | * The final step is to upload the images by unzipping the archive into content folder on the new server | ||
< | <pre>cd /var/www/ghost/content</pre> | ||
< | <pre>unzip images.zip</pre> |
Latest revision as of 08:37, 8 December 2022
Installation
First install mysql
apt-get install mysql-server
Open mysql and set a password for root
mysql -u root ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
And put the password in /root/.my.cnf
Install postfix
apt-get install mailutils
Install Node.js
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash apt-get install -y nodejs
Install Ghost-CLI
npm install ghost-cli@latest -g
Install Ghost
mkdir -p /var/www/sitename chown <user>:<user> /var/www/sitename chmod 775 /var/www/sitename cd /var/www/sitename ghost install
Instalation questions:
- Blog URL: http://blog.oxfordarchaeology.com (NOTE: I've used http because the encryption is done one the proxy, otherwise it will end up in a redirect loop)
- MySQL hostname: localhost
- MySQL username / password: root and password (NOTE: it will use the root only to create a DB and a user with rights for that DB)
- Ghost database name: blog
- Set up a ghost MySQL user?: yes
- Set up NGINX?: no (NOTE: nginx will be used to proxy pass to the ghost port, but since we already have a proxy no need to use nginx)
- Set up SSL?: no (SSL is handled on the proxy)
- Set up systemd?: yes
- Start Ghost?: yes
The installer will give you a link to visit so you can finish the installation, but hold on that just a bit.
Edit /var/www/blog/config.production.json to make it listen on the VM's IP instead of just local
"server": { "port": 2368, "host": "0.0.0.0" },
Edit the same file and configure ghost to use the local SMTP server to send emails
"mail": { "transport": "SMTP", "options": { "hosts": "127.0.0.1", "port": 25, "tls": { "rejectUnauthorized": false } } },
Restart the ghost service
systemctl restart ghost_blog-oxfordarchaeology-com.service
On the proxy point the domain to port 2368 instead of the default 80/443. The proxy vhost should look like this:
<VirtualHost *:443> ServerName blog.oxfordarchaeology.com ProxyPreserveHost On RequestHeader set X-Forwarded-Proto "https" <Location /> SSLRequireSSL </Location> ProxyPass / http://192.168.98.85:2368/ ProxyPassReverse / http://192.168.98.85:2368/ CustomLog /var/log/apache2/blog.oxfordarchaeology.access.log combined ErrorLog /var/log/apache2/blog.oxfordarchaeology.error.log SSLCertificateFile /etc/letsencrypt/live/blog.oxfordarchaeology.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/blog.oxfordarchaeology.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost>
Now you can go to the link provided by the ghost installer at the end and finish the installation on the web interface
Migration
In case we need to move ghost to a different server, for example if updating fails, it may be easier and optimal to simply migrate it to a fresh install. Here are the steps (taken from here):
- Make sure the new server is updated and has ghost installed to the latest version
- Run
ghost backup
on the source server. - Run
ghost doctor
to make sure everything checks out before you start to migrate data. - Navigate to the Labs view, and click Export to download the content archive
- Staying on the Labs page, click Download current redirects
- Download current routes.yaml
- Navigate to Members, click on the cog at top right and select Export all members, save the file somewhere.
- Navigate to the Design view, open the Advanced tab to see all themes and click the Download button next to the Active label. This will export your current theme.
- To download your images, you’ll need shell access to your server.
cd /var/www/ghost/content
zip -r images.zip images/*
Ensure your images folder only contains images. Any other file types may cause import errors.
- Now go to the new server and do the steps in the same order:
- Navigate to the Labs view. Next to the Import content header, select your content .json file and click Import
- Staying on the Labs view, click Upload redirects JSON, then select your redirects.json file to upload it.
- Then click Upload routes YAML
- Navigate to Members, click on the cog at top right and select Import members. Upload the file you exported earlier from the source.
- Head over to the Design view, and click Upload a theme, select your theme .zip file, and activate it.
- The final step is to upload the images by unzipping the archive into content folder on the new server
cd /var/www/ghost/content
unzip images.zip