首页 > 系统相关 >linux部署.NET6.0项目

linux部署.NET6.0项目

时间:2023-04-04 18:36:42浏览次数:40  
标签:服务 service 部署 NET6.0 systemctl linux dotnet com WCSConfigServer

一、CentOS7.9配置SSH实现远程连接方法过程

 1.确认是否安装ssh

yum list installed | grep openssh-server

有输出内容,说明已安装;

2.安装SSH服务

yum install openssh-server

已安装的可以直接跳过。

3.编辑配置

vim /etc/ssh/sshd_config

4.Port 2222

PermitRootLogin no #是否允许root登录
PermitEmptyPasswords no #是否允许空密码登录
UseDNS yes #是否对远程主机名进行反向解析,关闭会提高连接的速度
GSSAPIAuthentication no #解决Linux之间使用ssh连接慢的问题

5.开启服务

sudo service sshd start

6.查看服务启动情况

ps -e | grep sshd

参考:

https://blog.csdn.net/lwd2307997664/article/details/115282739

二、CentOS7.9服务设置时间同步

1.安装ntpdate工具

yum -y install ntp ntpdate

2.设置系统时间与网络同步

任选一个

ntpdate ntp1.aliyun.com    
ntpdate ntp2.aliyun.com    
ntpdate ntp3.aliyun.com    
ntpdate ntp4.aliyun.com    
ntpdate ntp5.aliyun.com    
ntpdate ntp6.aliyun.com    

3.将系统时间写入硬件时间

hwclock --systohc

4.使用date命令查看Centos时区

date -R

5.查看系统的硬件时间,即BIOS时间

hwclock -r

6.修改Centos的时区

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -R

7.Centos系统修改BIOS硬件时间

hwclock -w

三、安装dotnet

#注册 Microsoft 密钥。注册产品存储库。安装必需的依赖项。

sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm

#安装 .NET Core 运行时

sudo yum -y install dotnet-sdk6.0

#查看Dotnet 版本信息,可能需要重启生效,需要exit退出root运行才有效,否则会找不到命令

dotnet --info

四、安装MySQL

1、下载安装包

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

2、未安装wget的同学执行以下命令安装

sudo yum install wget

3、安装

sudo rpm -ivh mysql57-community-release-el7-8.noarch.rpm
sudo yum install mysql-server --nogpgcheck
参考:https://blog.csdn.net/lizy928/article/details/82531749

五、CENTOS7 安装telnet

参考:https://www.cnblogs.com/suni/p/11528480.html

六、CentOS7防火墙放行或限制指定IP和端口(firewall)

1、手动启动/停止/重启firewalld.service服务

 

 

 2、展示当前配置的firewall规则

firewall-cmd --list-all

3、端口(端口段)的查询/开放

 

 

 4、生效

firewall-cmd -- reload
参考:https://www.cnblogs.com/zmqcoding/p/14700374.html

七、安装ftp服务

1、安装vsftp

yum -y install vsftpd

2、修改配置文件

vi /etc/vsftpd/vsftpd.conf
保证下面3项为YES
    anonymous_enable=YES
    anon_upload_enable=YES
    anon_mkdir_write_enable=YES 

3、设置vsftpd开机启动

systemctl enable vsftpd.service

4、启动并查看vsftpd服务状态,systemctl启动服务成功不会有任何提示,绿色的active表示服务正在运行

systemctl start vsftpd.service
systemctl status vsftpd.service

本地验证ftp是否可以正常访问

1、安装ftp

yum -y install ftp

2、使用anonymous登陆,无需密码

ftp localhost

 

 

 

 八、安装自定义服务

1、CentOS7利用systemctl添加dotnet后台服务                
vim /usr/lib/systemd/system/WCSConfigServer.service                
解析:WCSConfigServer.service是不存在的文件,此句话是创建这个服务文件,服务名就是WCSConfigServer.service ==> 即WCSConfigServer                
2、vim /usr/lib/systemd/system 代表创建的是系统服务,vim /usr/… 有一个代表是创建用户服务还是本地服务啥的忘记了                
3、在WCSConfigServer.service 文件中添加以下内容:    
[Unit]        
# 服务描述,随便写        
Description=WCSConfigServer system service        
# 描述服务的类别        
After=network.target        
        
