Linux nginx

nginx
nginx :
《精通nginx第二版》
《nginx高性能web服务器详解》

1. web服务器
	http  80
	安装
	升级
	虚拟web主机
	加密
	用户认证
	重定向(rewrite)
	调优信息
	
2. 负载均衡 (反向代理)
	集群

3. web cache (缓存)

lnmp_soft.tar.gz

解压缩:
# tar -xf lnmp_soft.tar.gz
# cd lnmp_soft

软件的安装方式:
1. yum 安装 :自动解决依赖
2. rpm : 安装单一包
3. apt-get : Ubuntu、debian
4. 源码编译: 一般是tar包

源码编译:
优点: 自主定义配置
步骤:
1.解压:tar -xf
2.进入解压后的目录: cd
3.执行./configure 自定义的内容
4.编译并安装:
# make
# make install
所需的安装包:
gcc pcre-devel

源码编译安装nginx :
1.解压:
# tar -xf nginx-1.10.3.tar.gz
2.进入目录下:
# cd nginx-1.10.3
3.执行./configure
# ./configure
> --user=nginx
> --prefix=/usr/local/nginx
> --group=nginx
> --with-http_ssl_module (加载加密模块)

	创建用户nginx :
	# useradd  nginx 
	安装支持加密的依赖:
	# yum -y  install  openssl-devel 
4.编译并安装:	
	# make  && make  install 

nginx的管理:
启动:
# /usr/local/nginx/sbin/nginx
停止:
# /usr/local/nginx/sbin/nginx -s stop
重新加载:
# /usr/local/nginx/sbin/nginx -s reload
查看版本信息:
# /usr/local/nginx/sbin/nginx -V

创建软链接:
	# ln -s  /usr/local/nginx/sbin/nginx  /sbin

查看nginx的端口:80
	# netstat  -anuplt | grep nginx 

http://www.nginx.com
//官方网站–下载和售后
http://www.nginx.cn/doc/
//nginx的中文网站

遇到的问题:
现象:未找到nginx.pid
未发现进程
原因:80被占用
httpd

1.10.3 --> 1.12.2

升级:
1.解压:
# tar -xf nginx-1.12.2.tar.gz
2.进入目录:
# cd nginx-1.12.2
3.配置:
# ./configure --user=nginx --group=nginx
–prefix=/usr/local/nginx
–with-http_ssl_module
4.编译:
# make
5.老版本的nginx启动程序备份一份:
# mv /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginxold
6.复制新版本的启动程序:
# cp objs/nginx /usr/local/nginx/sbin
7.更新软件:
# make upgrade
8.验证:
# nginx -V

用户认证:
1.打开网页时,必须输入用户名和密码
2. 用户名tom 密码: 1234

  1. 修改主配置文件:

    vim /usr/local/nginx/conf/nginx.conf

    全局配置
    events {
    局部配置
    }
    http {
    server {
    局部配置
    }
    location / {
    局部配置
    }
    局部配置
    }


    server {
    listen 80;
    server_name localhost;
    auth_basic “Input your password:”;
    # 认证提示符
    auth_basic_user_file “/usr/local/nginx/pass”;
    # 认证密码文件
    }

    安装:httpd-tools //提供认证的依赖

    yum -y install httpd-tools

创建用户和密码:
# htpasswd -c /usr/local/nginx/pass tom
输入两遍密码
//添加新用户时,无需加-c

重新加载:
# nginx -s reload

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尹汇川

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值