How to publish Ghost on AWS?

by tressie.damore , in category: Third Party Scripts , a year ago

How to publish Ghost on AWS?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by domenico , a year ago

@tressie.damore 

To publish a Ghost blog on AWS, you can follow these steps:

  1. Set up an Amazon EC2 instance: Log in to your AWS Management Console. Go to the EC2 service and click on "Launch Instance." Choose an Amazon Machine Image (AMI) from the available options. Select the desired instance type, storage, and other configurations. Configure security groups and key pairs for SSH access. Launch the instance.
  2. Connect to your EC2 instance: Once the instance is up and running, connect to it using SSH. Retrieve the public IP address or DNS name of the instance from the EC2 Management Console. Open your terminal or SSH client and connect to the instance using the following command: ssh -i your_key.pem ubuntu@your_public_IP
  3. Install and configure Nginx: Update the server packages by running the following commands: sudo apt update sudo apt upgrade -y Install Nginx: sudo apt install nginx -y Start and enable Nginx: sudo systemctl start nginx sudo systemctl enable nginx
  4. Install Node.js: Add the Node.js repository to your package manager: curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - Install Node.js: sudo apt install nodejs -y
  5. Install and configure MySQL database: Install MySQL server: sudo apt install mysql-server -y Secure your installation: sudo mysql_secure_installation Create a new user and database for Ghost: sudo mysql CREATE DATABASE ghost; GRANT ALL ON ghost.* TO 'ghostuser'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; EXIT;
  6. Download and install Ghost: Create a new directory for your blog: sudo mkdir /var/www/ghost Change the ownership of the directory: sudo chown -R ubuntu:ubuntu /var/www/ghost Download the latest version of Ghost: cd /var/www/ghost wget https://ghost.org/zip/ghost-latest.zip Unzip the downloaded file: unzip ghost-latest.zip Install Ghost: cd ghost sudo npm install --production Configure Ghost by copying the example config file and editing it: cp config.production.example.js config.production.js sudo nano config.production.js
  7. Start Ghost using pm2 process manager: Install pm2 globally: sudo npm install -g pm2 Start Ghost with pm2: NODE_ENV=production pm2 start index.js --name "ghost" Set pm2 to start at system boot: pm2 save sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
  8. Configure Nginx as a reverse proxy: Create a new Nginx server block: sudo nano /etc/nginx/sites-available/ghost Add the following configuration to the file: server { listen 80; server_name your-domain.com; location / { proxy_pass http://127.0.0.1:2368; proxy_set_header Host $host; proxy_buffering off; } } Enable the new server block: sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/ Test the Nginx configuration: sudo nginx -t Restart Nginx: sudo systemctl restart nginx
  9. Set up DNS for your domain: Go to your domain registrar or DNS provider and configure a DNS record to point to your EC2 instance's IP address.
  10. Access your Ghost blog: Open a web browser and visit your domain to access your Ghost blog.


That's it! Your Ghost blog is now published on AWS using Nginx as a reverse proxy. You can further customize Ghost settings and themes according to your preferences.