Nginx配置

2018-08-10  本文已影响0人  杨凯飞

nginx.conf 主配置文件

打开主配置文件

nginx.conf

在http里面有一个 include /etc/nginx/conf.d/*.conf。nginx会先读主配置文件,然后再去读取/etc/nginx/conf.d  里面的所有 *.conf文件

user                                        设置nginx服务的系统使用用户

worker_processes                 工作进程数

error_log                                nginx的错误日志

pid                                          nginx服务启动时候pid

event

        worker_connections                        每个进程允许最大连接数

        use                                                工作进程数

server {

    listen       80;   #侦听80端口

    server_name  xx.com;  #定义使用www.xx.com访问

    access_log  logs/www.xx.com.access.log  main;   #设定本虚拟主机的访问日志

    #默认请求

    location / {

        root   /root;      #定义服务器的默认网站根目录位置

        index index.php index.html index.htm;   #定义首页索引文件的名称

        fastcgi_pass  www.xx.com;

        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name; 

        include /etc/nginx/fastcgi_params;

    }

    error_page   500 502 503 504 /50x.html;   # 定义错误提示页面

    location = /50x.html {

        root   /root;

    }

    location ~ /\.ht {   #禁止访问 的文件

        deny all; 

    }

}

日志

    error.log           记录Nginx处理http错误的状态和Nginx本身服务的错误状态。

    access_log       记录Nginx的每次的访问状态。

--whih-http_random_index_module    目录中随机选择一个做主页


随机主页

--whih-http_stub_status_module  监控nginx当前的链接信息

stub_status

--whih-http_stub_module    http内容替换

内容替换

access_module 访问控制

限制IP访问
上一篇下一篇

猜你喜欢

热点阅读