安装.net 6.0
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install dotnet-sdk-6.0
解压程序到opt/report
cd /opt/report
sudo tar zxvf /tmp/report_api.tar.gz
sudo tar zxvf /tmp/report_console.tar.gz
启动程序
dotnet WebApp_net6.dll --urls="http://*:5005"
sudo nohup dotnet Report_API.dll >/tmp/api_nohup.out &
sudo nohup dotnet Report_Console.dll >nohup.out &
nohup dotnet /opt/report/report_console/Report_Console.dll >/tmp/console_nohup.out &
nohup dotnet /opt/report/report_api/Report_API.dll >/tmp/api_nohup.out &
删除目录
sudo rm -rf publish2
删除文件
rm -f filename
创建目录
mkdir
查找进程对应PID,如httpd的PID
ps aux | grep httpd
ps aux | grep dotnet
ps -ef | grep dotnet | grep -v grep
根据PID杀死进程
kill -9 XXX
根据进程名关闭进程
killall XXXX
killall dotnet
赋予写入权限
chmod -R 777 /opt/report/report_api/log
excel插件
sudo yum install libgdiplus -y
添加到服务中
新建配置文件
sudo vi /etc/systemd/system/report_api.service
文件内容为:
[Service]
WorkingDirectory=/opt/report/report_api
ExecStart=/usr/bin/dotnet /opt/report/report_api/Report_API.dll
Restart=always
# Restart service after 5 seconds if the dotnet service crashes:
RestartSec=5
KillSignal=SIGINT
SyslogIdentifier=report_api
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
服务启用、启动、查看状态:
sudo systemctl daemon-reload
设置开机自启动
sudo systemctl enable /etc/systemd/system/report_api.service
sudo systemctl enable /etc/systemd/system/report_console.service
sudo systemctl enable /etc/systemd/system/report_api_prod.service
sudo systemctl enable /etc/systemd/system/report_console_prod.service
systemctl list-units --type=service (查看所有已启动的服务)
systemctl list-unit-files
查看服务日志
sudo journalctl -u report_api.service --since today
sudo journalctl -u report_api.service --since "16:28" --until now
查看端口占用情况
netstat -tunlp |grep 80 过滤查看含80的端口
netstat -ntlp 查看所有端口
lsof -i tcp:80 只查看80端口
sudo -i 切换到root用户下
mysql配置文件,linux版本是my.cnf,一般会放在/etc/my.cnf,/etc/mysql/my.cnf
查找文件
find / -name 'filename'
vi中查找字符
/字符串 n找下一个