首页 > 代码库 > 笔记13

笔记13

apache的虚拟主机加密和apache的网页重写


apache的虚拟主机加密和apache的网页重写

关闭火墙,配置好加密证书

[root@desktop upload]# cd /etc/httpd/conf.d/

[root@desktop conf.d]# ls

autoindex.conf  manual.conf  php.conf  ssl.conf    userdir.conf

default.conf    news.conf    README    tmprequest  welcome.conf

[root@desktop conf.d]# vim news.conf ##vim sp /etc/httpd/conf.d/ssl.conf打开俩个窗口 ,用ctrl+w进行选择

<Virtualhost *:80>

        ServerName news.westos.com

        RewriteEngine on

        RewriteRule  ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

</Virtualhost>

<Directory "/var/www/virtual/news/html">

        Require all granted

</Directory>

<Virtualhost *:443>

        serverName news.westos.com

        DocumentRoot /var/www/virtual/news/html

        Customlog logs/news-443.log combined

        SSLEngine on

        SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt##证书目录

        SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key

</Virtualhost>

[root@desktop conf.d]# vim default.conf

<Virtualhost _default_:80>

        DocumentRoot /var/www/html

        CustomLog logs/default.log      combined

</Virtualhost>

[root@desktop conf.d]# mkdir -p /var/www/virtual/news/html/

[root@desktop conf.d]# vim /var/www/virtual/news/index.html

hello word

wq

测试 http://news.westos.com 自动变为https://news.westos.com/

 

PHP

cd /var/www/html/

vim index.php

<?php

phpinfo ();php检测页面

?>

 

vim /etc/httpd/conf/httpd.conf

163 <IfModule dir_module>

164     DirectoryIndex index.php index.html优先读取php

yum install php -y安装php

systemctl restart httpd重启服务

 

 

CGI网络配置(http://172.25.254.126/manual选择CGI查看需要添加的参数配置)

yum install httpd-manual -y

cd /etc/httpd/conf.d/

cd /var/www/html/

mkdir cgi

cd cgi/

vim index.cgi

#!/usr/bin/perl

print "Content-type: text/html\n\n";##网页显示时间

print `date`;

 perl index.cgi ##检测CGI是否可用

vim /etc/httpd/conf.d/default.conf

在后面加入

<Directory "/var/www/html/cgi">##读取文件

        Options +ExecCGI##有执行权限

        AddHandler cgi-script .cgi

</Directory>

 cd /var/www/

[root@desktop cgi]# cd /var/www/

[root@desktop www]# ls -Zd cgi-bin/

drwxr-xr-x. root root system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin/

[root@desktop www]# semanage fcontext -a -t httpd_sys_script_exec_t ‘/var/www/html/cgi(/.*)?‘##更改安全上下文

[root@desktop www]# cd html/

[root@desktop html]# cd cgi/

[root@desktop cgi]# ls

index.cgi

[root@desktop cgi]# chmod +x index.cgi##index.cgi权限

火墙和selinux要关掉

测试http://172.25.254.126/cgi/index.cgi

Fri Dec 9 23:42:20 EST 2016

 

 

论坛建立

[root@desktop html]# yum install mariadb -y

[root@desktop html]# yum install php-mysql.x86_64 -y

[root@desktop html]# yum install mariadb-server.x86_64

[root@desktop html]# systemctl start mariadb

[root@desktop html]# mysql_secure_installation

[root@desktop upload]# yum install php

[root@desktop cgi]# mv Discuz_X3.2_SC_UTF8.zip /var/www/html/

[root@desktop cgi]# cd /var/www/html/

[root@desktop html]# ls

cgi  Discuz_X3.2_SC_UTF8.zip  index.php

[root@desktop html]# unzip Discuz_X3.2_SC_UTF8.zip

[root@desktop html]# ls

cgi  Discuz_X3.2_SC_UTF8.zip  index.php  readme  upload  utility

[root@desktop html]# chmod  777 upload/ -R##upload目录权限

[root@desktop html]# setenforce 0

[root@desktop ~]# systemctl restart httpd.service

 

 

 

 

 

 

 

 

 

正向代理

代理方:

yum install squid -y安装服务

vim /etc/squid/squid.conf

 56 http_access allow all允许所有访问

 62 cache dir ufs /var/spool/squid 100 16 256

 

systemctl start squid开启服务

 

被代理方进行测试

 

 

 

反向代理

服务端:

yum install squid安装服务(需要没有http

vim /etc/squid/squid.conf修改配饰文件

 56 http_access allow all允许所有人访问

 57

 58 # Squid normally listens to port 3128

 59 http_port 80 vhost vport使用80端口(虚拟主机 虚拟端口)

 60 cache_peer 172.25.254.25 parent 80 0 no-query访问ip 父级 端口 邻居端口 不使用邻居端口

 61 # Uncomment and adjust the following to add a disk cache directory.

 62 cache_dir ufs /var/spool/squid 100 16 256缓存位置

 

 

 

轮询

vim /etc/squid/suid.conf

 56 http_access allow all

 57

 58 # Squid normally listens to port 3128

 59 http_port 80 vhost vport

 60 cache_peer 172.25.254.25 parent 80 0 no-query originserver round-robin name    =web1轮询一ip

 61 cache_peer 172.25.254.24 parent 80 0 no-query originserver round-robin name    =web2轮询二ip

 62 cache_peer_domain web1 web2 www.westos.com 轮询所对应的域名

 63 # Uncomment and adjust the following to add a disk cache directory.

 64 cache_dir ufs /var/spool/squid 100 16 256

 

 

scripts






SHELL

倒计时





#!/bin/bash





for ((b=10;b>0;b--))




do





echo -ne "After

1M${b}s is GG "




echo -ne "\r

\r"




sleep 1





done





for ((a=60;a>0;a--))




do





echo -ne "After

${a}s  is GG " #-n 不换行;-e执行



echo -ne "\r

\r"




sleep 1





done





while





le <=





a 并且





gt >=





#!/bin/bash





for ((a=1;a<=10;a++))




do





ping -c1 -w1 172.25.254.${a} &>/dev/null

#c1 ping 1  w1

等一秒

while





[ "$?" -eq "0" ]




do





echo "172.25.254.${a} is up"




break





done





while





[ "$?" -ne "0" ]




do





echo "172.25.254.${a} is down"




break





done





done





备份数据库





#!/bin/bash





for a in $(mysql -uroot -predhat -e "show databases;"

-NE | grep -E "^\*|schema$" -v )

do





mysqldump -uroot -predhat $a  > /mnt/abc




done





#!/bin/bash





for ((a=1;a<=10;a++))




do





ping -c1 -w1 172.25.254.${a} &>/dev/null




while





[ "$?" -eq "0" ]




do





echo "172.25.254.${a} is up"




break





done





while





[ "$?" -ne "0" ]




do





echo "172.25.254.${a} is down"




break





done





done





[]数字运算比较符 -z

为空 -n 不为空





文件:/home/kiosk/桌面/shell 2 页,共 2 

技术分享 

-eq 等于-lt小于 -le小于等于 -gt 大于 -ge大于等于文件状态运算符

-d 设备 -c字符 -e是否可执行 -L软链接 -d目录 -f普通文件二进制文件运算符

-ef 比较是否互为硬链接-nt比较两个文件的时间戳哪个更新 或者-ot

 

逻辑运算符

 

-o或者

 

-a并且

 

       !  

 

&& 如果成立的话执行

 

||  如果不成立的话执行


笔记13