[Service]        
WorkingDirectory=/home/qiesR/WCS_Publish/WCS_Server/WCSConfigServer        
# forking代表是后台运行服务,simple:主线程运行,一般用于shell下运行在前台的程序,oneshot:一次性进程        
Type=forking        
# 启动当前服务的命令        
# 有的教程写的是/usr/share/,具体看dotnet在哪个文件夹下,用命令dotnet --info 可以查看        
ExecStart=/usr/share/dotnet/dotnet /home/qiesR/WCS_Publish/WCS_Server/WCSConfigServer/WCSConfigServer.dll        
Restart=always        
# 重启间隔时间        
RestartSec=3        
# 重启当前服务时执行的命令,应该是固定写法        
ExecReload=/bin/kill -s HUP $MAINPID        
# 停止当前服务时执行的命令,应该是固定写法        
ExecStop=/bin/kill -s TERM $MAINPID        
        
[Install]        
WantedBy=multi-user.target    
4、设置开启启动    
systemctl enable WCSConfigServer    
    
5、常用命令    
systemctl start WCSConfigServer    
systemctl stop WCSConfigServer    
systemctl status WCSConfigServer    
    
6、自动挂断重启Bug    
Job for WCSConfigServer.service failed because a timeout was exceeded    
执行 systemctl start xxxx.service   出现这个错误,就是执行对应的脚本时间太长,时间到了,就直接结束了进程    
借助“bash -c”,bash -c的作用是将一个长字符串当做一条完整的命令来执行,如果在脚本路径后面加上后台运行符号(&),脚本就会在后台运行,不会一直处于挂起状态,systemd也就不会一直等待run.sh执行完成了    
Old:    
    ExecStart=/usr/share/dotnet/dotnet /home/qiesR/WCS_Publish/WCS_Server/WCSConfigServer/WCSConfigServer.dll
New:    
    ExecStart=/bin/bash -c "/usr/share/dotnet/dotnet /home/qiesR/WCS_Publish/WCS_Server/WCSConfigServer/WCSConfigServer.dll &"
    
    
7、卸载服务    
1)、确认是否安装    
rpm -qa | grep nginx    
2)、停止服务    
systemctl stop nginx    
3)、卸载服务    
yum erase nginx    
    
参考:    
    1、https://www.cnblogs.com/YrRoom/p/11761980.html
    2、https://blog.csdn.net/ichen820/article/details/105764191

 

 

注:不同环境的区别

public static string GetResponseString(HttpWebResponse webresponse)
        {
//linux环境 try { using (Stream s = webresponse.GetResponseStream()) { Stream stm = new System.IO.Compression.GZipStream(s, System.IO.Compression.CompressionMode.Decompress); StreamReader reader = new StreamReader(stm, Encoding.UTF8); return reader.ReadToEnd(); } } catch (Exception ex) { LogHelper<HttpHelper>.Error("GetResponseString:" + ex.Message); } return null; //Windows环境下 // try // { // using (Stream s = webresponse.GetResponseStream()) // { // StreamReader reader = new StreamReader(s, Encoding.UTF8); // return reader.ReadToEnd(); // } // } // catch (Exception ex) // { // LogHelper<HttpHelper>.Error("GetResponseString:" + ex.Message); // } //return null; }
        public void httpServer(string url, string postData, string type)
        {
            List<ConfigPostModel> configPostModelList = new List<ConfigPostModel>();
            var request = (HttpWebRequest)WebRequest.Create(url);
            var data = Encoding.UTF8.GetBytes(postData);
            request.Method = "POST";
            request.ContentType = "application/json;charset=UTF-8"; 
            request.ContentLength = data.Length;
            //request.KeepAlive = true;
            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }
            HttpWebResponse response;

            response = (HttpWebResponse)request.GetResponse();
            string apiRtn = "";
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Windows 相关逻辑
                apiRtn = new StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                // Linux 相关逻辑
                using (Stream s = response.GetResponseStream())
                {
                    Stream stm = new System.IO.Compression.GZipStream(s, System.IO.Compression.CompressionMode.Decompress);
                    StreamReader reader = new StreamReader(stm, Encoding.UTF8);
                    apiRtn = reader.ReadToEnd();
                }
            }
            configPostModelList = JsonConvert.DeserializeObject<List<ConfigPostModel>>(apiRtn);
            if (type == "JTUpload")
            {
                _configModel.ConfigPostModelList = configPostModelList;
            }
            if (type == "Com")
            {
                _commonConfigModel.ConfigPostModelList = configPostModelList;
            }
        }

 

