简体   繁体   中英

fresh install gogs panic after setup with mkdir data: permission denied

Here just checking out gogs, I followed a tutorial to setup gogs behind apache. I was able to see the install page, ran install successfully. But unable to go past that step, as I don't see a login page for gogs. terminal shows below error

[Macaron] 2020-03-03 16:48:29: Completed GET / 500 Internal Server Error in 743.184µs
[Macaron] 2020-03-03 16:48:29: Started GET /favicon.ico for 10.108.23.170
[Macaron] PANIC: session(start): mkdir data: permission denied
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/session/session.go:162 (0x9bae70)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:79 (0x963b80)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:157 (0x934080)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:135 (0x933daa)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:121 (0x963cd9)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:112 (0x976b1f)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/recovery.go:161 (0x976b0d)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/logger.go:40 (0x967973)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:157 (0x934080)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:135 (0x933daa)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:121 (0x963cd9)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:112 (0x975e40)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/logger.go:52 (0x975e2b)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/logger.go:40 (0x967973)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:157 (0x934080)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/github.com/go-macaron/inject/inject.go:135 (0x933daa)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/context.go:121 (0x963cd9)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/router.go:187 (0x977d66)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/router.go:303 (0x970405)
/home/vagrant/gopath/src/github.com/gogs/gogs/vendor/gopkg.in/macaron.v1/macaron.go:220 (0x968d4c)
/usr/local/go/src/net/http/server.go:2774 (0x74a9c7)
/usr/local/go/src/net/http/server.go:1878 (0x7466b0)
/usr/local/go/src/runtime/asm_amd64.s:1337 (0x466190)
[Macaron] 2020-03-03 16:48:29: Completed GET /favicon.ico 500 Internal Server Error in 649.106µs

I have setup the directory/permissions. which I can see from

$su -c '/opt/gogs/gogs web' gogs
Password: 
2020/03/03 16:52:17 [TRACE] Custom path: /opt/gogs/custom
2020/03/03 16:52:17 [TRACE] Log path: /opt/gogs/log
2020/03/03 16:52:17 [TRACE] Log Mode: File (Info)

when I hit the browser I got the above error.

Solution to this issue is to change dir to the gogs install directory and run

$su -c '/opt/gogs/gogs web' gogs
Password: 
2020/03/03 16:52:17 [TRACE] Custom path: /opt/gogs/custom
2020/03/03 16:52:17 [TRACE] Log path: /opt/gogs/log
2020/03/03 16:52:17 [TRACE] Log Mode: File (Info)

solved the issue,

reason: gogs tries to mkdir on present directory, when running from your home, gogs user won't have permission there.

cd /opt/gogs/

helps gogs to run under the gogs user owned directory with needed permissions.

Hope that helps somebody

https://www.itfanr.cc/2017/03/23/docker-ubuntu-gogs-deploy/ explains the workdir for docker, which helped to find this bit of info

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM