我有一个.net core webapi,我试图在使用 UBUNTU 20.04 的 1&1 vps 上托管
我完成了文档和其他教程中的所有步骤:我下载了 .net 包,发布了项目,将发布上传到服务器,配置了 apache,创建了一个服务文件并启动了 apache 和服务。他们工作正常。
我还下载了 mssql 包,并成功配置了我的数据库。然后我将我的项目配置为连接到数据库。
现在,当我 ssh 进入服务器并 curl 一个 get 请求(通过 ssh 本地,即curl --location --request GET 'http://localhost:5000/api/Category'
)时,它可以完美运行并且响应成功返回。(获取 api/类别)例如。
但是当我调用 mydomain.com/api/categories 时,我得到了
Not Found
The requested URL was not found on this server.
Apache Server at mydomain.com Port 80
但例如,当我上传一个 html 页面并调用 mydomain.com/index.html 时,它运行良好。
这是我的服务配置文件
[Unit]
Description=ASP .NET Web Application
[Service]
WorkingDirectory=/var/netcore
ExecStart=/usr/share/dotnet /var/www/vhosts/mydomain.com/httpdocs/API.dll
Restart=always
RestartSec=10
SyslogIdentifier=netcore-demo
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
这是我的 apache conf 文件
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.mydomain.com
ServerAlias *.mydomain.com
ErrorLog ${APACHE_LOG_DIR}helloapp-error.log
CustomLog ${APACHE_LOG_DIR}helloapp-access.log common
</VirtualHost>
任何帮助,将不胜感激!