- NOTE: This guide assumes you already have some knowledge on how to navigate an Ubuntu linux server
- Install Golang
- Install nginx for reverse proxy
- Install supervisor to load your site
cd ~/go/src
git clone http://github.com/user/repo
cd your_git_folder
- Build site executable
go build -o site_executable_name cmd/web/*.go
-
Create config
cd /etc/nginx/sites-available
sudo nano *config_name*
- Fill the file with this base config:
server { listen 80; listen [::]:80; listen 443; server_name example.example.com; location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
- Change
example.example.com
to your domain - Change
8080
to your port - Save and exit
ctrl+x
,y
,enter
-
Link the file to sited-enabled
sudo ln -s /etc/nginx/sites-available/config_name /etc/nginx/sites-enabled/config_name
-
Test the config
sudo service nginx configtest
-
Restart nginx
sudo service nginx restart
-
Create config
cd /etc/supervisor/conf.d
sudo nano name.conf
- Fill the file with this base config:
[program:example_name] directory=/home/youruser/go/src/site_folder command=/home/youruser/go/src/site_folder/site_executable_name autorestart=true user=youruser redirect_stderr=true stdout_logfile=/home/youruser/logs/site.log stdout_logfile_maxbytes=50MB startretries=3 startsecs=0
- Replace the following parameters
example_name
youruser
site_folder
site_executable_name
- Save and exit
ctrl+x
,y
,enter
-
sudo supervisorctl reread
-
sudo supervisorctl update
-
sudo supervisorctl restart program_name
Hopefully everything will work with this
Good luck!