Submitted by Chris McIntosh on July 7, 2024

If you're looking to set up a cheap, easy-to-manage hosting solution for static or MEAN stack sites, Portainer on a VPS from A2 Hosting is a great choice. Portainer is a lightweight management UI that allows you to easily manage your Docker environments. Here's a step-by-step guide to get you started.

Step 1: Choosing the Right VPS from A2 Hosting

  1. Visit A2 Hosting VPS Plans: Go to A2 Hosting Unmanaged VPS.

  2. Select a Plan: Choose a plan that fits your needs. For basic static or MEAN stack sites, a lower-tier plan should suffice.

Step 2: Setting Up Your VPS

Once you have your VPS, you'll need to set it up and ensure it's ready for Docker and Portainer.

  1. Access Your VPS: Use SSH to log into your VPS. You can use a terminal on Linux/Mac or an SSH client like PuTTY on Windows.

    ssh root@your_vps_ip
  2. Update Your System:

    apt update && apt upgrade -y

Step 3: Installing Docker

Docker is required for running Portainer. Follow these steps to install Docker on your VPS.

  1. Install Docker:

    apt install docker.io -y
  2. Enable and Start Docker:

    systemctl enable docker
    systemctl start docker
  3. Verify Docker Installation:

    docker --version

Step 4: Installing Portainer

Now that Docker is installed, you can proceed to install Portainer.

  1. Pull the Portainer Image:

    docker pull portainer/portainer-ce
  2. Create the Portainer Volume:

    docker volume create portainer_data
  3. Run Portainer:

    docker run -d -p 8000:8000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  4. Access Portainer: Open your browser and go to https://your_vps_ip:9443. You’ll be prompted to create an admin user.

Step 5: Deploying Static or MEAN Stack Sites

With Portainer set up, you can now deploy your static or MEAN stack sites.

  1. Create a New Stack in Portainer:

    • Go to the Portainer dashboard.
    • Select "Stacks" and then "Add stack".
    • Name your stack and define your docker-compose.yml for your static site or MEAN stack site.
  2. Example Docker Compose for a Static Site:

    version: '3'
    services:
      web:
        image: nginx:alpine
        volumes:
          - ./html:/usr/share/nginx/html
        ports:
          - "80:80"
  3. Example Docker Compose for a MEAN Stack Site:

    version: '3'
    services:
      web:
        image: node:14
        working_dir: /app
        volumes:
          - ./:/app
        command: npm start
        ports:
          - "3000:3000"
      mongo:
        image: mongo:latest
        ports:
          - "27017:27017"
  4. Deploy the Stack: Once you have your docker-compose.yml defined, deploy the stack.

Step 6: Managing Your Site with Portainer

Portainer provides a user-friendly interface to manage your Docker containers. You can:

  • Start, stop, and restart containers.
  • View logs and stats.
  • Manage volumes and networks.
  • Use the console to interact with containers.

Additional Resources

By following these steps, you'll have a powerful and cost-effective hosting solution for your static or MEAN stack sites using A2 Hosting and Portainer. Enjoy the ease of managing your Docker environments with Portainer's intuitive UI!