1、修改配置文件

重要:修改配置文件使用虚拟机,否则怎么配置都不生效,添加如下用户

[root@host-10-1-1-161 html]# ll /etc/nginx/nginx.conf
-rw-r--r-- 1 root root 345 Aug 26 10:41 /etc/nginx/nginx.conf
[root@host-10-1-1-161 html]# vi /etc/nginx/nginx.conf
user root root;           #说明:这里的user根据 自己的nginx.conf文件所在的目录的属主属性而定
worker_processes 1; 2、整个配置文件,其他都删除,添加如下 [root@bogon ~]# cat /etc/nginx/nginx.conf
user root root;
worker_processes auto; worker_rlimit_nofile 51200; events
{
use epoll;
worker_connections 65535;
} 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 50m; sendfile on;
server_tokens off;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 256k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 3;
gzip_types text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
gzip_vary on;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for'; server { listen 80;
server_name 192.168.0.204; #填写 ip 或者域名
index index.html index.htm default.html index.php;
root /www/wwwroot/website/; if (!-e $request_filename) { #访问路径的文件不存在则重写URL转交给ThinkPHP处理
rewrite ^/(.*)$ /index.php/$1 last;
break;
          } location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf; #注意这个include 这个配置文件是nginx自带的,一定要有 #下面这 8 行统称为fastcgi_params的配置,nginx也有自带的fastcgi_params,但是报错,按照下面的就行
#宝塔面板里面 直接把这 8 行写到了一个pathinfo.conf文件里面,用一句话include pathinfo.conf代替 set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info; } location /status {
stub_status on;
access_log off;
} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 15d;
} location ~ .*\.(js|css)?$
{
expires 6h;
}
access_log /var/www/ceshi.access.log access;
error_log /var/www/ceshi.error.log;
}
include /etc/nginx/conf.d/*.conf; #nginx使用include配置多虚拟主机,需要加 ';' }

  

nginx主配置文件实例的更多相关文章

  1. Nginx 主配置文件参数详解

    Nginx 主配置文件参数详解 Nginx 安装完毕后,会有响应的安装目录,安装目录里 nginx.conf 为 nginx 的主配置文件, ginx 主配置文件分为 4 部分,main(全局配置). ...

  2. Centos7 nginx的目录结构与nginx主配置文件解析

    一.nginx的目录结构 [root@node nginx_116]# ls client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp ...

  3. nginx主配置文件学习,以及nginx的反向代理和负载均衡

    1.nginx.conf主配置文件学习 worker_processes : 表示nginx的进程数,根据CPU的核数来定义,起到优化的作用.通过cat /proc/cpuinfo来查看核数 even ...

  4. 第十六篇 nginx主配置文件参数解释

    # 指定拥有运行nginx权限的用户 #user nobody; # 指定开启的进程数,建议设置为CPU核心数 worker_processes ; # 指定全局错误日志级别,包括:debug/inf ...

  5. Nginx主配置文件说明

    #运行用户 user nobody; #启动进程,通常设置成和cpu的数量相等 worker_processes ; #全局错误日志及PID文件 #error_log logs/error.log; ...

  6. nginx子配置文件实例

    [root@bogon conf.d]# cat /etc/nginx/conf.d/test6.conf server { listen 8085; server_name 192.168.0.20 ...

  7. nginx 代理配置文件实例

    安装NGINX前要先安装PCRE正则表达式库: ./configure --prefix=/usr/local/pcre 出现以下错误  (一般./configure即可, 笔者这里是直接./conf ...

  8. nginx主配置文件详解

    #定义Nginx运行的用户和用户组user www www; #nginx进程数,建议设置为等于CPU总核心数.worker_processes 8; #全局错误日志定义类型,[ debug | in ...

  9. nginx主配置文件 在那找怎么打开

随机推荐

  1. The Preliminary Contest for ICPC Asia Nanjing 2019 B. super_log (广义欧拉降幂)

    In Complexity theory, some functions are nearly O(1)O(1), but it is greater then O(1)O(1). For examp ...

  2. 【XDOJ】小W的塔防

    原题: 小W在成功拿到iPhone后,下载了一个塔防游戏.游戏的目标是阻止僵尸穿过地图. 地图可以看作一条长度为n的线段,这条线段被划分为n条单位长度的小线段.僵尸需要花费t秒才能通过一条小线段.在每 ...

  3. 12-SSMS图形化工具中不允许保存修改的解决办法

    1.报出的警告 2.解决办法 工具-->选项-->设计器--->表设计和数据库设计器-->阻止保存要求重新创建表的更改  的勾去掉就OK 了

  4. css 判断是iphone4s iphone5 加载不同样式

    @media (device-height:480px) and (-webkit-min-device-pixel-ratio:2){/* 兼容iphone4/4s */ .class{}}@med ...

  5. Confluence 6.15 附件(Attachments )宏

    附件宏显示添加到一个页面中的所有文件列表. 同时附件宏允许用户(用户需要具有正确的权限)来进行下面的操作: 直接从列表中上传一个文件到页面 编辑附件属性和标签 删除一个附件文件(这个将会删除文件的所有 ...

  6. 线段树初步——转载自ljc20020730

    线段树初步   线段树模板1:https://www.luogu.org/problem/show?pid=3372 线段树模板2:https://www.luogu.org/problem/show ...

  7. 微信小程序“反编译”

    https://www.jianshu.com/p/ad8f417219e9 https://segmentfault.com/a/1190000018592740?utm_source=tag-ne ...

  8. AcWing:111. 畜栏预定(贪心 + 小根堆)

    有N头牛在畜栏中吃草. 每个畜栏在同一时间段只能提供给一头牛吃草,所以可能会需要多个畜栏. 给定N头牛和每头牛开始吃草的时间A以及结束吃草的时间B,每头牛在[A,B]这一时间段内都会一直吃草. 当两头 ...

  9. mysql 添加用户 - 设置远程登录/本地登陆的权限

    默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户: mysql> GRANT A ...

  10. Android res之shape

    xml控件配置属性 android:background="@drawable/shape" 标签 corners ----------圆角gradient ----------渐 ...