您的位置:首页 > 运维架构 > Linux

Linux学习笔记

2016-12-14 21:32 429 查看
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 主机名
Documentroot /var/www/virtual/news.westos.com/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 key
</Virtualhost>

systemctl restart httpd 重启服务
『可以访问http也可以访问https』

网页重写
vim news.conf
<Virtualhost *:80>
Servername news.westos.com
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301] 当访问http时带他访问https
</Virtualhost>
<Directory "/var/www/virtual/news.westos.com/html">
Require all granted
</Directory>
<Virtualhost *:443>
Servername news.westos.com
Documentroot /var/www/virtual/news.westos.com/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>

systemctl restart httpd 重启服务
『无论访问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
systemctl restart httpd 重启服务

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
</Virtualhost>
<Directory "/var/www/html/cgi"> 读取的文件
Options +ExecCGI 有执行权限
AddHandler cgi-script .cgi
</Directory>

制作网站
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 安装服务
systemctl restart httpd 重启服务






正向代理
代理方:
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

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux