zoukankan      html  css  js  c++  java
  • Nginx编译安装和配置

    环境准备:先安装准备环境

    yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

    解压安装包:

    编译nginx:

    ./configure  --prefix=/usr/local/nginx 
    --sbin-path=/usr/local/nginx/sbin/nginx
    --conf-path=/usr/local/nginx/conf/nginx.conf
    --error-log-path=/var/log/nginx/error.log
    --http-log-path=/var/log/nginx/access.log
    --pid-path=/var/run/nginx/nginx.pid
    --lock-path=/var/lock/nginx.lock
    --user=nginx --group=nginx
    --with-http_ssl_module
    --with-http_stub_status_module
    --with-http_gzip_static_module
    --http-client-body-temp-path=/var/tmp/nginx/client/
    --http-proxy-temp-path=/var/tmp/nginx/proxy/
    --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
    --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
    --http-scgi-temp-path=/var/tmp/nginx/scgi
    --with-pcre

    生成脚本及配置文件:make

    安装:make install

    通过命令启动和关闭nginx

    启动  /usr/local/nginx/sbin/nginx
    如果报错,在网上找相应的解决方法
    /usr/local/nginx/sbin/nginx/nginx  #启动 服务
    /usr/local/nginx/sbin/nginx/nginx   -s  reload  #不停止服务重读配置文件
    /usr/local/nginx/sbin/nginx/nginx -s stop #停止服务  #停止服务

    nginx 主配置文件:nginx.conf

    server {
      listen 80;
      server_name localhost;
      #charset koi8-r;
      #access_log logs/host.access.log main;
      location / {
        #root /var/www/html;
        index index.php index.html index.htm;
      }
      location ~ .php$ {
        root /var/www/html;
        # 设置监听端口
        fastcgi_pass 127.0.0.1:9000;
        # 设置脚本文件请求的路径
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # 引入fastcgi的配置文件
        include fastcgi_params;
        }
        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        root html;
      }

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ .php$ {
        # proxy_pass http://127.0.0.1;
      #}

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      #location ~ .php$ {
        # root html;
        # fastcgi_pass 127.0.0.1:9000;
        # fastcgi_index index.php;
        # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
        # include fastcgi_params;
      #}

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /.ht {
        # deny all;
      #}
    }

    重启nginx,

    在根目录的文件中创建一个PHP文件,在浏览器中用ip就能访问了





  • 相关阅读:
    Java SE 疑难点记录
    重写(OverRide)与重载(OverlLoad),以及相对应的多态性
    Static 作用探讨
    Java SE作业:判断一个字符串是否是视频文件
    轨迹压缩之Douglas-Peucker算法之Java实现
    论主动思考与专注力——我的读研感悟
    西安电子科技大学2011级计算机科学与技术专业知识体系结构图
    Hadoop分布式平台概述
    Jest测试框架(未完)
    项目经验总结
  • 原文地址:https://www.cnblogs.com/xiaochongzi/p/8528828.html
Copyright © 2011-2022 走看看