各位专家,
非常感谢大家的贡献!!
目前我已在本地计算机成功构建了 Discourse,并可以通过 localhost:3000 访问。这太棒了,包括创建主题、发布内容等操作都很顺利。
我主要参考了 这里 的指南,真的非常棒!
但是,我无法通过我的内网 IP(即局域网 IP,例如 10.1.2.139 这类地址)访问。我希望能在不同设备上访问此论坛(例如在我的笔记本电脑上访问)。
复现步骤
从以下地址获取 bash 脚本(install_discourse.sh):install-rails/linux at main · discourse/install-rails · GitHub
chmod +x install_discourse.sh
sudo ./install_discourse.sh
git clone https://github.com/discourse/discourse.git ~/discourse
sudo -u postgres createuser -s "$USER"
cd ~/discourse
source ~/.bashrc
bundle install
bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate
bundle exec rake autospec(此处可能会出现一些错误)
启动服务器:
bundle exec rails server
或
bundle exec rails server --binding=0.0.0.0
创建管理员账户
RAILS_ENV=development bundle exec rake admin:create
配置邮件
mailcatcher --http-ip 0.0.0.0
是否有任何建议可以通过本地 IP 进行访问?
非常感谢!
此致,
Chieh
2 个赞
simonk
(Simon King)
2020 年11 月 18 日 10:22
2
你使用了哪个命令来启动服务器?你需要使用这个命令:
bundle exec rails server --binding=0.0.0.0
3 个赞
pfaffman
(Jay Pfaffman)
2020 年11 月 18 日 13:04
3
我最近也在 Ubuntu 上进行开发安装时,遇到了开发环境无法监听 IP 地址的问题。
我相信我已经按照 Simon 的建议操作了,同时也使用了 bin/rails。
2 个赞
亲爱的 @simonk ,
感谢您的回复!
我曾在终端中使用 ctrl+c 来停止进程,然后运行 bundle exec rails server --binding=0.0.0.0 命令重新启动,但似乎仍然无法解决问题。
我想知道如何正确地停止它并再次启动?因为我发现即使我已经关闭了终端,仍然可以访问论坛。此外,我并没有通过 Docker 容器进行构建,因此没有 launcher 来使用 ./launcher stop app 命令。我也尝试过 kill $(cat tmp/pids/server.pid),但系统返回 cat: tmp/pids/server.pid No such file or directory。
非常感谢您能提供的任何提示!
再次感谢!
此致,
Chieh
1 个赞
simonk
(Simon King)
2020 年11 月 19 日 10:06
5
(免责声明:我自己并没有这样运行过 Rails——我使用的是基于 Docker 的开发环境(Install Discourse for development using Docker
你确定是这样吗?我之前就曾遇到过类似情况,因为我的浏览器缓存了 Discourse 应用,即使服务器进程没有运行,它仍然允许我在不同主题之间浏览。你不妨改用 curl 来测试一下:
curl http://localhost:3000
你也可以检查一下是否有 ruby 进程在运行:
ps -ef | grep ruby
netstat 工具可以告诉你哪些进程正在监听哪些端口。例如,如果我这样运行一个简单的 Python Web 服务器:
$ python3 -m http.server 8099
Serving HTTP on 0.0.0.0 port 8099 (http://0.0.0.0:8099/) ...
然后运行 netstat:
$ netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 2511478/python3
...
这会告诉我 PID 为 2511478 的进程正在所有接口(0.0.0.0 表示“所有接口”)的 8099 端口上监听。要获取关于该进程的更多信息,可以运行:
$ ps -fp 2511478
UID PID PPID C STIME TTY TIME CMD
simon 2511478 1250783 0 09:53 pts/11 00:00:00 python3 -m http.server 8099
3 个赞
你好 @simonk ,
感谢您的信息!非常有用。此外,我已经按这种方式迁移到了 Docker 容器。
我会在 Discourse 上继续尝试,对此感到非常兴奋。
再次感谢!
祝好,
Chieh
1 个赞
system
(system)
关闭
2020 年12 月 20 日 03:01
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.