第一次在linux 上装.netcore
业务需求就记下:
-
连接服务器,
发现用虚拟机死活连不上,而同局域网内的服务器能连上,通过同局域网的windows服务器连接后,修改linux内的端口号
sudo vim /etc/ssh/sshd_config
修改 #port 22 的端口号改成如: port 8099 之类的因为有些网关会让22这个端口不能访问 ,
然后重启服务
sudo service ssh restart #重启
sudo netstat -tunlp | grep "ssh" #查看端口号情况
-
配置证书
因为 centos7这个证书已经是好久好久以前的了,所以下载微软的配置的时候会发现证书过期,出现问题如下:curl: (60) Peer’s certificate issuer has been marked as not trusted by the user
这时候就要配置证书
wget http://curl.haxx.se/ca/cacert.pem #下载证书
mv cacert.pem /etc/pki/tls/certs/ #移动目录
cat cacert.pem>>/etc/pki/tls/certs/ca-bundle.crt #更新证书
- 如果出现
Name or service not known. wget: unable to resolve host address ‘curl.haxx.se’
或者类似的问题
就是说这个地址在curl里面不允许的
sudo vim /etc/hosts #进入到这个文件中
192.168.66.38 iZ88xk1xm84Z
192.168.85.163 jsrv.aegis.aliyun.com
192.168.85.164 update.aegis.aliyun.com
192.168.85.126 open.cms.aliyun.com
10.36.182.51 iZ8852iz1j2Z
60.210.8.70 docs.microsoft.com
65.52.183.205 packages.microsoft.com
151.101.230.49 curl.haxx.se #添加
4.接下去就可开心的去下微软的东西了
https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-centos
照着这里操作就好
5. 本地文件开发后上传
用sftp 上传,FileZilla这个程序就好了
6. 执行dotnet失败
It was not possible to find any compatible framework version
The framework ‘Microsoft.AspNetCore.App’, version ‘3.1.0’ was not found
去这里看吧人家写的很详细了
https://www.cnblogs.com/xuling-297769461/p/11934526.html
7. 其他鬼故事
如可开始dotnet
dotnet WebApplication7.dll --urls http://0.0.0.0:8007 #这里8007是你想要的端口号,5000有可能会被禁止的
如何停止dotnet
curl http://localtion:5000 #text web ,web is you ip 看下你的网址是否启动中
ps -aux | grep "WebApplication7.dll" #获得线程id
kill 18767 #杀死线程
如果css/js出现404
看下启动的路由
你可以通过到publish启动项目,也可以通过program修改代码来设置启动目录
最后祝你好运,啦啦啦德玛西亚