欢迎使用CSDN-markdown编辑器

nginx安装

先准备安装好gcc, openssl-devel,pcre-devel, zlib-devel
然后下载nginx 程序进行安装
wget http://nginx.org/download/nginx-0.7.69.tar.gz
tar …
./configure –prefix=/opt/nginx
make && make install

主配置文件

在/opt/nginx/conf/目录下,主要配置文件是nginx.conf

user nobody;  #制定nginx进程的所属者和组,默认是nobody
error_log logs/error.log  debug;  #指定日志的级别debug->info->notice->warn->error->cati
pid    logs/nginx.pid; #进程ID存储文件的位置

#设置nginx的工作模式和连接数上限
event  {  
    use epoll; 指定工作模式,linux默认是epoll模式
    worker_connections 1024;  每个进程的最大连接数
}

HTTP服务全局配置

http {
    include       mime.types;  
    default_type  application/octet-stream;   #默认类型为2进制流

    #Nginx的HttpLog模块,指定nginx的日志输出格式 main为个格式的名称
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;   调用格式名称

    sendfile        on;    #开启高效文件传输模式
    #tcp_nopush     on;

    #keepalive_timeout  0;  
    keepalive_timeout  65; #服务器和客户端之间的保活超时时间

    #gzip  on;   #开始起gzip压缩,实时压缩输出数据流

server配置

server  {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
             }
        }

常用维护命令

[root@localhost sbin]# ./nginx -t #通过此命令检查配置文件是否正确
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
“`

启动程序
[root@localhost sbin]# ./nginx
[root@localhost sbin]# ps -ef | grep nginx
root 23618 1 0 09:55 ? 00:00:00 nginx: master process ./nginx
nobody 23619 23618 0 09:55 ? 00:00:00 nginx: worker process

然后访问本机出现如下网页及正常
Alt text

Nginx对进程的控制:
1. HUP :重新加载配置文件,不影响接受用户请求,实现平滑重启nginx ->kill -HUP pid
2. USR1 :用于nginx日志切换,重新打开一个日志文件

安装后的文件夹说明
[root@localhost nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
sbin目录下是命令工具
logs下保存有access.log,error.log等
html: 保存页面配置信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值