>> Deploy

Use Apache to host FlowCore 2.0 on Linux



how to install ASP.NET Core 6.0 on Linux
Depending on the Linux distribution you are using, please refer to the official Microsoft documentation to execute the installation command.
install the .NET SDK or .NET runtime on Ubuntu

(1) Configure the Kestrel Web Server.
1.1 Configure Kestrel binding native ports.
Open <runroot/appsettings.json>, you can see that Kestrel binds the local address and port <localhost:5000> by default.
localhost equals 127.0.0.1 and uses Kestrel to bind native addresses and ports, which can be used with reverse proxies (Nginx, Apache).
You can customize the port that Kestrel binds (recommended port range 5000-60000) as long as the port is not occupied.
"Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      }
    }
  }

1.2 Verify that the Kestrel web server is working correctly.
Start the Kestrel web server on the Linux command line.
Linux commands
sudo dotnet /FlowCoreApproot/runroot/FlowCore.dll

Test HTTP access to the Kestrel web server.
Linux commands
curl http://localhost:5000

1.3 Configure the Linux background service <flowcore.service>. Copy<runroot/flowcore.service> to </etc/systemd/system>.
Linux commands
sudo cp /FlowCoreApproot/runroot/flowcore.service /etc/systemd/system

Use <vim > editing <flowcore.service> ,change the deployment path /FlowCoreApproot/ to the actual deployment path.
Linux commands
sudo vim /FlowCoreApproot/runroot/flowcore.service
flowcore.service
[Unit]
Description=FlowCore

[Service]
WorkingDirectory=/FlowCoreApproot/runroot
ExecStart=/usr/bin/dotnet /FlowCoreApproot/runroot/FlowCore.dll

Restart=always
RestartSec=10
SyslogIdentifier=flowcore
User=root
Environment=DOTNET_ROOT=/usr/lib64/dotnet
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

1.4 Start the service <flowcore.service>。
Install the service
Linux commands
sudo systemctl enable /etc/systemd/system/flowcore.service

Start the service
Linux commands
sudo systemctl start flowcore

Stop the service
Linux commands
sudo systemctl stop flowcore

View service status
Linux commands
sudo systemctl status flowcore

(2)Install Apache
Install Apache
Linux commands
sudo apt update
sudo apt install apache2

Start Apache for the first time
sudo service apache2 start

Start Apache
sudo systemctl start apache2

Reboot Apache
sudo systemctl restart apache2

Stop Apache
sudo systemctl stop apache2

View Apache service status
Linux commands
sudo systemctl status apache2

(3) Configure the Apache reverse proxy
Apache's configuration file is located in the /etc/httpd/conf.d/ directory.
In Apache on Ubuntu, all virtual host configuration files are stored in /etc/apache2/sites-available.
With the exception of the module configuration file in /etc/httpd/conf.modules.d/, any file with a .conf extension is processed alphabetically.
Configure an Apache reverse proxy to forward external HTTP requests to the Kestrel listening address http://127.0.0.1:5000/.
Create a configuration file named flowcore.conf for your app:
Apache configuration file
<VirtualHost *:*>
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:5000/
    ProxyPassReverse / http://127.0.0.1:5000/
    ServerName office.paicore.com
    ServerAlias *.paicore.com
    ErrorLog ${APACHE_LOG_DIR}flowcore-error.log
    CustomLog ${APACHE_LOG_DIR}flowcore-access.log common
</VirtualHost>



© 2023 PaiCore LLC. or its affiliates. All rights reserved.