图集1/3

正文 1692字数 1,588,600阅读


安装依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
Run code
Cut to clipboard


    下载nginx
    //创建一个文件夹 cd /usr/local mkdir nginx cd nginx //下载tar包 wget http://nginx.org/download/nginx-1.13.7.tar.gz tar -xvf nginx-1.13.7.tar.gz
    Run code
    Cut to clipboard


      安装nginx
      //进入nginx目录 cd nginx-1.13.7 //执行命令 ./configure //执行make命令 make //执行make install命令 make install
      Run code
      Cut to clipboard


        配置防火墙
        Failed to restart iptables.service: Unit not found.
        解决CentOS7关闭/开启防火墙出现Unit iptables.service failed to load: No such file or directory.
        firewall-cmd --zone=public --add-port=80/tcp --permanent #(--permanent永久生效,没有此参数重启后失效)
        Run code
        Cut to clipboard

          重新载入 firewall-cmd --reload 查看 firewall-cmd --zone=public --query-port=80/tcp 删除 firewall-cmd --zone=public --remove-port=80/tcp --permanent
          Run code
          Cut to clipboard


            Nginx虚拟域名配置
            //编辑nginx.conf sudo vim /usr/local/nginx/conf/nginx.conf //增加行 include vhost/*.conf //保存退出 //在/usr/local/nginx/conf目录新建vhost文件夹 mkdir vhost //创建每个域名的配置 sudo vim jimisun.com.conf //节点中增加入响应的配置 端口转发 或者访问文件系统
            Run code
            Cut to clipboard


              Nginx启动
              //进入nginx安装目录 cd sbin sudo ./nginx
              Run code
              Cut to clipboard

                //启动命令 ./nginx //停止命令 ./nginx -s stop 或者 : nginx -s quit //重启命令 ./nginx -s reload
                Run code
                Cut to clipboard

                  LINUX安装NGINX
                  nginx禁止使用ip地址直接访问
                  打开文件/etc/nginx/nginx.conf
                  将原server中的两个default_server去掉
                  换成
                  server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 444; }
                  Run code
                  Cut to clipboard


                    linux_nginx环境配置
                    linux_nginx反向代理
                    linux nginx配置新项目加域名
                    server{ server_name default sofun.net.cn iwstf.com snapshot.wiki; rewrite ^(.*) http://lizhenqiu.com$1 permanent; }
                    Run code
                    Cut to clipboard