From 7b4eb86a2305a37719e69f6f955bfe407f1c332c Mon Sep 17 00:00:00 2001
From: RadinPirouz <75082987+RadinPirouz@users.noreply.github.com>
Date: Fri, 29 Mar 2024 13:25:38 +0330
Subject: [PATCH] Update dotnet.md
---
nginx/dotnet.md | 215 ++++++++++++++++++++----------------------------
1 file changed, 89 insertions(+), 126 deletions(-)
diff --git a/nginx/dotnet.md b/nginx/dotnet.md
index 40d93ea..4c29582 100644
--- a/nginx/dotnet.md
+++ b/nginx/dotnet.md
@@ -1,150 +1,113 @@
+# Deploying .NET on Linux
-#
آموزشDeploy Dotnet روی لینوکس
-این آموزش فقط روی دات نت ۷ و اوبونتو ۲۲.۰۴ تست شده است
+This tutorial has been tested only on .NET 7 and Ubuntu 22.04.
-## خروجی گرفتن
+## Getting the Output
-
- نخست دات نت را نصب کنیم
-
-
- sudo apt install dotnet-sdk-7.0
-
-نکته: می توانید با دستور dotnet new mvc پروژه دات نت بسازید
-
-
-
- سپس باید از پروژه خود خروجی بگیریم پس دستور زیر را اجرا کنید
-
-
- dotnet publish
-
-
-مکان خروجی فایل بعد از اتمام دستور به شما نشان داده خواهد شد معمولا خروجی پروژه در مکان زیر قرار خواهد گرفت
-
+First, let's install .NET:
+```bash
+sudo apt install dotnet-sdk-7.0
+```
+*Note: You can create a .NET project using `dotnet new mvc` command.*
+Then, we need to publish our project:
+```bash
+dotnet publish
+```
+The location of the output file will be displayed after the command finishes. Typically, the project output will be placed in:
**bin/Debug/net7.0/publish**
-## نصب Ngnix
-
-اِنجیناِکس (به انگلیسی: nginx) یک کارساز وب با حجم پایین و کارایی بالا است که تحت مجوز بیاسدی منتشر میشود. این کارساز وب در یونیکس، گنو/لینوکس، بیاسدی، مک او اس و ویندوز اجرا میشود. بر طبق گفتهٔ نتکرافت، در حال
-حاضر ۱۲٫۰۷٪ از دامنههای اینترنت از این کارساز استفاده میکنند.
-
-
-
-برای نصب Ngnix از طریق apt از دستور زیر استفاده کنید
-
-
+## Installing Nginx
- sudo apt install ngnix
+**Nginx** is a high-performance web server with low resource usage, distributed under the terms of the BSD license. It runs on Unix-like operating systems and is widely used, currently powering 12.07% of the internet's domains.
-
-سپس با استفاده از دستور sudo ufw disable فایروال را غیرفعال کنید
-اگر با این دستور با خطا مواجه شد یعنی شما فایروال ندارد پس از روی این بخش رد شوید
+To install **Nginx** via `apt`, use the following command:
+```bash
+sudo apt install nginx
+```
-
-
-
-اگر نصب موفقیت آمیز بوده باشد با تایپ کردن localhost در مرورگر باید با پیام Welcome to Ngnix مواجه شوید
-
+Then, disable the firewall with:
+```bash
+sudo ufw disable
+```
+If you encounter an error with this command, it means you don't have a firewall. In that case, skip this part.
-## تنظیمات Ngnix
-
-با دستور زیر یک پوشه برای سایت خود می سازیم
-
+If the installation is successful, you should see "Welcome to Nginx" when typing `localhost` in your browser.
- sudo mkdir /var/www/app1
+## Configuring Nginx
+Create a directory for your site:
+```bash
+sudo mkdir /var/www/app1
+```
-
-محتویات پوشه publish را به پوشه ای که ساختیم کپی کنید
-
+Copy the contents of the `publish` directory to the newly created directory:
+```bash
+sudo cp yourprojectFolder/bin/Debug/net7.0/publish /var/www/app1
+```
- sudo cp yourprojectFolder/bin/Debug/net7.0/publish /var/www/app1
+Then, navigate to the Nginx configuration:
+```bash
+sudo vim /etc/nginx/sites-available/default
+```
-
-
-
-سپس با دستور زیر وارد کانفیگ Ngnix می شویم
-
-
- sudo vim /etc/nginx/sites-available/default
-
-
-و محتویات داخل فایل را با زیر عوض می کنیم
-
-
- server {
- listen 80;
- server_name example.com *.example.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 $host;
- proxy_cache_bypass $http_upgrade;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- }
+Replace the contents of the file with the following:
+```nginx
+server {
+ listen 80;
+ server_name example.com *.example.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 $host;
+ proxy_cache_bypass $http_upgrade;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
}
+}
+```
+*Note: Replace `example.com` with your site address.*
-
-نکته: به جای example.com آدرس سایت خود را بگذارید
-
-
-
-
-با دستور زیر محتویات فایلی را که تغییر دادیم را بررسی کنید
-
+Check the configuration file syntax:
+```bash
+sudo nginx -t
+```
- sudo ngnix -t
+If no errors are reported, reload Nginx to apply the changes:
+```bash
+sudo nginx -s reload
+```
-
-
-اگر با خطا مواجه نشدید دستور زیر را فراخوانی کنید تا تنظیمات Ngnix دوباره بارگذاری شود
-
+## Adding the Site as a Service
- sudo ngnix -s reload
+Create a service file for your site:
+```bash
+sudo vim /etc/systemd/system/app1.service
+```
-## افزودن سایت به عنوان سرویس
-
-با دستور زیر فایلی برای سرویس خود درست می کنیم
-
- sudo vim /etc/systemd/system/app1.service
-
-
-
-
-کد زیر در فایل بالا کپی کنید
-
-
- [Unit]
- Description= dotnet webapp
- [Service]
- WorkingDirectory=/var/www/app1
- ExecStart=/usr/bin/dotnet /var/www/app/projectname.dll
- Restart=always
- RestartSec=10
- SyslogIdentifier=projectname
- Environment=ASPNETCORE_ENVIRONMENT=Production
+Copy the following code into the file:
+```plaintext
+[Unit]
+Description=dotnet webapp
+[Service]
+WorkingDirectory=/var/www/app1
+ExecStart=/usr/bin/dotnet /var/www/app/projectname.dll
+Restart=always
+RestartSec=10
+SyslogIdentifier=projectname
+Environment=ASPNETCORE_ENVIRONMENT=Production
- [Install]
- WantedBy=multi-user.target
-
-
-
-نکته: به جای projectname اسم پروژه خود را بگذارید
-
-
-
-
-با دستور های زیر سایت را فعال کنید و از وضعیت آن مطلع شوید
-
-
- sudo systemctl enable app1.service
- sudo systemctl start app1.service
- sudo systemctl status app1.service
-
+[Install]
+WantedBy=multi-user.target
+```
+*Note: Replace `projectname` with your project's name.*
+Enable and start the site, and check its status:
+```bash
+sudo systemctl enable app1.service
+sudo systemctl start app1.service
+sudo systemctl status app1.service
+```