nginx 安装
nmtui ############配IP
nmcli connection modify
192.168.2.5
192.168.4.5
[root@localhost /]# nmcli device # 看网卡
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet connected eth1
eth2 ethernet connected eth2
eth3 ethernet connected eth3
lo loopback unmanaged –
nmcli connection add ifname eth1 con-name eth1 type ethernet
添加一块 eth1 的以太网卡
[root@localhost /]# nmcli connection modify eth3 ipv4.method manual ipv4.address 192.168.1.22 配IP
[root@localhost /]# nmcli connection up eth1 # 激活网卡
[ 1056.051232] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
[root@room9pc01 ~]# virsh list 看虚拟机
Id 名称 状态
1 stu_node01 running
________________________________________–
传文件
scp ‘/root/桌面/lnmp_soft.tar.gz’ @192.168.4.5:/
tar -xf lnmp_soft.tar.gz
cd /lnmp_soft
tar -xf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
yum -y install gcc pcre-devel openssl-devel
make && make install make;编译 make install :安装程序
[root@localhost /]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure \
–prefix=/usr/local/nginx \
–user=nginx
–group=nginx
–with-http_ssl_module
使用户从root脱离,只是在nginx 中使用, 降低恶意软件的危害
[root@localhost nginx-1.12.2]# netstat -ntulp 看网络端口状态
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 794/sshd
[root@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx -V 查看软件的安装信息
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module (安全模块)
##[root@localhost nginx-1.12.2]# ./configure --prefix==xxx 修改,然后make&&m i
conf :配置文件 html ; 默认网页根路径 logs: 日志 sbin :主程序
[root@localhost /]# cd /usr/local/nginx
[root@localhost nginx]# sbin/nginx
[root@localhost nginx]#curl 192.168.4.5
______________________-
[root@localhost nginx]# sbin/nginx
nginx: [emerg] getpwnam(“nginx”) failed
[root@localhost nginx]# useradd -s /sbin/nologin -M nginx (添加用户)
[root@localhost /]# cd lnmp_soft/. 找到www_template.zip
#yum -y install unzip #解压zip
unzip www_template.zip
[root@localhost lnmp_soft]# cp -r www_template/* /usr/local/nginx/html/
cp:是否覆盖"/usr/local/nginx/html/index.html"? y
_________________________###########
用户认证
[root@localhost nginx]# cd conf
vim +38 nginx.conf #打开配置文件
38行
auth_basic “input password”;
auth_basic_user_file “/usr/local/nginx/pass”;
[root@localhost nginx]# sbin/nginx -s reload #重新读取配置文件
[root@localhost nginx]# yum -y install httpd-tools #生成网站账户用户名和密码
[root@localhost nginx]# htpasswd -c /usr/local/nginx/pass tom # 创建 (追加不用c)
New password:
Re-type new password:
Adding password for user tom
[root@localhost nginx]# cat /usr/local/nginx/pass
tom:
a
p
r
1
apr1
apr1VOxUJFnt$dst3y1FkA14.6Bs8s20MI0
_______________________________________________________–
server {
listen 80;
server_name www.a.com
root “/usr/local/nginx/html” ;
}
域名解析
vim /etc/hosts
192.168.2.5 www.a.com
windows:
C:\Windows\System32\drivers\etc\hosts
########################################
搭建安全web
https
[root@localhost nginx]# sha256sum pass
6d856f0a0d72d4daacd3477b93b8d99758aad95ad65bb99e9fa616276c23a636 pass
[root@localhost nginx]# md5sum pass
d93a04b3e011e4cbb7c674a61dfcbd66 pass