• Nginx源码安装


    一、环境:

    centOs6.5

    pcre-8.42

    nginx 1.62

    二、依赖和库文件安装

    # yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
    、pcre安装

    [root@master pcre-8.42]# cd /local/
    [root@master local]# pwd
    /local
    [root@master local]# ls pcre-8.42.zip
    pcre-8.42.zip
    [root@master local]# unzip pcre-8.42.zip

    [root@master local]# cd pcre-8.42
    [root@master pcre-8.42]# ./configure

    [root@master pcre-8.42]# make && make install

    四、安装nginx

    4.1 下载

    [root@master local]# wget http://nginx.org/download/nginx-1.6.2.tar.gz

    [root@master nginx]# pwd
    /opt/nginx

    4.2 安装

    [root@master nginx]# ./configure --prefix=/opt/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/local/pcre-8.42

    [root@master nginx]# make

    [root@master nginx]# make install

    4.3 查看版本

    [root@master nginx]#  /opt/webserver/nginx/sbin/nginx -v

    nginx version: nginx/1.6.2

    4.4 配置nginx

    [root@master nginx]# vi /opt/webserver/nginx/conf/nginx.conf  

    [root@master nginx]# cat /opt/webserver/nginx/conf/nginx.conf
    user www www;
    worker_processes 2; #设置值和CPU核心数一致
    error_log /opt/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
    pid /opt/webserver/nginx/nginx.pid;
    #Specifies the value for maximum file descriptors that can be opened by this process.
    worker_rlimit_nofile 65535;
    events
    {
      use epoll;
      worker_connections 65535;
    }
    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';
      
    #charset gb2312;
         
      server_names_hash_bucket_size 128;
      client_header_buffer_size 32k;
      large_client_header_buffers 4 32k;
      client_max_body_size 8m;
         
      sendfile on;
      tcp_nopush on;
      keepalive_timeout 60;
      tcp_nodelay on;
      fastcgi_connect_timeout 300;
      fastcgi_send_timeout 300;
      fastcgi_read_timeout 300;
      fastcgi_buffer_size 64k;
      fastcgi_buffers 4 64k;
      fastcgi_busy_buffers_size 128k;
      fastcgi_temp_file_write_size 128k;
      gzip on; 
      gzip_min_length 1k;
      gzip_buffers 4 16k;
      gzip_http_version 1.0;
      gzip_comp_level 2;
      gzip_types text/plain application/x-javascript text/css application/xml;
      gzip_vary on;
     
      #limit_zone crawler $binary_remote_addr 10m;
     #下面是server虚拟主机的配置
     server
      {
        listen 80;#监听端口
        server_name localhost;#域名
        index index.html index.htm index.php;
        root /opt/webserver/nginx/html;#站点目录
          location ~ .*.(php|php5)?$
        {
          #fastcgi_pass unix:/tmp/php-cgi.sock;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          include fastcgi.conf;
        }
        location ~ .*.(gif|jpg|jpeg|png|bmp|swf|ico)$
        {
          expires 30d;
      # access_log off;
        }
        location ~ .*.(js|css)?$
        {
          expires 15d;
       # access_log off;
        }
        access_log off;
      }
    
    }

    4.5 测试安装的正确性

    [root@master nginx]# /opt/webserver/nginx/sbin/nginx -t
    nginx: the configuration file /opt/webserver/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /opt/webserver/nginx/conf/nginx.conf test is successful

    五 、启动nginx

    [root@master nginx]#  /opt/webserver/nginx/sbin/nginx

    前端查看一下:

    http://192.168.234.129/ 或者 http://192.168.234.129:80/

    六、 其他

     6.1 命令

    /opt/webserver/nginx/sbin/nginx -s reload            # 重新载入配置文件
    /opt/webserver/nginx/sbin/nginx -s reopen            # 重启 Nginx
    /opt/webserver/nginx/sbin/nginx -s stop              # 停止 Nginx

    6.2 进程查看

    [root@master nginx]# ps -ef|grep nginx
    root 14443 1 0 23:32 ? 00:00:00 nginx: master process /opt/webserver/nginx/sbin/nginx 
    www 14444 14443 0 23:32 ? 00:00:00 nginx: worker process 
    www 14445 14443 0 23:32 ? 00:00:00 nginx: worker process 
    root 14479 2276 0 23:56 pts/0 00:00:00 grep nginx

    6.3 端口查看:

    [root@master nginx]# netstat -ntl
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State 
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN



    IT之界浩瀚无边 只有持之恒心方可打开一窗 偷窥此中奥秘之一二 取之受益,亦珍而视之 学之留香,方不失风范 共勉 共进
  • 相关阅读:
    bzoj1107: [POI2007]驾驶考试egz LIS+单调队列
    poj3134 Power Calculus 迭代加深搜索
    洛谷P3953 逛公园 记忆化搜索
    洛谷P3960 列队 splay
    bzoj1486: [HNOI2009]最小圈 分数规划
    SharePoint Add-in Model (App Model) 介绍 – 概念、托管方式、开发语言
    SharePoint Add-in Model 介绍
    Office Add-In 应用类型及平台支持
    使用 Napa 创建并调试一个 Office 内容应用 – Hello World
    Office Add-in Model 简介
  • 原文地址:https://www.cnblogs.com/zhangmin1987/p/8870918.html
Copyright © 2020-2023  润新知