标签:linux
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
标签:linux
原文地址:http://12119652.blog.51cto.com/12109652/1882829