标签:有一个 nbsp 部署 mes ip地址 名称 NPU nta inpu
1 [root@proxy ~]# yum -y install gcc pcre-devel openssl-devel //安装依赖包 2 [root@proxy ~]# useradd -s /sbin/nologin nginx 3 [root@proxy ~]# tar -xf nginx-1.10.3.tar.gz 4 [root@proxy ~]# cd nginx-1.10.3 5 [root@proxy nginx-1.10.3]# ./configure 6 > --prefix=/usr/local/nginx //指定安装路径 7 > --user=nginx \ //指定用户 8 > --group=nginx \ //指定组 9 > --with-http_ssl_module //开启SSL加密功能模块 10 [root@proxy nginx-1.10.3]# ./configure --help | grep ssl //记不清时可以此查找相关模块 11 [root@proxy nginx-1.10.3]# make && make install //编译并安装
1 [root@proxy ~]# /usr/local/nginx/sbin/nginx //启动服务 2 [root@proxy ~]# /usr/local/nginx/sbin/nginx -s stop //关闭服务 3 [root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload //重新加载配置文件 4 [root@proxy ~]# /usr/local/nginx/sbin/nginx –V //查看软件信息 5 [root@proxy ~]# ln -s /usr/local/nginx/sbin/nginx /sbin/ //方便后期使用
1 root@proxy ~]# netstat -anptu | grep nginx 查询nginx服务是否开启
1 [root@proxy ~]# firewall-cmd --set-default-zone=trusted 2 [root@proxy ~]# setenforce 0
1 [root@proxy ~]# tar -zxvf nginx-1.12.2.tar.gz 2 [root@proxy ~]# cd nginx-1.12.2 3 [root@proxy nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module 4 [root@proxy nginx-1.12.2]# make
1 [root@proxy nginx-1.12.2]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginxold 2 [root@proxy nginx-1.12.2]# cp objs/nginx /usr/local/nginx/sbin/ //拷贝新版本 3 [root@proxy nginx-1.12.2]# make upgrade //升级 4 /usr/local/nginx/sbin/nginx -t 5 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok 6 nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 7 kill -USR2 `cat /usr/local/nginx/logs/nginx.pid` 8 sleep 1 9 test -f /usr/local/nginx/logs/nginx.pid.oldbin 10 kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` 11 [root@proxy ~]# /usr/local/nginx/sbin/nginx –v //查看版本 12
1 [root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf 2 全局配置(用户名,日志,进程) 3 http{ 4 server{ 5 listen 80; 6 server_name localhost; 7 root html; 8 } 9 server{ 10 listen 80; 11 server_name www.xyz.com; 12 root www; 13 } 14 }
1 [root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf 2 .. .. 3 server { 4 listen 80; 5 server_name localhost; 6 auth_basic "Input Password:"; //认证提示符 7 auth_basic_user_file "/usr/local/nginx/pass"; //认证密码文件 8 location / { 9 root html; 10 index index.html index.htm; 11 } 12 }
1 [root@proxy ~]# yum -y install httpd-tools 2 [root@proxy ~]# htpasswd -c /usr/local/nginx/pass tom //创建密码文件 3 New password: 4 Re-type new password: 5 Adding password for user tom 6 [root@proxy ~]# htpasswd /usr/local/nginx/pass jerry //追加用户,不使用-c选项 7 New password: 8 Re-type new password: 9 Adding password for user jerry 10 [root@proxy ~]# cat /usr/local/nginx/pass
1 [root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload //重新加载配置文件 2 登录192.168.4.100客户端主机进行测试 3 [root@client ~]# firefox http://192.168.4.5 //输入密码后可以访问
1 [root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf 2 .. .. 3 server { 4 listen 80; //端口 5 server_name www.a.com; //域名 6 auth_basic "Input Password:"; //认证提示符 7 auth_basic_user_file "/usr/local/nginx/pass"; //认证密码文件 8 location / { 9 root html; //指定网站根路径 10 index index.html index.htm; 11 } 12 13 } 14 … … 15 server { 16 listen 80; //端口 17 server_name www.b.com; //域名 18 location / { 19 root www; //指定网站根路径 20 index index.html index.htm; 21 } 22 }
1 [root@proxy ~]# mkdir /usr/local/nginx/www 2 [root@proxy ~]# echo "www" > /usr/local/nginx/www/index.html 3 [root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload
1 [root@client ~]# vim /etc/hosts 2 192.168.4.5 www.a.com www.b.com 3 [root@client ~]# firefox http://www.a.com //输入密码后可以访问 4 [root@client ~]# firefox http://www.b.com //直接访问
1 [root@proxy ~]# cd /usr/local/nginx/conf 2 [root@proxy ~]# openssl genrsa > cert.key //生成私钥 3 [root@proxy ~]# openssl req -new -x509 -key cert.key > cert.pem //生成证书
1 [root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf 2 … … 3 server { 4 listen 443 ssl; 5 server_name www.c.com; 6 ssl_certificate cert.pem; #这里是证书文件 7 ssl_certificate_key cert.key; #这里是私钥文件 8 ssl_session_cache shared:SSL:1m; 9 ssl_session_timeout 5m; 10 ssl_ciphers HIGH:!aNULL:!MD5; 11 ssl_prefer_server_ciphers on; 12 13 location / { 14 root html; 15 index index.html index.htm; 16 } 17 }
1 [root@proxy ~]# /usr/local/nginx/sbin/nginx -s reload
1 [root@client ~]# vim /etc/hosts 2 192.168.4.5 www.c.com www.a.com www.b.com
1 [root@client ~]# firefox https://www.c.com //信任证书后可以访问
标签:有一个 nbsp 部署 mes ip地址 名称 NPU nta inpu
原文地址:https://www.cnblogs.com/share368/p/9594265.html