zoukankan      html  css  js  c++  java
  • centos7 安装 nginx

    nginx

    • 环境依赖

      yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

    • 下载压缩包

      wget https://nginx.org/download/nginx-1.14.0.tar.gz

    • 解压

      tar zxvf nginx-1.14.0.tar.gz

    • configure

      ./configure

    • 编译和编译安装

      make && make install

    • 服务启动

      ./nginx

    • 查看是否启动

      • 查进程 ps aux | grep nginx
      • 输入地址看效果
    • 平滑启动

      ./nginx -s reload

    • nginx的配置文件 /usr/local/nginx/config/nginx.conf

      #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;
      
          #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;  # 后端给前端提供数据的时候,是否将数据进行压缩。
      
          server {
              listen       80;
              server_name  localhost;
              location / {
                  root   /home;
                  index  index.html index.htm;
              }
          }
          
          include  vhost/*.conf; # 以后将server可以写在这个目录里
          
       }
      
      # api.conf
      server {
              listen       80;
              server_name  localhost;
              location / {
                  root   /home;
                  index  index.html index.htm;
              }
          }
      
  • 相关阅读:
    架构漫谈阅读笔记(1)
    第一周学习进度
    2月13号寒假总结
    2月12日寒假总结
    2月11日寒假总结
    2月10日寒假总结
    寒假学习进度笔记一
    mapreduce课上实验
    个人课程总结
    用户体验评价
  • 原文地址:https://www.cnblogs.com/wuxiaoshi/p/12530835.html
Copyright © 2011-2022 走看看