银河麒麟服务器v10 sp1 nginx 部署项目

这篇具有很好参考价值的文章主要介绍了银河麒麟服务器v10 sp1 nginx 部署项目。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

上一篇:银河麒麟服务器v10 sp1 nginx开机自动启动_csdn_aspnet的博客-CSDN博客

 由于项目为前后端分离,前端项目使用nginx部署,VUE项目打包后上传至银河麒麟服务器:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

8063 为前端项目文件目录,修改配置 ,默认配置没有处理:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

 sudo systemctl stop nginx.service

 sudo systemctl status nginx.service

sudo systemctl start nginx.service

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10 

异常信息:Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

开始以为是配置文件的问题,然而在本机测试是可以正常启动,于是开始查找端口是否占用问题:

 银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

并没有占用,还能是什么问题?使用 命令 sudo systemctl status nginx.service 看看能不能锁定具体问题:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

明显看到80端口被占用了,这才想到开始修改配置的时候默认80端口并没有处理:

netstat -apn|grep :80

kill 58758 #杀死进程

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

将配置文件下载到本机,修改后上传服务器,配置如下:


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
	include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 50M;
    fastcgi_intercept_errors on;
    add_header X-Frame-Options SAMEORIGIN;
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    gzip on;
    gzip_static on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


    server {
        listen       8063;
        server_name  localhost;
        location / {
            root   html/8063;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
        location ^~ /apis/ {
            proxy_pass http://127.0.0.1:8061/;
        }
        location ^~ /apiz/ {
            proxy_pass http://127.0.0.1:8071/;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

执行命令:

sudo systemctl stop nginx.service

 sudo systemctl status nginx.service

sudo systemctl start nginx.service

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

使用命令:sudo systemctl status nginx.service 查看具体错误:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

 nqinx: [emerg] unknown directive "gzip_static"

启动异常:未知指令,于是将gzip_static on; 注释 #gzip_static on;,再次执行上面命令启动:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

通过上图看到已经启动成功,在浏览器访问:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10 

 难道是静态文件没有访问权限,对8063目录进行授权操作:

chmod 777 /usr/local/nginx1.25.1/html/8063

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10

再次访问依然为500,于是开始查找资料:

1. 设置静态网页或者文件夹权限

chmod 755 /home/ubuntu/nginxPic/

2. nginx 配置文件,配置server

sudo vi /etc/nginx/nginx.conf

在http里面加sever

server {

listen 92.168.2.380;

server_name 1;

autoindex on; #是否允许访问目录

location / {

root html;

index index.html index.htm;

}

在server节点添加上面红色部分:

server {
        listen       8063;
        server_name  localhost;
        autoindex on; #是否允许访问目录
        location / {
            root   html/8063;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
        location ^~ /apis/ {
            proxy_pass http://127.0.0.1:8061/;
        }
        location ^~ /apiz/ {
            proxy_pass http://127.0.0.1:8071/;
        }
    }

停止,重新启动nginx,依然没有解决。查看配置到 root   html/8063; 这一行的时候,在windows中会自动匹配到nginx下的html的目录,将此路径补全,由于代理获取ip均为127.0.0.1或::1,在server的location节点下添加请求IP配置,完整配置如下:


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
	include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 50M;
    fastcgi_intercept_errors on;
    add_header X-Frame-Options SAMEORIGIN;
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    gzip on;
    #gzip_static on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


    server {
        listen       8063;
        server_name  localhost;
		autoindex on; #是否允许访问目录
        location / {
            root   /usr/local/nginx-1.25.1/html/8063;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location ^~ /apis/ {
            proxy_pass http://127.0.0.1:8061/;
        }
        location ^~ /apiz/ {
            proxy_pass http://127.0.0.1:8071/;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

vue项目完整目录:

root   /usr/local/nginx-1.25.1/html/8063;

IP配置:

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

配置完成后启动:

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10 

银河麒麟服务器v10 sp1 nginx 部署项目,银河麒麟V10 SP1,nginx,nginx,银河麒麟服务器v10 

项目访问也是成功的,希望对你有帮助。

 文章来源地址https://www.toymoban.com/news/detail-605753.html

到了这里,关于银河麒麟服务器v10 sp1 nginx 部署项目的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 银河麒麟高级服务器v10 sp1 iso镜像定制

    https://www.kylinos.cn/support/trial.html?pid=1        安装选择最小化安装 1 虚拟机下挂载原版镜像 1) 查看光盘是否已挂载 ls -l /dev/cdrom |grep cd 2) 将ISO所在的/dev/cdrom挂载到/media mount /dev/cdrom /media 2 安装制作发行版的工具 yum -y install createrepo mkisofs isomd5sum rsync 3 同步光盘文件到制作ISO的

    2024年02月06日
    浏览(34)
  • 银河麒麟服务器操作系统 V10 SP1 开启SSH服务

    此处显示已经安装了openssh。 如果此处没有任何输出显示,表示没有安装openssh 当发现没有安装openssh时,使下面的命令安装openssh: 如图所示,已经开启sshd服务。 如果显示未开启sshd服务,使用下列命令开启sshd服务 使用下面的命令查看ssh服务是否开机启动 如上图所示,ssh已经

    2023年04月22日
    浏览(34)
  • 银河麒麟服务器 v10 sp1 安装 .Net6.0

    系统版本、架构:  如果系统自带.netcore3,先卸载系统自带的.netcore3:  卸载.netcore3: 我的系统没有自带.netcore3,也没有yum命令。 下载二进制文件安装SDK: 下载 .NET 6.0 (Linux、macOS 和 Windows) 下载后将文件dotnet-sdk-6.0.411-linux-x64.tar.gz,上传至银河麒麟服务器: 我的第一步给文

    2024年02月12日
    浏览(48)
  • 银河麒麟V10SP1服务器系统同步外网源到本地

    系统环境:Kylin Linux Advanced Server release V10(SP1)/(Tercel)-aarch64-Build20/20210518 本文同步的是外网ARM的yum源仓库,若需要同步X86的yum源仓库,则需要修改yum配置文件的架构为X86,其他配置不变。 a)确定系统版本及网络情况 b)关闭系统防火墙和 selinux a)备份原yum配置文件 b)yum配

    2024年01月24日
    浏览(67)
  • 银河麒麟服务器v10 sp1 .Net6.0 上传文件错误

    上一篇:银河麒麟服务器v10 sp1 部署.Net6.0 http https_csdn_aspnet的博客-CSDN博客 .NET 6之前,在Linux服务器上安装 libgdiplus 即可解决,libgdiplus是System.Drawing.Common原生端跨平台实现的主要提供者,是开源mono项目。地址:GitHub - mono/libgdiplus: C-based implementation of the GDI+ API 因此,解决方法

    2024年02月12日
    浏览(30)
  • 银河麒麟服务器操作系统 V10 SP1 防火墙(firewalld)指令

    systemctl status firewalld (或者: systemctl status firewalld.service ,或者: systemctl is-active firewalld )active(running):表示防火墙已经开启。 1、开启: systemctl start firewalld 查看状态: systemctl status firewalld 2、关闭: systemctl stop firewalld 查看状态: systemctl status firewalld 3、重启: systemc

    2024年02月13日
    浏览(55)
  • 银河麒麟服务器v10 sp1 部署 redis 及redis gui 客户端工具

    上一篇:银河麒麟服务器v10 sp1 redis开机自动启动_csdn_aspnet的博客-CSDN博客 本文介绍另一种redis安装方式及客户端工具安装。 Redis 是一种内存数据模型存储,可用作数据库、缓冲区和消息传递中继。它是开源的(BSD 许可)。字符串、散列、列表、集合、具有范围搜索的排序集

    2024年02月11日
    浏览(39)
  • 银河麒麟服务器V10SP1双内核更改低版本内核为第一引导项

    需要保留新内核的情况下使操作系统在下次启动默认加载的是旧内核。 1.1 UEFI传统的Legacy BIOS启动 grub引导文件路径不一致,先需要查看系统是UEFI启动还是传统的Legacy BIOS启动

    2024年02月03日
    浏览(40)
  • 银河麒麟服务器v10 sp1 部署.Net6.0项目后无法访问静态文件

    上一篇:银河麒麟服务器v10 sp1 部署.Net6.0 http https_csdn_aspnet的博客-CSDN博客 由于本人项目直接从.NetCore3.1升级到.Net6.0的,请参考文章:NetCore3.1项目升级到Net6.0_vs2022 没有startup_csdn_aspnet的博客-CSDN博客 虽然部署项目后,swagger与接口可以正常访问,但是静态文件,如html、css、j

    2024年02月12日
    浏览(28)
  • 远程连接银河麒麟高级服务器操作系统V10SP1的几种方法(命令行远程+图形化远程)

    服务端 OS环境:银河麒麟高级服务器操作系统V10SP1(x86_64) 确认sshd服务处于运行状态 [root@localhost ~]# systemctl status sshd 确认防火墙已经放行SSH服务 [root@localhost ~]# firewall-cmd --list-all 备注:如果系统没有放行ssh服务,或者ssh端口号被修改,则需要重新放行ssh服务或者新的ssh端口

    2024年02月09日
    浏览(153)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包