• linux安装nginx以及nginx部署前端服务


    之前没在linux上安装nginx并且部署前端环境,现总结如下

    1.下载并解压压缩包

    cd /app/
    //下载tar包
    wget http://nginx.org/download/nginx-1.13.7.tar.gz
    //解压tar包
    tar -xvf nginx-1.13.7.tar.gz
    
    //我直接解压,改了名字。即/app/nginx

    2.安装nginx

    //进入目录
    cd nginx
    //执行命令
    ./configure
    //执行make命令
    make
    //执行make install命令
    make install

    3.检查安装

    # cd到刚才配置的安装目录
    cd  /app/nginx/
    
    ./sbin/nginx -t

    正常情况的信息输出:

    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    4.启动nginx

    cd /app/nginx/
    /sbin/nginx   //启动nginx

    浏览器输入服务器ip,证明成功

    已上成功的显示

    下面是有可能失败的原因

    1../sbin/nginx -t 命令后,出现以下错误

    nginx: [alert] could not open error log file: open() "/opt/nginx-1.10.3//logs/error.log" failed (13: Permission denied)
    nginx: the configuration file /opt/nginx-1.10.3//conf/nginx.conf syntax is ok
    2019/01/06 21:47:53 [emerg] 22206#0: open() "/opt/nginx-1.10.3//logs/nginx.pid" failed (13: Permission denied)
    nginx: configuration file /opt/nginx-1.10.3//conf/nginx.conf test failed

    (1) 表示nginx下没有error.log的文件

       解决方法: nginx文件夹下新建logs文件夹

    mkdir logs
    
    chmod 700 logs

    然后再次执行 ./sbin/nginx -t

    然后执行./sbin/nginx,此时出现

    2017/09/19 11:07:26 [emerg] 5580#3332: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
    2017/09/19 11:09:35 [emerg] 7552#7556: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

    原因是只有root权限的用户可以conf的端口是1024以下,其他用户只能1024以上,所以在nginx/conf/nginx.conf下面把80端口号改为8080即可

    (1)查询nginx启动的服务  
    
    ps –ef | grep nginx
    
    (2)杀掉所有的进程
    
    kill -9 sth
    
    (3)重新启动nginx即可

     然后输入ip+端口号



    最后把前端代码打包,然后配置nginx.conf文件,然后直接重启nginx。输入你的ip+端口即可出现相应的前端界面。

    注:如果后台服务和前端服务不在同一个端口,要在nginx.conf的文件中配置反向代理,否则接口会报405错误

  • 相关阅读:
    ABP Xunit单元测试 第五篇
    ABP 异常处理 第四篇
    ABP Quartz 作业调度第三篇
    ABP 权限拦截 第二篇
    ABP .NET corej 版本 第一篇
    Vue生命周期
    vue中的import、export、requre的区别
    ES6最新语法
    Vux项目搭建
    对象克隆
  • 原文地址:https://www.cnblogs.com/yesu/p/12918166.html
Copyright © 2020-2023  润新知