
FastReport .NET 具有广泛的功能,这已不是什么秘密。它还是一个可以与 Apache 2 网络服务器集成的优秀解决方案。接下来,我们将了解在 Linux 操作系统上对 Apache2 的微调。
首先,让我们用几个命令来安装 .NET 5。从微软软件仓库下载必要的软件包:
$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
接下来,安装 .NET5 软件包:
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-5.0
注意。您可以为 Windows 准备应用程序,即安装 FastReport.Core.Skia 软件包,并将此项目发送给已经在 Ubuntu 上运行的自己。
通过测试安装,您不需要 X11 就能使应用程序正常运行,因为它已经安装在 apache 或 Ubuntu 上。
现在,让我们使用以下命令开始加载 Apache2:
sudo apt install apache2
如果成功,则进入下一步。接下来,我们将管理 Apache 服务或其重启和关闭。请记住,对 Apache 进行任何更改,例如更改配置或启用任何设置时,都需要运行以下命令:
sudo systemctl start apache2 — Starts a previously stopped web server
sudo systemctl restart apache2— Stops and restarts the web server
Apache 被配置为在服务器启动时自动启动。如果不希望这样,请使用以下命令禁用:
sudo systemctl disable apache2
要在启动时重新加载启动服务,请键入
sudo systemctl enable apache2
现在,我们将设置虚拟主机。这意味着,如果你访问 localhost:80,你将被自动重定向到 localhost:5000。
为使一切正常运行,有必要启用一些模块:
sudo a2enmod proxy
sudo a2enmod proxy_http
接下来,进入安装 Apache 时自动创建的文件夹:
sudo cd /etc/apache2/sites-available/
现在,我们创建一个包含配置的文件,并立即对其进行编辑:
sudo nano /etc/apache2/sites-available/your_domain.conf
您需要在文件中添加以下几行:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ErrorLog ${APACHE_LOG_DIR}helloapp-error.log
CustomLog ${APACHE_LOG_DIR}helloapp-access.log common
注意:如果访问 localhost:80,则会自动重定向到 localhost:5000
创建配置文件后,激活并禁用默认配置:
sudo a2ensite your_domain.conf —Activate your config
sudo a2dissite 000-default.conf — Disable the config by default
sudo apache2ctl configtest — Check the file for syntax errors (if it is ok, then you will see the "Output Syntax OK" notification in the console)
sudo systemctl restart apache2 —Restart Apache for the changes to take effect
要发布项目,您需要执行以下命令:
dotnet publish --configuration Release — Publish the application to the publish folder as a release
接下来,进入发布文件夹。使用 ls 命令可以看到所有带有项目名称的 dll。
使用以下命令启动项目:
dotnet FastReport.Core.Web.Net5.dll
使用之前启动的 FastReport.Core.Web.Net5 应用程序重新启动 Apache,并转到 Apache 中指定的虚拟主机。即 localhost:80,然后看到它自动重定向到 localhost:5000。
如果成功,那么恭喜你!您已经成功地为 FastReport .NET 配置了 Apache2。如果您有任何问题,请联系我们的支持人员。
渝公网安备50010702505508