安裝go
參考 https://blog.csdn.net/liangguangchuan/article/details/51249360
安裝hugo
官方安裝指南https://gohugo.io/getting-started/installing/
CentOS需要參考https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/
該網站只有CentOS7的安裝指南,CentOS6需要自己推
表中CentOS7 epel repo信息在
https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/repo/epel-7/daftaupe-hugo-epel-7.repo
推算CentOS6 epel repo信息在
https://copr.fedorainfracloud.org/coprs/daftaupe/hugo/repo/epel-6/daftaupe-hugo-epel-6.repo
根據所得的設置
添加epel repo
vim /etc/yum.repos.d/hugo.repo
其中內容如下
[daftaupe-hugo]
name=Copr repo for hugo owned by daftaupe
baseurl=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/epel-6-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/daftaupe/hugo/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
保存
執行yum -y install hugo
執行hugo version
就安裝成功
配置hugo(本地可訪問)
參考https://gohugo.io/getting-started/quick-start/
在本地打開firefox,輸入http://localhost:1313可以訪問
配置hugo(遠程也可訪問)
假定遠程訪問地址 http://222.222.222.222:1313
打開防火牆端口
iptables -A INPUT -p tcp --dport 1313 -j ACCEPT
檢查內存防火牆設置
iptables --list
如果沒有問題,先備份原來的防火牆文件
cp /etc/sysconfig/iptables /etc/sysconfig/iptables.20180724
保存內存防火牆設置到文件
service iptables save > /etc/sysconfig/iptables
防火牆重啓
service iptables restart
修改網站配置
進入quickstart項目目錄
vim config.toml
修改其中baseUrl
baseURL = "http://222.222.222.222:1313"
保存
重新啓動網站
如果網站已在某終端啓動,找到該終端,執行Ctrl+C
再啓動網站,執行
hugo server --bind=0.0.0.0 --baseURL=http://222.222.222.222 --port=1313 -D
注意由於阿里雲ECS服務器的特殊網卡設置,--bind=222.222.222.222
會報錯bind: cannot assign requested address
, 需要寫成--bind=0.0.0.0
參考 https://discourse.gohugo.io/t/hugo-server-cant-select-any-port-v0-38/11341
進階配置指南
建一個靜態電子商務網站,參考https://snipcart.com/blog/hugo-tutorial-static-site-ecommerce