安装新版本的Nginx(vim /etc/yum.repos.d/Nginx.repo)
[Nginx-stable] name=Nginx stable repo baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled= gpgkey=https:Nginx.org/keys/Nginx_signing.key module_hotfixes=true [Nginx-mainline] name=Nginx mainline repo baseurl=http:Nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=true
yum-config-manager --enable Nginx-mainline
一、安装Nginx
yum install Nginx
二、配置Nginx
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
如果启动Nginx失败,提示bind() to 0.0.0.0:8000 Failed (13: Permission denied)则需要在SElinux中把自定义端口加入(默认SELinux只允许80,81,443,488,8008,8009,8443,9000提供Http服务)
semanage port -l | grep http_port_t
yum install policycoreutils-python.x86_64
semanage port -a -t http_port_t -p tcp 8088
#如果添加端口的时候提示 ValueError: 已定义端口,则使用下面的命令,覆盖配置
# semanage port -m -t http_port_t -p tcp 8000 //覆盖
# semanage port -d -t http_port_t -p tcp 6033 //删除
在Nginx.conf配置中增加一个配置(务必注意access_log的配置文件夹是否存在)
location /Nginxstatus { stub_status on; access_log /usr/local/Nginx/logs/status.log; auth_basic "NginxStatus"; }
三、设置Nginx开机启动
systemctl enable Nginx.service
四、安装守护进程工具
方法一:
yum install python-setuptools wget https:files.pythonhosted.org/packages/d3/7f/c780b7471ba0ff4548967a9f7a8b0bfce222c3a496c3dfad0164172222b0/supervisor-4.2.2.tar.gz tar -zxvf supervisor-4.2.2.tar.gz cd supervisor-2 python setup.py install # 检查是否正常安装 supervisord -v # 生成配置文件 mkdir -p /etc/supervisor/conf.d echo_supervisord_conf > /etc/supervisor/supervisord.conf
方法二:yum install supervisor
配置/etc/supervisor/supervisord.conf
[supervisord] logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB logfile_backups=10 ; # of main logfile backups; 0 means none,default 10 loglevel=info ; log level; default info; others: debug,warn,trace pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid nodaemon=false ; start in foreground if true; default false # 重要 minfds=655350 ; min. avail startup file descriptors; default 1024 minprocs=65535 ; min. avail process descriptors;default 200 [include] files = /etc/supervisor/conf.d/*.conf
五、配置守护进程信息
cd /etc/supervisord.d
vi videoserver.ini (注意program:后面的名字是唯一的)
[program:VideoServer.Site]
command=dotnet VideoCheckServer.dll
directory=/usr/bin/videoserver
environment=ASPNETCORE__ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=3
stderr_logfile=/var/log/videoserver.err.log
stdout_logfile=/var/log/videoserver.out.log
supervisord -c /etc/supervisord.conf
六、设置开机启动守护工具
systemctl enable supervisord.service
如果要显示验证码,需要安装libgdiplus:
sudo libgdiplus install libtiff libtiff-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel libX11 libX11-devel freetype rpm -ivh https:dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm install libgdiplus-devel
如果安装 libgidplus提示缺少glib-2.0 就先安装:
install glib2-devel cairo-devel -y
然后执行
./configure --prefix=/usr/local && make && install
Ubuntu在线安装.NET Core SDK流程:
1、将 Microsoft 包签名密钥添加到受信任密钥列表,并添加包存储库。
packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb
2、安装 .NET Core SDK 6.0
sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update &&install -y dotnet-sdk-6.0
如果只需要安装asp.netcore运行时,则上述最后一句换成
install -y aspnetcore-runtime-6.0