分类目录归档:未分类

ubuntu18.04通过docker安装gitea

参照docker官方文档:https://docs.docker.com/install/linux/docker-ce/ubuntu/

参照gitea官方文档:https://docs.gitea.io/zh-cn/install-with-docker/

新建oneinstack vhost,配置反向代理

location / {
        proxy_pass         http://localhost:10080;
        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;
    }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
    proxy_pass http://localhost:10080;

  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
    proxy_pass http://localhost:10080;
  }

Ubuntu18.04部署Asp.Net core Webapi为systemd服务

在Ubuntu上部署asp.net core webapi程序,并使用nginx代理,通过二级域名来访问。Ubuntu18.04使用oneinstack环境安装好了nginx,方便配置https,也方便添加二级域。添加一个api.host.com虚拟机,能正常通过域名访问(会显示403),然后此二级域名的目录为/data/wwwroot/api.host.com/,在此目录中建一个文件夹api,把发布的asp.net core程序上传到该目录,把用户和组修改为www,编写systemd配置如下,保存在 /etc/systemd/system目录下,比如命名为dotnetapi.service

[Unit]
Description=API running on Ubuntu

[Service]
WorkingDirectory=/data/wwwroot/api.host.com/api
ExecStart=/usr/bin/dotnet /data/wwwroot/api.host.com/api/MyApi.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-api
User=www
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

然后通过systemctl管理该服务,升级的时候,直接用新程序替换/data/wwwroot/crapi.lifehack.dev/crapi中的原程序,然后重启服务即可,systemd教程可参考这里

systemctl enable dotnetapi.service

systemctl start dotnetapi.service

systemctl restart dotnetapi.service

systemctl status dotnetapi.service

systemctl stop dotnetapi.service

# 重载所有修改过的配置文件
systemctl daemon-reload