apache的虛拟主機加密和apache的網頁重寫
配置基礎的虛拟主機擷取加密認證
(虛拟主機news.westos.com)
cd /etc/httpd/conf.d
vim news.conf
<Virtualhost *:80>
Servername news.westos.com
Documentroot /var/www/virtual/news.westos.com/html
Customlog logs/news.log combined
</Virtualhost>
<Directory "/var/www/virtual/news.westos.com/html">
Require all granted
</Directory>
<Virtualhost *:443> 可以通路443端口(https端口)
Servername news.westos.com 主機名
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 key
systemctl restart httpd 重新開機服務
『可以通路http也可以通路https』
網頁重寫
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301] 當通路http時帶他通路https
<Virtualhost *:443>
Customlog logs/news-443.log combined
SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
『無論通路http還是https最後都通路的時https』

apache的php和cgi
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
CGI:
mkdir cgi
ls cgi
yum install httpd-manual.noarch -y 安裝manual(查找cgi需要的指令)
vim index.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print `date`;
perl index.cgi 測試cgi是否可用
chmod +x index.cgi 賦予執行權限
cd /etc/httpd/conf.d/
vim default.conf
<Virtualhost _default_:80>
Documentroot /var/www/html
Customlog "logs/default.log" combined
<Directory "/var/www/html/cgi"> 讀取的檔案
Options +ExecCGI 有執行權限
AddHandler cgi-script .cgi
制作網站
yum install mariadb-server.x86_64 -y 安裝資料庫服務
systemctl start mariadb 開啟服務
vim /etc/my.cnf 資料庫配置檔案
skip-networking=1 不将資料庫暴露在網絡上
mysql_secure_installation 資料庫基礎配置
cd /var/www/html
lftp 172.25.254.250 擷取網站需要的檔案
unzip Discuz_X3.2_SC_UTF8.zip 解壓
chmod 777 upload/ -R 按要求賦予權限
yum install php-mysql.x86_64 -y 安裝服務
正向代理
代理方:
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
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
SHELL腳本
1.基本運算
++自加 -- 自減 **幂運算 /除法 %餘數 +=加等 -=減等
2.for;do;done 語句
for NAME in tom jack westos;do echo This is $NAME;done
3.[]數字運算比較符 -z 為空 -n 不為空
-eq 等于-lt小于 -le小于等于 -gt 大于 -ge大于等于
檔案狀态運算符
-d 裝置 -c字元 -e是否可執行 -L軟連結 -d目錄 -f普通檔案
二進制檔案運算符
-ef 比較是否互為硬連結
-nt比較兩個檔案的時間戳哪個更新 或者-ot
邏輯運算符
-o或者
-a并且
!否
&&如果成立的話執行
||如果不成立的話執行
4.檢查檔案屬性
#!/bin/bash
if
[ -e "$1" ]
then
[ -f "$1" -a ! -L "$1" ] && echo $1 is a file 是檔案且不是連接配接
[ -b "$1" ] && echo $1 is a block 是裝置
[ -c "$1" ] && echo $1 is a c-block
[ -n "$1" ] && echo $1 is not exist || echo "Please give me a file "
fi