Check sourcelist first, make sure it has backports; $ sudo apt update && sudo apt upgrade -y $ sudo apt install curl software-properties-common apt-transport-https ca-certificates gnupg2 -y
Install NodeJs, npm
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
$ sudo apt install nodejs -y
$ node --version
$ npm --version
$ adduser nginx
$ adduser nginx sudo
$ su - nginx
$ exit
$ sudo mysql -u root -p
CREATE DATABASE ghostbuster;
CREATE USER 'ghostadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON ghostbuster.* TO 'ghostadmin'@'localhost';
FLUSH PRIVILEGES;
EXIT;
$ sudo mkdir -p /var/www/html/ghost
$ sudo chown www-data:www-data /var/www/html/ghost
$ chmod 775 /var/www/html/ghost // do this x3 or go to webmin
Install Ghost-Cli
$ sudo su - nginx
$ sudo npm install ghost-cli@latest -g
$ ghost --version
$ cd /var/www/html/ghost
---- > ghost install
Blog URL (e.g., https://yourdomain.com)
MySQL hostname (localhost)
MySQL username and password (created earlier)
Ghost database name (ghostdb)
The installer will set up Ghost and its dependencies automatically.
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php* postfix
Belows are already installed by Ghost installer, but in case.
Configuring Nginx for Ghost
$ sudo nano /etc/nginx/sites-available/ghost.conf
server {
listen 80;
server_name yourdomain.com;
root /var/www/html/ghost;
index index.php index.html index.htm;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
client_max_body_size 50m;
}
$ sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl restart nginx
============================================
Securing Ghost with SSL/TLS
$ sudo apt install certbot python3-certbot-nginx -y
$ sudo certbot --nginx -d yourdomain.com
================================================
$ ghost start # Start Ghost
$ ghost stop # Stop Ghost
$ ghost restart # Restart Ghost
$ ghost status # Check Ghost status
$ sudo systemctl enable ghost_yourdomain-com
=================================================
Troubleshooting Common Issues
1. Permission Problems
$ sudo chown -R nginx:nginx /var/www/ghost
$ sudo find /var/www/html/ghost -type d -exec chmod 775 {} \;
$ sudo find /var/www/html/ghost -type f -exec chmod 664 {} \;
2. Database Connection Issues
sudo systemctl status mysql
$ mysql -u ghostadmin -p -e "USE ghostbuster; SHOW TABLES;"
3. Nginx Configuration Errors
$ sudo tail -f /var/log/nginx/error.log
$ sudo nginx -t
$ sudo mkdir -p /var/www/html/domain
$ wget https://github.com/flatpressblog/flatpress/archive/1.3.1.zip
$ unzip flatpress-1.3.1.zip
$ mv flatpress-1.3.1/* /var/www/html/domain
$ chown -R www-data:www-data /var/www/html/domain
$ chmod -R 775 /var/www/html/domain
$ nano /etc/nginx/conf.d/domain.conf
server {
listen 80;
server_name domain.com;
root /var/www/html/domain;
index index.php index.html index.htm;
error_log /var/log/nginx/domain_error.log;
access_log /var/log/nginx/domain_access.log;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
$ nginx -t
$ systemctl reload nginx
http://domain1.com