c# - 显示 apache 默认页面的 ASP.NET 核心应用程序
问题描述
我一直在关注有关如何在 Ubuntu 20.04 上的 .NET 5 应用程序中安装 ASP.NET Core的博客。当我访问链接api.example.com
时,它显示默认的 apache 页面。它应该向我展示 ASP.NET Core 应用程序。
所有应用程序文件都存储在其中,/var/www/api/
并且所有权已授予www-data
虚拟主机 api.conf
在 VirtualHost 中,我有以下配置并启用了 conf。
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost api.example.com:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName api.example.com
ServerAlias api.example.com
ErrorLog ${APACHE_LOG_DIR}api-error.log
CustomLog ${APACHE_LOG_DIR}api-access.log common
</VirtualHost>
添加服务
添加了以下服务配置并启用了服务。
[Unit]
Description=Api
[Service]
WorkingDirectory=/var/www/api/
ExecStart=/usr/bin/dotnet /var/www/api/Api.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=api
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
当我跑步时,sudo systemctl status api.service
我得到以下信息
ubuntu@sandbox:~$ sudo systemctl status api.service
● api.service - Api
Loaded: loaded (/etc/systemd/system/api.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-07-04 12:28:54 UTC; 12h ago
Main PID: 21133 (dotnet)
Tasks: 13 (limit: 1116)
Memory: 33.3M
CGroup: /system.slice/api.service
└─21133 /usr/bin/dotnet /var/www/api/Api.dll
Jul 04 12:28:55 sandbox api[21133]: warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
Jul 04 12:28:55 sandbox api[21133]: No XML encryptor configured. Key {cb00126e-6ce8-41cc-9568-800ff705be3a} may be persisted to storage in unencrypted form.
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Now listening on: http://localhost:5000
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Application started. Press Ctrl+C to shut down.
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Hosting environment: Production
Jul 04 12:28:55 sandbox api[21133]: info: Microsoft.Hosting.Lifetime[0]
Jul 04 12:28:55 sandbox api[21133]: Content root path: /var/www/api
解决方案
推荐阅读
- deep-learning - 数据集的归一化,错误:输入的所有元素应介于 0 和 1 之间
- jquery - [Route: ] - Laravel 7 缺少必需的参数
- google-sheets - 如何从一列和相邻列中随机选择
- angular - 如何在 Ionic App 中使用 cypress、scrollTo?
- sql - 无法在 oracle sql 开发中使用数据透视函数
- html - 如何在 Safari 15 中控制网站着色
- linux - 我无法修复此“无法锁定 apt 以进行独占操作”
- google-cloud-platform - 谷歌存储桶配置主页
- python - 我不能更改 conda 的 python 版本吗
- html - 使用 css 在按钮旁边添加加载图像