我似乎无法确定问题出在哪里,但我似乎无法将我的应用程序部署到子 URI。我的直觉说它在我的虚拟主机配置和我的符号链接之间,但这是我第一次广泛使用虚拟主机和乘客。
当我尝试点击http://example.com/app时,我遇到了乘客错误...
No such file or directory - config.ru
它显示应用程序根:
/home/username/public/example.com/public
就其他一切而言……网站的目录结构:
example.com/
|-- public/
|-- index.php
|-- app/
|-- config.ru
|-- app.rb
|-- public/
`-- tmp/
`-- restart.txt
/etc/apache2/sites-available/example.com 中的虚拟主机:
# domain: example.com
# public: /home/username/public/example.com/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin email@example.com
ServerName www.example.com
ServerAlias example.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/username/public/example.com/public
<Directory /home/username/public/example.com/public>
Allow from all
</Directory>
RackBaseURI /app
<Directory /home/username/public/example.com/public/app>
Options -MultiViews
</Directory>
# Log file locations
LogLevel warn
ErrorLog /home/username/public/example.com/log/error.log
CustomLog /home/username/public/example.com/log/access.log combined
</VirtualHost>
我制作的符号链接:
ln -s /home/username/public/example.com/public/app/public /home/username/public/example.com/app
配置.ru:
#!/usr/bin/env ruby
require 'sinatra'
require File.expand_path('app.rb',__FILE__)
run Sinatra::Application
和 app.rb:
#!/usr/bin/env ruby
# encoding: UTF-8
require 'sinatra'
get '/' do
"App!"
end
不太确定这里可能出了什么问题,但我在这个 VPS 上有多个站点,所以目录结构有点时髦,有这么多公共文件夹。我可能会混淆自己。