zoukankan      html  css  js  c++  java
  • centos7 apache后台转nginx后台

    背景

    一开始买完服务器装的是用apache搭的后台, 现在想使用nginx, 希望对你有参考作用

    查看系统版本信息

    lsb_release -a
    

    我的版本信息是

    首先关闭apache-tomcat服务

    最稳妥的关闭方法,找到你的安装路径,执行bin下的shutdown脚本

    /usr/local/backend/apache-tomcat-9.0.24/bin/shutdown.sh
    

    要开启执行startup脚本

    /usr/local/backend/apache-tomcat-9.0.24/bin/startup.sh
    

    安装nginx

    yum install nginx
    安装成功后在浏览器输入服务器ip会显示欢迎页
    我的是这样

    如果你不知道yum 安装的nginx路径的话

    查找nginx安装包(所有安装包都可以这样找)

    rpm -qa|grep nginx
    

    画红线的就是nginx安装包
    然后查看这个安装包的安装路径

    rpm -ql nginx-1.16.1-1.el7.x86_64
    

    这个路径就是欢迎页面

    /usr/share/nginx/html/index.html
    

    你可以使用vim修改这个界面,然后去浏览器刷新一下看有没有变化

    设置开机启动

    sudo systemctl enable nginx

    开启nginx 服务

    sudo systemctl start nginx

    重启nginx服务

    sudo systemctl restart nginx

    查看nginx状态

    sudo systemctl status nginx.service

    开启nginx服务失败的时候

    报错: Job for nginx.service failed because the control process exited with error code.
    意思是进程存在,解决办法
    查看nginx pid

    ps ax | grep nginx
    

    kill 掉

    kill -9  nginx的pid
    

    然后重启
    service nginx start 或者 systemctl start nginx

    开放80端口

    阿里云服务器安全组规则添加80端口的出入规则

    修改nginx 默认首页

    vim /etc/nginx/nginx.conf
    

    按 i 进入编辑模式
    server {
    root 你的项目路径
    }
    把root的路径改为你的项目路径
    改完以后按esc , 然后按 :wq 保存并退出,重启nginx服务

  • 相关阅读:
    P1197 [JSOI2008]星球大战[并查集+图论]
    P1955 [NOI2015]程序自动分析[离散化+并查集]
    取模运算律[简单数学]
    P1462 通往奥格瑞玛的道路[最短路+二分+堆优化]
    P1330 封锁阳光大学[搜索+染色]
    P1168 中位数[堆 优先队列]
    P2661 信息传递[最小环+边带权并查集]
    P1080 【NOIP 2012】 国王游戏[贪心+高精度]
    P2085 最小函数值[优先队列]
    【转】priority_queue的用法
  • 原文地址:https://www.cnblogs.com/LHLVS/p/11928428.html
Copyright © 2011-2022 走看看