Last active
August 8, 2021 13:43
-
-
Save ayrilmaz/1b9e31959e67c346798f3e11acb9ee10 to your computer and use it in GitHub Desktop.
Ubuntu Nginx publish and run .net core web project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd var/www | |
mkdir -p proje | |
sudo chown -R www-data: /var/www/proje | |
sudo nano /etc/nginx/sites-available/proje.conf | |
server { | |
listen 80; | |
server_name proje.domain.com; | |
location / { | |
proxy_pass http://localhost:5000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection keep-alive; | |
proxy_set_header Host $http_host; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
} | |
} | |
sudo ln -s /etc/nginx/sites-available/proje.conf /etc/nginx/sites-enabled/ | |
sudo nginx -t | |
#create service | |
sudo nano /etc/systemd/system/proje.service | |
[Unit] | |
Description=proje | |
[Service] | |
WorkingDirectory=/var/www/proje | |
ExecStart=/usr/bin/dotnet /var/www/proje/proje.dll | |
Restart=always | |
# Restart service after 10 seconds if the dotnet service crashes: | |
RestartSec=10 | |
SyslogIdentifier=proje | |
User=www-data | |
Environment=ASPNETCORE_ENVIRONMENT=Production | |
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false | |
[Install] | |
WantedBy=multi-user.target | |
sudo systemctl enable proje.service | |
sudo systemctl restart proje.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment