Nginx-小结

概念:高性能的HTTP和反向代理web服务器,轻量,高并发

环境:

centos7

关闭防火墙

nginx-1.18.0.tar.gz 安装包  源码安装

常用命令:

#创建软链接方便执行
[root@localhost nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
#启动服务
[root@localhost nginx]# nginx
#重启服务
[root@localhost nginx]# nginx -s reload
#停止服务
[root@localhost nginx]# nginx -s stop
#检测配置文件是否有语法错误
[root@localhost nginx]# nginx -t
#nginx 启动后会产生 /usr/local/nginx/logs/nginx.pid 文件,记录nginx进程pid
[root@localhost ~]# cat /usr/local/nginx/logs/nginx.pid 
7426

配置:

#解压
#tar.gz 压缩包解压
[root@localhost ~]# tar -xvzf nginx-1.18.0.tar.gz
#tar.bz2 压缩包解压
[root@localhost ~]# tar -xvjf nginx-1.18.0.tar.bz2


#配置
#yum 安装需要的依赖 
[root@localhost ~]# yum -y install zlib zlib-devel gzip gcc gcc-c++ pcre pcre-devel openssl openssl-devel


[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.18.0  nginx-1.18.0.tar.gz
[root@localhost ~]# cd nginx-1.18.0
[root@localhost nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module

#编译 安装
[root@localhost nginx-1.18.0]# make && make install
[root@localhost nginx-1.18.0]# echo $?
0
#创建软链接方便执行
[root@localhost nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/

#编辑nginx配置文件
[root@localhost nginx]# cd conf/
[root@localhost conf]# vim nginx.conf
#user  nobody;
#进程个数,一般小于cup核数
worker_processes  1;
#错误日志 级别
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#默认进程号存储的文件及目录
#pid        logs/nginx.pid;


events {
    #每个进程每秒最大的连接数,最大连接数不能超过系统默认允许最大打开文件的数量
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    #日志格式
    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;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值