nginx学习总结三(nginx的基本配置)

http://hzcsky.blog.51cto.com/1560073/473530


装nginx简单但是必须装pcre这个包。

# tar zxvf pcre-7.9.tar.gz

# cd pcre-7.9/

# ./configure

# make && make install

# tar zxvf nginx-0.7.65.tar.gz

# cd nginx-0.7.65/

#./configure
# make && make install
useradd nginx -M -s /sbin/nologin

按照默认安装   vi /usr/local/nginx/conf/nginx.conf
user  nginx nginx;
#运行的用户和组 我一般是采用www用户的。
worker_processes  1;
#指定工作的进程数 一般是CPU总核数的2倍或相等(我这里是虚拟机所以就一个)
例如是2个2核的写4就可以了
#error_log  logs/error.log;    #错误日志的路径
#error_log  logs/error.log  notice;
#日志的级别{debug |info |notice |warn |errro |crit}
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;   #pid 进程的日志

worker_rlimit_nofile 51200;   #打开文件的数量
events {
    use epoll;   #使用的模型前面讲到了
    worker_connections  51200;  #允许连接数
}
http {
    include       mime.types;
    default_type  application/octet-stream;
  #charset gb2312;
  # 设置使用的字符集 ,多个网站的请勿乱设置。
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
#使用日志记录相当于apache的combined日志格式。。。
    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
   #gzip#头部压缩缓存是否开启。
  include vhosts/*.conf;
  #区配这个目录下的配置文件我习惯一个虚拟主机一个配置文件
  }
[root@localhost local]#mkdir  /usr/local/nginx/conf/vhosts/
[root@localhost local]# vi   /usr/local/nginx/conf/vhosts/hou.conf
server {
        listen       80;
       #监听端口
        server_name  test1.xywy.com;
       #域名
        #charset koi8-r;
      #这个虚拟主机用的字符集
        #access_log  logs/host.access.log  main;
     #针对每个域名记录日志
        location / {
            root   /www;
# 虚拟主机目录
            index  index.html index.htm index.php; #访问页
        }

        #error_page  404              /404.html; #400错误吧

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
   }
保存启动服务,最基本的nginx的搭建就出来了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值