• liunx安装nginx


    参考 https://blog.csdn.net/dyllove98/article/details/41120789

    1,去官网下载最新的包

    官网地址:http://nginx.org/download/

    也可以直接 wget http://nginx.org/download/nginx-1.9.9.tar.gz (我这下载很慢所有直接去官网下,在上传到服务器)

    2,下载相关依赖包

    [root@localhost src] wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
    [root@localhost src] tar zxvf pcre-8.40.tar.gz
    [root@localhost src] cd pcre-8.40
    
    [root@localhost pcre-8.40]# ./configure && make && make install
    
    下面两个安装步骤和上面的一致
    [root@localhost src] wget http://zlib.net/zlib-1.2.11.tar.gz
    
    [root@localhost src] wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

    3,解压nginx

    tar zxvf nginx-1.9.9.tar.gz

    cd nginx-1.9.9/

    ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module
    

    4,编译nginx

      make && make install

    添加一个nginx主程序的符号链接 
    ln -sf /usr/local/nginx/sbin/nginx  /usr/sbin

    检查配置是否正常

    nginx -t 

    首先把原来的配置文件清空:

    > /usr/local/nginx/conf/nginx.conf

    “>” 这个符号之前阿铭介绍过,为重定向的意思,单独用它,可以把一个文本文档快速清空。

    vim /usr/local/nginx/conf/nginx.conf

    写入如下内容:

    user nobody nobody;
    worker_processes 2;
    error_log /usr/local/nginx/logs/nginx_error.log crit;
    pid /usr/local/nginx/logs/nginx.pid;
    worker_rlimit_nofile 51200;
    
    events
    {
        use epoll;
        worker_connections 6000;
    }
    
    http
    {
        include mime.types;
        default_type application/octet-stream;
        server_names_hash_bucket_size 3526;
        server_names_hash_max_size 4096;
        log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
        '$host "$request_uri" $status'
        '"$http_referer" "$http_user_agent"';
        sendfile on;
        tcp_nopush on;
        keepalive_timeout 30;
        client_header_timeout 3m;
        client_body_timeout 3m;
        send_timeout 3m;
        connection_pool_size 256;
        client_header_buffer_size 1k;
        large_client_header_buffers 8 4k;
        request_pool_size 4k;
        output_buffers 4 32k;
        postpone_output 1460;
        client_max_body_size 10m;
        client_body_buffer_size 256k;
        client_body_temp_path /usr/local/nginx/client_body_temp;
        proxy_temp_path /usr/local/nginx/proxy_temp;
        fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
        fastcgi_intercept_errors on;
        tcp_nodelay on;
        gzip on;
        gzip_min_length 1k;
        gzip_buffers 4 8k;
        gzip_comp_level 5;
        gzip_http_version 1.1;
        gzip_types text/plain application/x-javascript text/css text/htm application/xml;
    
    server
    {
        listen 80;
        server_name localhost;
        index index.html index.htm index.php;
        root /usr/local/nginx/html;
    
        location ~ .php$ {
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
        }
    
    }
    
    }
    

    5,启动nginx

      /usr/local/nginx/sbin/nginx

      在检查下配置

      nginx -t

      查看nginx 是否启动

      ps -ef | grep nginx

    6,测试

     php安装参考 : https://www.cnblogs.com/chancy/p/9238149.html

    vim /usr/local/nginx/html/index.php

    内容如下:
    <?php
        echo phpinfo();
    ?>



  • 相关阅读:
    python---django初步了解以及安装(包括Django网页首次无法访问的原因及解决方法,以及在linux服务器上布置无法启动的原因)
    pytho部分命令
    三层架构
    CardView
    SimpleTagImageView
    MultiCardMenu
    DashClock
    SuperToolTips
    MPAndroidChart
    SlideLayout
  • 原文地址:https://www.cnblogs.com/chancy/p/9244023.html
Copyright © 2020-2023  润新知