Skip to content

KasraK2K/go-ecommerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Useful Documentation



This is not full documentation but in here I explain most useful things that you cant see in the code, and it's necessary.

I hope it will be useful for you.

Deploy Go on linux server


For deploy go on linux server do these steps:

  1. Build your app with necessary environments:
env GOOS=linux CGO_ENABLED=0 go build -o blog ./cmd/api

  1. Create a systemd job file:
touch /etc/systemd/system/blog.service

  1. Copy these code into blog.service file:
Description= instance to serve blog api
After=network.target

[Service]
Environment="MODE=production"
User=root
Group=www-data
ExecStart=<Path of your builded go file>
[Install]
WantedBy=multi-users.target

NOTE: As you can see this file created with production mode environment


  1. Start service:
sudo systemctl start blog

  1. Check service status:
sudo systemctl enable blog

  1. Create blog config for nginx:
touch /etc/nginx/sites-available/blog

  1. Copy these codes into blog config file:
server {
    server_name .com;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_pass http://localhost:<Port Number>;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    listen 80;
    listen [::]:80;
}

  1. Create soft link for sites-enables:
sudo ln -s /etc/nginx/sites-available/blog /etc/nginx/sites-enabled

  1. Restart nginx:
sudo systemctl restart nginx

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages