资讯专栏INFORMATION COLUMN

linux nginx.conf 配置

zorpan / 2074人阅读

摘要:文件配置域名重定向配置配置默认访问文件修改为定义的名称查找文件夹或者文件命令例如

1.conf文件

server {
    listen       80;
    server_name  mmy.109.com;
    root   /data/www/mmy.nginx.com;

    #access_log  logs/host.access.log  main;

    # 配置域名重定向
    #if ($host != "www.jt018.com" ) {
    #    rewrite ^/(.*)$ http://www.yphp.cn/$1 permanent;
    #}

    location / {

        # 配置rewrite
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?$1  last;
            break;
        }

        # include  /usr/local/nginx/html/yphp/.htaccess;
        # rewrite ^/(.+)/(.+)[/]?$ /index.php?m=$1&a=$2 last;

        # 配置默认访问文件
        index default.php index.html index.php index.htm;
    }


    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;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_intercept_errors on;
        # fastcgi_pass   phpServer;    # 修改为upstream定义的名称
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

2.nginx.conf

user www www;
worker_processes auto;

error_log /data/logs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;

events {
    use epoll;
    worker_connections 51200;
    multi_accept on;
    }

http {
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 1024m;
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 120;
    server_tokens off;
    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 Compression
    gzip on;
    gzip_buffers 16 8k;
    gzip_comp_level 6;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
        text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
        text/javascript application/javascript application/x-javascript
        text/x-json application/json application/x-web-app-manifest+json
        text/css text/plain text/x-component
        font/opentype application/x-font-ttf application/vnd.ms-fontobject
        image/x-icon;
    gzip_disable "MSIE [1-6].(?!.*SV1)";

    #If you have a lot of static files to serve through Nginx then caching of the files" metadata (not the actual files" contents) can save some latency.
    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

######################## default ############################
# server{
#    listen 80;
#    server_name mmy.109.com;
#    index index.html index.htm index.php;
#    root /data/www/mmy.nginx.com;
#
#    location ~ .php$ {
#        include fastcgi_params;
#        fastcgi_pass 127.0.0.1:9000;
#        fastcgi_index index.php;
#        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#    }
#
#}
########################## vhost #############################
include vhost/*.conf;
}

3.linux查找文件夹或者文件命令

例如:
find / -name nginx.conf
find /-name mysql

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/39362.html

相关文章

  • 虚拟机Linux Centos7搭建web环境(LNMP)

    摘要:本文内容是,如何在下快速搭建环境。虚拟机实体机环境都可以。按照提示,输入。 本文内容是,如何在Linux centos7下快速搭建LNMP环境。虚拟机、实体机环境都可以。另外,安装教程参考的是,下面这篇文章进行文字排版和内容扩充,感谢hcchanqing作者。CentOS6.2 yum安装配置LNMP服务器(Nginx+PHP+MySQL) 特别提醒:本文系统用的Centos7,是7!...

    Enlightenment 评论0 收藏0
  • 虚拟机Linux Centos7搭建web环境(LNMP)

    摘要:本文内容是,如何在下快速搭建环境。虚拟机实体机环境都可以。按照提示,输入。 本文内容是,如何在Linux centos7下快速搭建LNMP环境。虚拟机、实体机环境都可以。另外,安装教程参考的是,下面这篇文章进行文字排版和内容扩充,感谢hcchanqing作者。CentOS6.2 yum安装配置LNMP服务器(Nginx+PHP+MySQL) 特别提醒:本文系统用的Centos7,是7!...

    Cristic 评论0 收藏0

发表评论

0条评论

zorpan

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<