Ghost¶
Requirements¶
This guide assumes that you already have the following set up prior to following these instructions:
- OpenLiteSpeed 1.4.41+
- MariaDB ( or another SQL server )
For more specific requirements for Ghost please see Ghost's documentation.
Install Node.js and Ghost-CLI¶
The commands in this section should be run on an elevated command prompt. If it is not elevated, be sure to use a sudo user and add the term sudo
before the commands.
Node.js¶
=== Ubuntu 20.04
apt-get install nodejs npm
Ghost-CLI¶
npm install -g ghost-cli@latest
Configure OpenLiteSpeed¶
This section requires you to be able to access the WebAdmin Console. It can usually be accessed by visiting port 7080
at your URL, like so: https://example.com:7080
.
Create a Virtual Host¶
Navigate to the Virtual Host tab and click the Add button.
Adjust the following settings:
- Virtual Host Name:
Ghost
- Virtual Host Root:
/home/ghost/app/
- Config File:
$SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
- Follow Symbolic Link:
Yes
- Enable Scripts/ExtApps:
Yes
- Restrained:
Yes
- suEXEC User:
demouser
- suEXEC Group:
demouser
Press the Save button.
If the specified Config File does not already exist, the program will prompt you to create it. Just click the CLICK TO CREATE
link, and press the Save button again.
Set the Document Root¶
Navigate to the newly created Virtual Host, go to the General tab and click Edit.
Set Document Root to /home/ghost/app/
and press the Save button.
Set up the App Server¶
Navigate to the Virtual Host and go to the Context tab. Click the Add button.
Select which type of context to create by setting Type to App Server
. Click the Next button.
Fill in the following settings:
- URI:
/
- Location:
/home/ghost/app/
- Binary Path:
/usr/bin/node
- Application Type:
Node
- Startup File:
current/index.js
- Run-time Mode:
Production
If you are using something other than the default Node.js path, be sure to change it to the path you want to use. Also, if you are going to run this in a mode other than Production
, be sure to change that as well. Once everything is set, click the Save button.
Set up the Listener¶
Navigate to the Listener tab.
Add the following Virtual Host Mappings for each listener you want Ghost to listen on:
- Virtual Host:
Ghost
- Domains:
ghost-ols.local
Be sure to replace ghost-ols.local
with the domain you plan on using for Ghost.
Install Ghost¶
This section assumes that you are in an elevated command prompt. If you are not in an elevated command prompt you may need to run sudo
before the commands listed.
Install MySQL¶
apt-get install mysql-server
mysql
# Now update your user with this command
# Replace 'password' with your password, but keep the quote marks!
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
quit
Add User¶
Ghost-CLI does not allow running as root, so we will need to create a Ghost-CLI user and add it to the sudoers
file. Be sure to use the same username as you set in SuExec User earlier.
adduser demouser
usermod -aG sudo demouser
Log in As User¶
Log in as the new Ghost user before proceeding.
su - demouser
Create Directory¶
Create the directory in which Ghost will be installed, and change to that directory.
mkdir -p /home/ghost/app/
cd /home/ghost/app/
Run Ghost-CLI¶
Ghost-CLI will do most of the installation for you. It will download the latest version and get it set up. Run the following to get started:
ghost install local
Begin setup:
ghost setup --no-setup-nginx --no-setup-systemd --no-setup-ssl --no-start
Answer the installation questions:
? Enter your blog URL: http://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_blog
Ghost was installed successfully! To complete setup of your publication, visit:
http://example.com/ghost/
Be sure to use your own login information for MySQL username/password.
Restart OpenLiteSpeed¶
Now that Ghost is installed and set up, restart OpenLiteSpeed so it can run the Node.js application:
systemctl restart lsws
Finished!¶
That's it! Navigate over to your browser and visit your site. You should see the following welcome screen:
To access the Ghost backend admin page, visit http://example.com/ghost
.
Caching Ghost with LiteSpeed Cache¶
In OpenLiteSpeed WebAdmin Console, navigate to Virtual Hosts > Context > App Server context and add the following to Rewrite Rules:
CacheLookup on
RewriteCond %{REQUEST_URI} !/ghost/
RewriteRule .* - [E=cache-control:max-age=120]
And with that, you have just enabled caching on your site. All pages that are not in the /ghost/
subdirectory, will be cached publicly for two minutes. You can learn more about caching without a plugin in the LSCache Without a Plugin documentation.
Further Configuration¶
For further configuration, please see Ghost's documentation.