要求
1、配置linux客户端免密登录服务端linux主机的root用户
2、配置web服务器,当访问网站www.haha.com时显示:haha
3、配置web服务器,当访问网站www.xixi.com/secret/显示:this is secret
一、配置linux客户端免密登录服务端linux主机的root用户
1、在SSH服务器所在机器上#
(1)、以root用户登录,更改ssh配置文件 /etc/ssh/sshd_config,去除以下配置的注释
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
(2)、重启SSH服务
[root@server /]
2、在客户端机器上#
(1)、生成公钥和私钥
[root@client /]
一路默认回车,系统在/root/.ssh下生成id_rsa、id_rsa.pub
(2)、把id_rsa.pub发送到服务端机器上
[root@client /]
(3)、验证
[root@client /]
二、配置web服务器,当访问网站www.haha.com时显示:haha
(1)、在/etc/hosts文件中添加IP对应的域名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.48.128 www.haha.com
(2)、创建静态资源存放的目录
[root@128-service data]
.
├── haha
│ └── index.html
└── nginx
├── haha.txt
├── hello.html
└── ykzhaopian.jpg
2 directories, 4 files
(3)、添加服务配置文件在/etc/nginx/conf.d/*.conf;
[root@128-service conf.d]
.
├── haha.conf
└── static.conf
0 directories, 2 files
[root@128-service conf.d]
/etc/nginx/conf.d
(4)、编辑haha.conf
server {
listen 192.168.48.128:80;
server_name www.haha.com;
root /data/haha;
location / {index index.html;}
}
(5)、检查语法,重启nginx
nginx -t
nginx -s reload
(6)使用curl获取指定的URL
[root@128-service conf.d]
haaa
三、配置web服务器,当访问网站www.xixi.com/secret/显示:this is secret
(1)、在/etc/hosts文件中添加IP对应的域名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.48.128 www.haha.com
192.168.48.110 www.xixi.com
(2)、创建静态资源存放的目录
[root@128-service xixi]
/data/xixi
└── secret
└── index.html
1 directory, 1 file
(3)、添加服务配置文件在/etc/nginx/conf.d/*.conf;
server {
listen 192.168.48.110:80;
server_name www.xixi.com;
root /data/xixi;
location / {}
}
(5)、检查语法,重启nginx
[root@128-service xixi]
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@128-service xixi]
nginx: invalid option: "-s relaod"
[root@128-service xixi]
(6)使用curl获取指定的URL
[root@128-service xixi]
this is secret