PROWAREtech
Install ASP.NET Core on Linux ARM 32-bit
See also: Install ASP.NET Core on Ubuntu Linux and Configure it to Serve a Web Application
Download Raspian and install it on the Raspberry Pi. User: "pi" password: "raspberry"
Install and Configure Samba Server
To make it easy to copy files over to the Raspberry Pi from a Mac or Windows PC, install and configure Samba with these commands (or use scp):
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf
Create the new shares [www]
and [opt]
in the Samba smb.conf file.
NANO Edit smb.conf:
[www]
path=/var/www
writable=yes
browseable=yes
only guest=no
create mask=0777
directory mask=0777
public=yes
guest ok=yes
[opt]
path=/opt
writable=yes
browseable=yes
only guest=no
create mask=0777
directory mask=0777
public=yes
guest ok=yes
Edit access rights for /var/www
and /opt
and reboot the Raspberry Pi.
sudo chmod 0777 /opt
sudo mkdir /var/www
sudo chmod 0777 /var/www
sudo reboot
Install ASP.NET Core 3 Runtime
To install ASP.NET Core 3.1 runtime on the Raspberry Pi (ARM, 32-bit OS), download the Linux ARM32 ASP.NET Core binary. Copy the downloaded ASP.NET Core 3.1 file (aspnetcore-runtime-3.1.18-linux-arm.tar.gz) to the opt share on the Raspberry Pi. Issue these commands:
sudo apt-get install curl libunwind8 gettext
sudo mkdir -p /opt/dotnet
sudo tar zxf /opt/aspnetcore-runtime-3.1.18-linux-arm.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
dotnet --info
Install and Configure Apache Web Server
NOTE: skip this step by changing the port the ASP.NET Core Kestrel server is listening on to 80 (from 5000).
Issue these commands to install and configure Apache as a proxy.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install apache2
sudo a2enmod proxy proxy_http proxy_html
sudo nano /etc/apache2/sites-enabled/000-default.conf
With a hashtag (#), comment out all the lines until just these remain or have been added:
NANO Edit 000-default.conf:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:5000/
ProxyPassReverse / http://0.0.0.0:5000/
</VirtualHost>
Issue this command to restart the Apache server.
sudo systemctl restart apache2
Create a Web Application
Create an ASP.NET Core Web Application (MVC) in Visual Studio. Call it "webapp" for the purposes of this tutorial. Publish it as Folder or File Share in the directory of choice.
Set the target runtime to linux-arm and deployment mode to Framework-Dependent.
Copy the published files to the Raspberry Pi using its share www
. Copy the files into a directory named webapp
.
Install and Configure Supervisor
Supervisor will automatically run the "webapp" everytime the machine starts. Issue these commands to install and configure Supervisor:
sudo apt-get install supervisor
cd /etc/supervisor/conf.d
sudo touch webapp.conf
sudo nano webapp.conf
Enter this text into the file.
NANO Edit webapp.conf:
[program:webapp]
command=dotnet /var/www/webapp/webapp.dll
directory=/var/www/webapp
autostart=true
autorestart=true
environment=ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopsignal=INT
To stop the "webapp" so that new files can be copied to the Linux server, issue this command:
sudo service supervisor stop
To start the "webapp" after new files have been copied over, issue this command:
sudo service supervisor start
Reboot the Raspberry Pi and access its IP address from a browser and you will see this: