####wsgi服务
[root@apache wsgi]# scp kiosk@172.25.4.250:/home/kiosk/Desktop/script.wsgi /var/www/wsgi ##电脑传输我们准备好的页面
[root@apache conf.d]# vim vhost.conf ###/etc/httpd/conf.d中
1 <VirtualHost *:80>
2 ServerName www.westoswsgi.com
3 WSGIScriptAlias / /var/www/wsgi/script.wsgi
4 < /VirtualHost>
~
[root@apache conf.d]# yum install mod_wsgi -y #####现在软件对页面进行支持
[root@apache conf.d]# vim /etc/hosts ######添加本地域名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.25.254.254 classroom.example.com
172.25.254.250 content.example.com
172.25.4.1 www.westoswsgi.com
systemctl restart httpd
###用浏览器输入域名可以看到我们想要的实验结果
#############正向代理
###网络配置关闭GATEWAY br0 在真机中
[root@foundation4 network-scripts]# vim ifcfg-br0
PREFIX=24
#GATEWAY=172.25.254.250
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
[root@foundation4 network-scripts]# vim /etc/sysconfig/network
#Created by anaconda
#GATEWAY=172.25.254.250
#GATEWAY=172.25.4.250
############真机变路由器
[root@foundation4 network-scripts]# firewall-cmd -permanent --add-masquerade ###允许这项服务
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: -permanent
[root@foundation4 network-scripts]# firewall-cmd --permanent --add-masquerade
Warning: ALREADY_ENABLED: masquerade
success
[root@foundation4 network-scripts]# firewall-cmd --reload
success
[root@foundation4 network-scripts]# firewall-cmd --list-all #####查看防火墙的状态
trusted (active)
target: ACCEPT
icmp-block-inversion: no
interfaces: br0 enp0s25 wlp3s0
sources:
services:
ports:
protocols:
masquerade: yes
forward-ports:
sourceports:
icmp-blocks:
rich rules:
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 ####一台虚拟机网络配置链接真机上网
DEVICE=eth0
BOOTPROTO=none
IPADDR=172.25.4.100
NETMASK=255.255.255.0
GATEWAY=172.25.4.250
DNS1=114.114.114.114
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
PERSISTENT_DHCLIENT=1
######在虚拟机中
[root@localhost ~]# yum install squid -y ###下载squid服务
[root@localhost ~]# vim /etc/squid/squid.conf ###squid的配置文件打开缓存单元,允许别人访问
52 http_access allow localnet
53 http_access allow localhost
62 cache_dir ufs /var/spool/squid 100 16 256
[root@localhost ~]# cd /var/spool/squid
[root@localhost squid]# ls
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F swap.state
[root@localhost squid]# cd 00
[root@localhost 00]# ls
00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 B0 BB C6 D1 DC E7 F2 FD
01 0C 17 22 2D 38 43 4E 59 64 6F 7A 85 90 9B A6 B1 BC C7 D2 DD E8 F3 FE
02 0D 18 23 2E 39 44 4F 5A 65 70 7B 86 91 9C A7 B2 BD C8 D3 DE E9 F4 FF
03 0E 19 24 2F 3A 45 50 5B 66 71 7C 87 92 9D A8 B3 BE C9 D4 DF EA F5
04 0F 1A 25 30 3B 46 51 5C 67 72 7D 88 93 9E A9 B4 BF CA D5 E0 EB F6
05 10 1B 26 31 3C 47 52 5D 68 73 7E 89 94 9F AA B5 C0 CB D6 E1 EC F7
06 11 1C 27 32 3D 48 53 5E 69 74 7F 8A 95 A0 AB B6 C1 CC D7 E2 ED F8
07 12 1D 28 33 3E 49 54 5F 6A 75 80 8B 96 A1 AC B7 C2 CD D8 E3 EE F9
08 13 1E 29 34 3F 4A 55 60 6B 76 81 8C 97 A2 AD B8 C3 CE D9 E4 EF FA
09 14 1F 2A 35 40 4B 56 61 6C 77 82 8D 98 A3 AE B9 C4 CF DA E5 F0 FB
0A 15 20 2B 36 41 4C 57 62 6D 78 83 8E 99 A4 AF BA C5 D0 DB E6 F1 FC
#####在原有真机和虚拟机下再起一台虚拟机中进行测试。打开网页在浏览器中设置如图
http_port 3128
########################反向代理我们自己访问他人的信息并不知跳转的页面
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 ####网络配置
DEVICE=eth0
BOOTPROTO=none
IPADDR=172.25.4.100
NETMASK=255.255.255.0
#GATEWAY=172.25.4.250
#DNS1=114.114.114.114
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
PERSISTENT_DHCLIENT=1
[root@localhost ~]# systemctl restart network
[root@localhost ~]# vim /etc/squid/squid.conf ######squid的配置文件更改
59 #http_port 3128
60 http_port 80 vhost vport
[root@localhost ~]# systemctl restart squid
[root@localhost ~]# netstat -antlupe | grep squid #####管道的查询
tcp6 0 0 :::80 ::? LISTEN 0 108459 4477/(squid-1)
udp 0 0 0.0.0.0:37424 0.0.0.0:* 23 108454 4477/(squid-1)
udp6 0 0 :::35693 ::? 23 108453 4477/(squid-1)
[root@localhost ~]# firewall-cmd --list-all ########现在防火墙的状态
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@localhost ~]# firewall-cmd --permanent --add-service=http #####添加http服务
success
[root@localhost ~]# firewall-cmd --permanent --add-service=https ######添加httpds服务
[root@localhost ~]# firewall-cmd --list-all
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client http https ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@localhost ~]# vim /etc/squid/squid.conf #########当我们访问自己时跳转到他人的ip之上查看信息
59 #http_port 3128
60 http_port 80 vhost vport
62 cache_dir ufs /var/spool/squid 100 16 256
63 cache_peer 172.25.4.250 parent 80 0 proxy-only ###此次我们是以172.25.4.100跳转到172.25.4.250上
[root@localhost ~]# systemctl restart squid
打开浏览器我们输入这台虚拟机的ip 172.25.4.100页面自动调转到172.25.4.250
##完成实验
250画面
100跳转到250
####我们可以再次基础上在加一个调转页面使得在网页上搜索ip 172.25.4.100时可以在 172.25.4.250和172.25.25.4.1之间调转。
~
[root@localhost ~]# vim /etc/squid/squid.conf ####修改配置文件
60 http_port 80 vhost vport
61 # Uncomment and adjust the following to add a disk cache directory.
62 cache_dir ufs /var/spool/squid 100 16 256
63 cache_peer 172.25.4.250 parent 80 0 proxy-only round-robin round-robin originserver name=web1
64 cache_peer 172.25.4.1 parent 80 0 proxy-only round-robin round-robin originserver name=web2 ##增添新的跳转用户
65 cache_peer_domain www.westos.com web1 web2 通过域名的方式进行两个外部资源跳转
66
67 # Leave coredumps in the first cache dir
68 coredump_dir /var/spool/squid
[root@localhost ~]# firefox
进行网页刷新
####还可以对调转到那个ip页面的次数进行设定在cache_peer 后面加weight=2.
进行上传网站和管理一个bbs我们提前下好前端的程序下来进行bbs的搭建
###########特别强调selinux一定要关
一定要做setenforce 0在做完后也要查看selinux的状态getenforce
[root@localhost ~]# yum install httpd ####下载服务
[root@localhost html]# ls
readme upload utility
[root@localhost html]# cd upload
[root@localhost upload]# pwd
/var/www/html/upload
[root@localhost upload]# chmod o+w ./config -R 赋予权限
[root@localhost upload]# chmod o+w ./data/ -R
[root@localhost upload]# chmod o+w ./config/ -R
[root@localhost upload]# yum install php -y ###下载php页面动态的展示
[root@localhost upload]# systemctl restart httpd #####重起httpd使php生效
[root@localhost upload]# yum install mariadb-server ####数据库下载
[root@localhost upload]# vim /etc/my.cnf ####修改数据库配置文件
[mysqld]
skip-networking=1 ### 关闭外部端口。只有有密码的可以进数据库
datadir=/var/lib/mysql
[root@localhost upload]# systemctl restart mariadb
[root@localhost upload]# mysql_secure_installation ###保证数据库安全的装置,设置密码
[root@localhost conf.d]# vim vhost.conf ####设置配置文件的路径
<VirtualHost *:80>
ServerName www.westosbbs.com
DocumentRoot /var/www/html/upload
CustomLog logs/bbs.log combined
[root@localhost conf.d]# vim /etc/hosts ####写入本地解析
[root@localhost upload]# chmod o+w ./config/ -R
[root@localhost upload]# chmod o+w ./data/ -R
selinux一定要关
打开浏览器查找172.25.4.100/upload按照程序进行下一步
[root@localhost conf.d]# setenforce 0
[root@localhost conf.d]# getenforce
Permissive
######再次强调一定要关selinux
不关selinux的话进入页面将会出现下图所示