zoukankan      html  css  js  c++  java
  • nginx环境搭建

    nginx环境搭建

    准备工作

    1. nginx是C语言开发的所以安装gcc必不可少 yum install gcc-c++
    2. 安装PCRE yum install -y pcre pcre-devel
    3. zlib压缩解压缩 yum install -y zlib zlib-devel
    4. openssl协议 yum install -y openssl openssl-devel
    5. 安装wget下载nginx包 yum install -y wget & wget http://nginx.org/download/nginx-1.19.0.tar.gz
    6. 解压安装包 tar -zxvf nginx-1.19.0.tar.gz
    7. 到解压路径 cd ./nginx-1.19.0
    8. 指定软件安装路径 ./configure --prefix=/usr/local/nginx
    9. 编译&安装 make install
    10. 到达目录并且启动(指定配置文件) cd /usr/local/nginx/sbin/ & ./nginx -c /usr/local/nginx/conf/nginx.conf
    11. 这时候使用 IP地址+80(默认端口号就可以打开了) 如果无法显示看下面

    网页无法显示

    1. 查看防火墙状态 systemctl status firewalld (如果是running开启,dead未开启)
    2. 开启防火墙 service firewalld start
    3. 关闭防火墙 systemctl stop firewalld
    4. centos7.3 上述方式可能无法开启,可以先 systemctl unmask firewalld.service 然后 systemctl start firewalld.service
    5. 查看想开的端口是否开启 firewall-cmd --query-port=80/tcp (no表示未开)
    6. 开启端口号 firewall-cmd --add-port=80/tcp --permanent (success表示成功)
    7. 重新载入防火墙配置 firewall-cmd --reload
    8. 移除端口 firewall-cmd --permanent --remove-port=80/tcp

    nginx操作

    1. 启动 cd /usr/local/nginx/sbin/ & ./nginx -c /usr/local/nginx/conf/nginx.conf
    2. 停止 cd /usr/local/nginx/sbin/ & ./nginx -s quit
    3. 重新加载配置文件 ./nginx -s reload

    设置开机自启动

    ​ 开机启动,加入rc.local文件中

    ​ vi /etc/rc.d/rc.local

    ​ 加入一行

    ​ /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    ​ 修改rc.local文件权限

    ​ chmod 755 /etc/rc.d/rc.local

  • 相关阅读:
    一个在LINUX里安装MS LIB的工具
    Debian 5网易更新源
    ZT:apache转发实现iis和apache共享80端口
    SuSE 安装 永中Office
    [ZT]用dd备份主引导记录
    opensuse 11.3使用fcitx的办法
    在debian5上安装vmware server 2.0.2的尝试
    VHCS wait to be added问题解决
    debian里的NAT转发设置
    Linux操作系统下安装USB移动硬盘的方法
  • 原文地址:https://www.cnblogs.com/hwx1999/p/13171609.html
Copyright © 2011-2022 走看看