Prerequisite
This page will install Ghost, Grave, Wordpress, Webmin, PhpMyAdmin with Nginx on Debian/Ubuntu. 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 -yInstall NodeJs, npm
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - $ sudo apt install nodejs -y $ node --version $ npm --versionInstall UFW
$ sudo apt install ufw -y $ sudo ufw allow ssh $ sudo ufw allow http $ sudo ufw allow https $ sudo ufw enable
Install DB
$ apt install mariadb-server mariadb-client -y $ systemctl start mariadb $ systemctl status mariadb $ systemctl enable mariadb $ sudo mysql_secure_installation
Install Nginx
$ sudo apt install nginx -y $ sudo systemctl start nginx $ sudo systemctl enable nginx $ sudo nano /etc/nginx/sites-enabled/default -------------------------------------------- server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; } }
Install Webmin
$ sudo chown www-data:www-data /var/www/html $ curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh $ sh setup-repos.sh $ apt -y install webmin --install-recommends ( change port: $ sudo nano -w /etc/webmin/miniserv.conf )
Install Ghost
$ 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
Install PHP
$ sudo apt -y install php php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-fpm php-json php-imap php-mbstring php-opcache php-soap php-dev php-cgi php-zip php-intl php-bcmath php-pear $ sudo apt -y install libmcrypt-dev libreadline-dev mcrypt zip unzip php-zip php-tokenizer
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
Install Grav
$ cd /var/www/html $ sudo wget https://getgrav.org/download/core/grav-admin/1.7.48 $ sudo unzip 1.7.48 $ sudo mv grav-admin grav $ sudo chown -R www-data:www-data /var/www/html/grav $ sudo nano /etc/nginx/conf.d/grav.conf server { listen 80; server_name grav.example.com; root /var/www/html/grav; index index.html index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; } location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; } } $ sudo nginx -t $ sudo systemctl restart nginx $ sudo systemctl status nginx If any issues with the scheduler in Grav, run the following command: $ sudo crontab -u www-data -e And add this line to the bottom of the file: cd /var/www/html/grav;/usr/bin/php bin/grav scheduler 1>> /dev/null 2>&1
Install WordPress
$ curl -L -O http://wordpress.org/latest.tar.gz $ tar xf latest.tar.gz $ mv wordpress/* /var/www/html/domain $ nano /etc/nginx/sites-available/domain.conf server { listen 80; server_name domain.com; root /var/www/html/domain; index index.php index.html; location / { index index.php index.html index.htm; try_files $uri $uri/ =404; } location ~* \.php$ { fastcgi_pass unix:/run/php/php8.2-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; include snippets/fastcgi-php.conf; } } $ ln -s /etc/nginx/sites-available/domain.conf /etc/nginx/sites-enabled/ $ sudo nginx -t $ systemctl restart nginx $ cp /var/www/html/domain/wp-config-sample.php /var/www/html/domain/wp-config.php $ nano /var/www/html/domain/wp-config.php Insert db name, passwd, localhost $ chown -R www-data:www-data /var/www/html/domain $ chmod -R 755 /var/www/html/domain $ sudo rm /etc/nginx/sites-enabled/default $ sudo rm /etc/nginx/sites-available/default $ sudo nginx -t http://domain1.com
OR
$ wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz $ tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html $ chown -R www-data:www-data /var/www/html/wordpress $ chmod -R 755 /var/www/html/wordpress Create a Virtual Host (Server Blocks) for WordPress website on the Nginx server. $ nano /etc/nginx/conf.d/wordpress.conf Add the content to file. server { listen 80; listen [::]:80; server_name website1.com; root /var/www/html/wordpress; index index.php index.html index.htm; error_log /var/log/nginx/wordpress_error.log; access_log /var/log/nginx/wordpres_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; } } $ sudo nginx -t $ systemctl restart nginx
Install Composer
$ curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer $ sudo chmod +x /usr/local $ bin/composer $ composer $ sudo nginx -t $ sudo systemctl reload nginx