nginx学习笔记一

总结:
一.学习如何源码安装nginx,如何升级nginx
1.准备好相应的安装环境
yum -y install gcc pcre-devel openssl-devel make
2.首先创建不能登录的nginx用户
useradd -s /sbin/nologin nginx
3.进入nginx安装包文件,进行源码安装
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with–(添加相应的功能模块)
make && make install
4.建立软连接
ln -s /usr/local/nginx/sbin/nginx /sbin/

二.设置网页帐号密码登录
1.前提是在安装nginx时,必须得添加–with-http_ssl_module这个模块包和安装 httpd-tools软件包
2.打开nginx配置文件,在server框里面添加
auth_basic “请输入相应的信息”; //添加输入内容
auth_basic_user_file “/usr/local/nginx/pass”; //输入密码文件目录
3.生成密码文件
htpasswd -c /usr/local/nginx/pass tom //创建用户
htpasswd /usr/local/nginx/pass jerry //添加用户

三.了解nginx.conf配置文件相应内容
1.配置文件中所包含的内容
http->server->location
2.server
-提供设置服务的监听端口号
-设置域名
3.location
-提供url的模糊查询
-提供设置网页根目录的设置
-提供设置默认网页

四.了解nginx提供多台虚拟主机服务
1.通过添加多一个server框架
例如:
server {
listen 80;
server_name www.a.com;

     location / {
         root ;
         index;
        }
   } 
  
 server {
     listen 80;
     server_name www.b.com;

     location / {
         root ;
         index;
        }
   } 

五.了解https服务
1.首先得有openssl-devel软件包
2.使用命令
openssl genrsa > cert.key //生成私钥文件
openssl req -new -x509(证书类型) -key cert.key > cert.pem //生成对应的密钥文件
3.配置nginx.conf配置文件,在最后会有相应的模版,将其解除注释

猜你喜欢

转载自blog.csdn.net/weixin_42917630/article/details/87976348