nginx安装步骤详解

1.nginx安装

[root@proxy ~]# yum -y install gcc pcre-devel openssl-devel openssl-devel
[root@proxy nginx-1.12.2]# ./configure   \
--prefix=/usr/local/nginx   \                #指定安装路径
--user=nginx   \                            #指定用户
--group=nginx  \                            #指定组
--with-http_ssl_module                    #开启SSL加密功能
> --with-stream              //开启4层反向代理功能
> > --with-http_stub_status_module                //开启status状态页面

2.用户认证
步骤一:修改Nginx配置文件

server {
        auth_basic "Input Password:";                        //认证提示符信息
        auth_basic_user_file  "/usr/local/nginx/pass";        //认证的密码文件

步骤二:生成密码文件,创建用户及密码

[root@proxy ~]# yum -y install  httpd-tools
[root@proxy ~]# htpasswd -c /usr/local/nginx/pass   tom 

3.基于域名的虚拟主机

  server {
        listen       8000;                      //端口
        server_name  web1.example.com;           //域名
}

4.SSL虚拟主机

[root@proxy ~]# openssl genrsa > cert.key                            //生成私钥
[root@proxy ~]# openssl req -new -x509 -key cert.key > cert.pem      //生成证书
[root@proxy ~]# vim  /usr/local/nginx/conf/nginx.conf
        ssl_certificate      cert.pem;    #这里是证书文件
        ssl_certificate_key  cert.key;   #这里是私钥文件
[root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值