Based on the Asp .NET Core course of Jannick Leismann. The original code can be found here. This version is upgraded to NET Core 8.0 using bootstrap 5.1. Below you'll find the most common cmd arguments if you are not developing with VS on windows.
- install net core from here
- to install entity framework (EF) and it's tools see here
- we can create a mvc razor auth app (like this) with
dotnet new mvc --auth Individual -o <APP_NAME_HERE>
- for other project templates, see here
- EF base command
dotnet ef
- add migration
dotnet ef migrations add <NAME> -o Data/Migrations
- create schema from migration
dotnet ef database update
- to learn more about migrations, see here
- install ASP.NET Core scaffolder
dotnet tool install -g dotnet-aspnet-codegenerator
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
- show options with
dotnet aspnet-codegenerator identity -h
- add and modify login pages
dotnet aspnet-codegenerator identity -dc <APP_NAME_HERE>.Data.ApplicationDbContext --files "Account.Register;Account.Login;Account.Logout"
- name:
[email protected]
- pw:
Test.1234
- name:
[email protected]
- pw:
5kX99xM7KxQz$Ha
- name:
[email protected]
- pw:
1kX99xM7KxQz$Ha
- build and run and automatically update changes
dotnet watch
- build and run
dotnet run
- run
dotnet publish --configuration Release
in local project dir - copy the files to the server by running
scp -r bin/Release/net8.0/publish/* username@remotecomputer:/var/www/worktastic
locally - ssh to the server
- install the .NET runtime on the server
- (the following steps will all be on the server side)
- howto
- intall
apt install postgresql
- login
sudo -u postgres psql
- change password for username postgres with
ALTER USER postgres with encrypted password 'postgres';
- check status
service postgresql status
- (the following steps will all be on the server side)
- install nginx
- get nginx status
service nginx status
- run nginx
service nginx start
- when we open the browser and navigate to the server ip, the nginx start page should be shown
- go to
cd /etc/nginx
mkdir sites-available
mkdir sites-enabled
nano /etc/nginx/sites-available/default
- add the following and save
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- add symlink
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
nano nano /etc/nginx/nginx.conf
- add the line
include /etc/nginx/sites-enabled/*;
tohttp {}
and save sudo nginx -s reload
- run
sudo nginx -t
to verify the configuration - reload nginx with
sudo nginx -s reload
to apply the changes
- run
dotnet /var/www/worktastic/worktastic.dll
on the server - when we open the browser and navigate to the server ip the startpage of the site should be shown
- ssh to server and run
chown -R www-data:www-data /var/www
- run
scp -r worktastic-app.service username@remotecomputer:/etc/systemd/system
on the local machine in project directory - run
systemctl enable worktastic-app.service
on server to enable the service - run
systemctl start worktastic-app.service
to start the service