标签:服务,service,部署,NET6.0,systemctl,linux,dotnet,com,WCSConfigServer
From: https://www.cnblogs.com/ywtssydm/p/15954976.html

相关文章

  • 1、Clickhouse 单节点与集群部署
    一、单节点部署1.1、修改文件描述符 vim/etc/security/limits.conf*softnofile65536*hardnofile65536*softnproc131072*hardnproc131072 vim/etc/security/limits.d/20-nproc.conf*softnofile65536*hardnofile65536*softnproc131072*hard......
  • archllinux配置触摸板
    参考:https://www.jianshu.com/p/c5678ce41ab1——作者:BigTaiYang大太阳https://wiki.archlinuxcn.org/wiki/Libinputsudocp /usr/share/X11/xorg.conf.d/70-synaptics.conf  /etc/X11/xorg.conf.d/修改内容如下:/etc/X11/xorg.conf.d$cat70-synaptics.conf......
  • Docker 部署单机 Zookeeper + exporter
    目录资源清单一、Docker安装1.使用国内yum源2.卸载旧版本的docker3.安装Docker20.10版本4.设置镜像加速5.启动docker二、Docker-compose安装1.Docker-compose安装2.查看docker-compose版本三、部署服务1.docker-compose.yaml资源清单2.创建目录结构3./conf/......
  • 部署项目遇到的问题汇总
    部署项目遇到的问题汇总问题一:nginx部署完成后,访问后端的接口返回CORS跨域请求思考:我部署的前后端都在同一个宿主机上,访问的ip都是相同的,不应出现跨域才对。解决:当你的nginx有如下配置(该配置通常用于本地开发环境)server{listen80;server_namexxx.aliyun.......
  • Docker 部署单机 Redis + exporter
    目录资源清单一、Docker安装1.使用国内yum源2.卸载旧版本的docker3.安装Docker20.10版本4.设置镜像加速5.启动docker二、Docker-compose安装1.Docker-compose安装2.查看docker-compose版本三、部署服务1.docker-compose.yaml资源清单2.创建目录结构3./etc/r......
  • 安装archlinux
    arch安装步骤archlinux官方安装wiki1、分区and格式化分区   (分区用fdisk,格式化分区用mkfs)2、挂载分区 (mount命令)3、安装archlinux base base-devel 先检测网路是否连接dhcpcd  没有提示代表一切正常安装arch baseandbase-develfailedretrievingfile'core.......
  • Docker 部署单机 ES + exporter
    目录资源清单一、Docker安装1.使用国内yum源2.卸载旧版本的docker3.安装Docker20.10版本4.设置镜像加速5.启动docker二、Docker-compose安装1.Docker-compose安装2.查看docker-compose版本三、部署服务1.docker-compose.yaml资源清单2.elasticsearch.yml外......
  • linux之stress(模拟压力测试)
    stress是一款模拟压力测试工具,他可以模拟cpu,内存,io等情况stress安装yuminstall-yepel-releaseyuminstallstress-ystress的使用1.模拟一颗cpu打满->stress-c1  通过htop查看一下cpu情况,可以看到有一颗cpu打满 2.模拟多颗cpu打满->stres......
  • linux/windows下开发yii项目
    在Windows下yii下载1将yii框架解压到apache下的htdoc文s件夹下2修改php.ini文件,将extension=php_pdo_mssql.dllextension=php_mysql.dllextension=php_pdo_mysql.dl前的分号去掉.3修改path变量我的电脑--属性--高级--环境变量--双击path--在后面添加;D:\myenv\php.重启电脑3验证......
  • Linux 配置www登录
    1、修改配置允许www登录root登录,编辑 /etc/passwd文件vi/etc/passwd找到 www:x:1000:1000::/home/www:/sbin/nologin,修改为www:x:1000:1000::/home/www:/bin/bash2、设置www登录密码继续利用root身份,执行passwdwww,输入两次密码(密码需要8位字符),回车修改成功......