How to set up an Apache2 web server for FastReport .NET

How to set up an Apache2 web server for FastReport .NET

It's no secret that FastReport .NET has broad functionality. It is also a great solution that can be integrated with the Apache 2 web server. Next, we will look at the fine-tuning of Apache2 on the Linux operating system.

First, let's install .NET 5 with a few commands. Download the necessary packages from the Microsoft repository:

$ 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

Next, install the .NET5 package:

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

Note. You can prepare your application for Windows, namely, install FastReport.Core.Skia packages and send this project to yourself already on Ubuntu.

With a test install, you do not need X11 for the application to work correctly because it is already installed with apache or on Ubuntu.

Now let's start loading Apache2 with the following command:

sudo apt install apache2

If it is successful, then proceed to the next step. Next, we are going to manage the Apache service or its reboot and shutdown. Remember that with any change in Apache, for example, when changing the config or when enabling any settings, you will need to run the following commands:

sudo systemctl start apache2 — Starts a previously stopped web server
sudo systemctl restart apache2— Stops and restarts the web server

Apache is configured to start automatically when the server boots. If you don't want this, disable this with the following command:

sudo systemctl disable apache2

To reload the start service during boot time, type:

sudo systemctl enable apache2

Now we will set up virtual hosts. It means that if you go to localhost:80, you will be automatically redirected to localhost:5000.

For everything to work correctly, it is necessary to enable some modules:

sudo a2enmod proxy
sudo a2enmod proxy_http

Next, go to the automatically created folder when installing Apache:

sudo cd /etc/apache2/sites-available/ 

Now we create a file with your config and immediately edit it:

sudo nano /etc/apache2/sites-available/your_domain.conf 

You need to add the following lines to the file:

<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

Note: If you go to localhost:80, then you will be automatically redirected to localhost:5000

After creating the config file, activate it and disable the default config:

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 

To publish the project, you will need the following command:

dotnet publish --configuration Release — Publish the application to the publish folder as a release 

Next, go to the publish folder. You will see all dlls with a project name using the ls command.

The project is started with the following command:

dotnet FastReport.Core.Web.Net5.dll

Restart Apache with the previously launched FastReport.Core.Web.Net5 application and go to the virtual host specified in Apache. Namely, on localhost:80, and see that it automatically redirects to localhost:5000.

If it was successful, congratulations! You have successfully configured Apache2 for FastReport .NET. If you have any questions, write to our support at support@fast-report.com.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot