• nginx


    一、安装LNMP之前要安装EPEL,以便安装源以外的软件,如Nginx,phpMyAdmin等。

    yum install epel-release

    二、安装Nginx

    a) yum install nginx 
    b) systemctl start nginx #启动nginx         systemctl stop nginx 
    c) systemctl enable nginx #设置开机启动 

    三、修改nginx的配置

     1 vim /etc/nginx/conf.d/default.conf  
     2 server {   
     3     listen       80;   
     4     server_name  server_domain_name_or_IP;   
     5    
     6     location / {   
     7         root   /usr/share/nginx/html;   
     8         index  index.php index.html index.htm;   
     9     }   
    10    
    11     error_page  404              /404.html;   
    12    
    13     # redirect server error pages to the static page /50x.html   
    14     error_page   500 502 503 504  /50x.html;   
    15     location = /50x.html {   
    16         root   /usr/share/nginx/html;   
    17     }   
    18    # 更改nginx配置文件识别php 
    19     location ~ .php$ {   
    20         root           /usr/share/nginx/html;   
    21         try_files $uri =404;   
    22         fastcgi_pass   127.0.0.1:9000;   
    23         fastcgi_index  index.php;   
    24         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;   
    25         include        fastcgi_params;   
    26     }   
    27        
    28 }  

    四、设置图片,以及访问错误的时候跳转

          location ~* .(js|css|jpg|jpeg|gif|swf)$ { 
                    if (!-f $request_filename){ 
                            rewrite ^/(.*)$ /index.html last; 
                    } 
            }
        location ~ .*.(gif|jpg|jpeg|png)$ {
            expires 24h;
                root /opt/;#指定图片存放路径    
                proxy_store on;    
                proxy_store_access user:rw group:rw all:rw;
                proxy_temp_path         /opt/;#图片访问路径    
                proxy_redirect          off;
                proxy_set_header        Host 127.0.0.1;
                client_max_body_size    10m;
                client_body_buffer_size 1280k;
                proxy_connect_timeout   900;
                proxy_send_timeout      900;
                proxy_read_timeout      900;
                proxy_buffer_size       40k;
                proxy_buffers           40 320k;
                proxy_busy_buffers_size 640k;
                proxy_temp_file_write_size 640k;
                if ( !-e $request_filename)
                {
                     proxy_pass  http://127.0.0.1;#默认80端口    
                }
        }

    Copyright ©2017cnn . All Rights Reserved.

  • 相关阅读:
    教育是什么?
    关于CTime::Format在Unicode下的输出问题及解决办法
    COleDateTime在Unicode下,Format函数会有问题。
    UNICODE字符集
    处理字符串String类和正则表达式
    关于datatable linq的转换
    js
    HDU 3874 Necklace
    HDU 1520 Anniversary party
    HDU 4314 Save the dwarfs
  • 原文地址:https://www.cnblogs.com/cnn2017/p/6780213.html
Copyright © 2020-2023  润新知