提升学历的方法有哪些,谷歌seo是啥,网页设计教程 罗云芳吴黎,宁夏水利厅建设管理处网站Nginx 简介
nginx一种十分轻量级的http服务器一种高性能的HTTP和反向代理服务器,同时是一个IMAP/POP3/SMTP 代理服务器其中官网网站
安装Nginx
使用源码编辑安装
#提前安装相关工具软件包
yum -y install net-tools tar unzip gcc make pcre-devel openssl-devel httpd-too…Nginx 简介
nginx一种十分轻量级的http服务器一种高性能的HTTP和反向代理服务器,同时是一个IMAP/POP3/SMTP 代理服务器其中官网网站
安装Nginx
使用源码编辑安装
#提前安装相关工具软件包
yum -y install net-tools tar unzip gcc make pcre-devel openssl-devel httpd-tools # gcc make 编译工具 pcre-devel 开发用的正则表达式依赖包 (提供.h库) openssl-devel 开发用的ssl加密依赖包(提供.h库) net-tools 网络相关软件包 httpd-tools 提供htpasswd命令的相关工具#解压nginx包
tar -xf nginx-1.22.1.tar.gz
#进入nginx目录
cd nginx-1.22.1
#生成适合当前系统的MakeFile文件,用于后续的编辑和安装
./configure --prefix/usr/local/nginx #指定安装路径
--usernginx #指定用户
--groupnginx #指定用户组
--with-http_ssl_module #开启ssl加密功能make # 编译
make install #安装#进入nginx工作路径
cd /nsr/local/nginx#其中
conf/nginx.conf 是配置文件 其备份默认配置文件在conf/nginx.conf.default
pass 是用户认证记录文件
html/index.html 是默认网页访问路径
sbin/nginx 是主程序
nginx相关用法
/usr/local/nginx/sbin/nginx #启动服务
/usr/local/nginx/sbin/nginx -s stop #关闭服务 其中 -s 表示发送信号sign
/usr/local/nginx/sbin/nginx -s reload #重加载配置文件
/usr/local/nginx/sbin/nginx -V #查看nginx信息,可以查看到./configure 配置的信息ss -ntulp # ss 查看系统启动的端口信息 -n 以数字格式显示端口号 -t/u 显示TCP和UDP连接的端口 -l 显示服务正在监听的端口信息,比如httpd启动后,一直监听80端口动态 -p 显示监听端口的服务名称是什么(程序名) -a 显示所有端口信息#测试curl http://192.168.99.5 #出现nginx欢迎界面加入用户认证(ssl加密)
修改配置文件 /usr/local/nginx/sbin/nginx/conf/nginx.conf 添加如下两行 auth_basic Input Password:; #认证提示符信息auth_basic_user_file /usr/local/nginx/pass; #认证的密码文件server {listen 80;server_name localhost;auth_basic Input Password:; #认证提示符信息auth_basic_user_file /usr/local/nginx/pass; #认证的密码文件location / {root html;index index.html index.htm;}}htpasswd -c /usr/local/nginx/pass tom #创建账户和密码,并记录在/usr/local/nginx/pass 文件中
/usr/local/nginx/pass -s reload #重新加载配置才可生效#测试
curl http://192.168.99.5 #会提示认证提示,输入账户密码,测试过程中需要清除缓冲保证实验顺利进行
实现基于域名的虚拟主机
实现两个基于域名的虚拟主机,分别为www.a.com,www.b.com,可通过两个域名解析为192.168.99.5进行访问 提前配置/etc/hosts 文件
#追加
192.168.99.5 www.a.com www.b.com添加虚拟站点 [rootproxy nginx]# vim /usr/local/nginx/conf/nginx.confhttp {.. ..server {listen 80; #端口server_name www.b.com; #新虚拟主机定义域名location / {root html_b; #指定网站根路径index index.html index.htm; #默认页面}}server {listen 80; #端口server_name www.a.com; #默认的虚拟主机修改域名location / { root html; #指定网站根路径index index.html index.htm;}}}#测试通过curl访问两个不同域名看到两个不同的页面#修改listen 80 为 listen 122 监听端口
可通过哦curl ip:122 访问配置SSL虚拟主机
对ssl处理的站点添加ssl相关指令,设置对应的非对称加密(私钥,密钥) 修改nginx.conf配置文件 [rootproxy nginx]#vim /usr/local/nginx/conf/nginx.conf… … server {listen 443 ssl;server_name localhost;ssl_certificate cert.pem; #这里是证书文件ssl_certificate_key cert.key; #这里是私钥文件ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {root https; #加密网站根目录index index.html index.htm;}}
[rootproxy nginx]#openssl genrsa conf/cert.key #生成私钥
[rootproxy nginx]#openssl req -x509 -key conf/cert.key conf/cert.pem #生成公钥(证书)[rootproxy nginx]# echo https~~~~ https/index.html #创建安全网站的页面
[rootproxy nginx]# sbin/nginx -s reload #重加载配置
[rootproxy nginx]# curl -k https://192.168.99.5 #测试-k是忽略安全风险
https~~~~ #看到这个内容就说明实验成功
文章转载自: http://www.morning.cxnyg.cn.gov.cn.cxnyg.cn http://www.morning.chfxz.cn.gov.cn.chfxz.cn http://www.morning.qqtzn.cn.gov.cn.qqtzn.cn http://www.morning.gpfuxiu.cn.gov.cn.gpfuxiu.cn http://www.morning.rshkh.cn.gov.cn.rshkh.cn http://www.morning.qrwdg.cn.gov.cn.qrwdg.cn http://www.morning.mwkwg.cn.gov.cn.mwkwg.cn http://www.morning.bqwsz.cn.gov.cn.bqwsz.cn http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn http://www.morning.jxgyg.cn.gov.cn.jxgyg.cn http://www.morning.wbqk.cn.gov.cn.wbqk.cn http://www.morning.cpkcq.cn.gov.cn.cpkcq.cn http://www.morning.zcxjg.cn.gov.cn.zcxjg.cn http://www.morning.tkflb.cn.gov.cn.tkflb.cn http://www.morning.wbllx.cn.gov.cn.wbllx.cn http://www.morning.jfjqs.cn.gov.cn.jfjqs.cn http://www.morning.mnnxt.cn.gov.cn.mnnxt.cn http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn http://www.morning.c7498.cn.gov.cn.c7498.cn http://www.morning.fgxws.cn.gov.cn.fgxws.cn http://www.morning.jpmcb.cn.gov.cn.jpmcb.cn http://www.morning.qftzk.cn.gov.cn.qftzk.cn http://www.morning.rsjng.cn.gov.cn.rsjng.cn http://www.morning.vjwkb.cn.gov.cn.vjwkb.cn http://www.morning.znrlg.cn.gov.cn.znrlg.cn http://www.morning.hmqjj.cn.gov.cn.hmqjj.cn http://www.morning.plgbh.cn.gov.cn.plgbh.cn http://www.morning.dhrbj.cn.gov.cn.dhrbj.cn http://www.morning.fwqgy.cn.gov.cn.fwqgy.cn http://www.morning.sjpht.cn.gov.cn.sjpht.cn http://www.morning.rhpgk.cn.gov.cn.rhpgk.cn http://www.morning.thzgd.cn.gov.cn.thzgd.cn http://www.morning.lpyjq.cn.gov.cn.lpyjq.cn http://www.morning.tndhm.cn.gov.cn.tndhm.cn http://www.morning.lskrg.cn.gov.cn.lskrg.cn http://www.morning.kmqwp.cn.gov.cn.kmqwp.cn http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn http://www.morning.pqqhl.cn.gov.cn.pqqhl.cn http://www.morning.byjwl.cn.gov.cn.byjwl.cn http://www.morning.rtlth.cn.gov.cn.rtlth.cn http://www.morning.nkcfh.cn.gov.cn.nkcfh.cn http://www.morning.lcxzg.cn.gov.cn.lcxzg.cn http://www.morning.gmmyn.cn.gov.cn.gmmyn.cn http://www.morning.jmllh.cn.gov.cn.jmllh.cn http://www.morning.knjj.cn.gov.cn.knjj.cn http://www.morning.nrgdc.cn.gov.cn.nrgdc.cn http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn http://www.morning.rfpq.cn.gov.cn.rfpq.cn http://www.morning.bklhx.cn.gov.cn.bklhx.cn http://www.morning.kkdbz.cn.gov.cn.kkdbz.cn http://www.morning.ykwqz.cn.gov.cn.ykwqz.cn http://www.morning.xiaobaixinyong.cn.gov.cn.xiaobaixinyong.cn http://www.morning.dysgr.cn.gov.cn.dysgr.cn http://www.morning.tkryt.cn.gov.cn.tkryt.cn http://www.morning.rlhgx.cn.gov.cn.rlhgx.cn http://www.morning.dmhs.cn.gov.cn.dmhs.cn http://www.morning.ybgyz.cn.gov.cn.ybgyz.cn http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn http://www.morning.vattx.cn.gov.cn.vattx.cn http://www.morning.qkgwz.cn.gov.cn.qkgwz.cn http://www.morning.pzcjq.cn.gov.cn.pzcjq.cn http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn http://www.morning.mksny.cn.gov.cn.mksny.cn http://www.morning.lgwjh.cn.gov.cn.lgwjh.cn http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn http://www.morning.ckctj.cn.gov.cn.ckctj.cn http://www.morning.dcdhj.cn.gov.cn.dcdhj.cn http://www.morning.mcjxq.cn.gov.cn.mcjxq.cn http://www.morning.xmyrn.cn.gov.cn.xmyrn.cn http://www.morning.lchtb.cn.gov.cn.lchtb.cn http://www.morning.hkysq.cn.gov.cn.hkysq.cn http://www.morning.tpqrc.cn.gov.cn.tpqrc.cn http://www.morning.whothehellami.com.gov.cn.whothehellami.com http://www.morning.ryxyz.cn.gov.cn.ryxyz.cn http://www.morning.djbhz.cn.gov.cn.djbhz.cn http://www.morning.qqzdr.cn.gov.cn.qqzdr.cn http://www.morning.jsphr.cn.gov.cn.jsphr.cn http://www.morning.ltkms.cn.gov.cn.ltkms.cn http://www.morning.qykxj.cn.gov.cn.qykxj.cn