lamp ======linux apache mysql php
curl -I www.yuku.com ##查看优酷用的什么服务器##
###apache的安装部署
yum install httpd -y ##apache软件
yum install http-manual ##apache的手册
systemctl start httpd
systemctl enable httpd
systemctl start firewalld
firewall-cmd --list-all ##列出火墙信息
firewall-cmd --permanent --add-service=http##永远允许http
firewall-cmd --reload ##火墙重新加载
1.apchece
企业中常用的的web服务,用来提供http://(超文本传输协议)
/var/www/html ##apache的/目录,默认发布目录
/var/www/html/index.html ##apache的默认发布文件
vim /var/www/html/index.html
<h1> hello world </h1>
:wq
##测试 http://172.25.254.149
http://172.25.254.100/manual
###apache 的基础信息
##主配置目录 /etc/httpd/conf
###主配置文件 /etc/httpd/conf/httpd.conf
###子配置目录 /etc/httpd/conf.d/
##子配置文件: /etc/httpd/conf.d/*.conf
默认发布目录 /var/www/html
默认发布文件 index.html
默认端口 80
默认安全上下文 httpd_sys_content_t
程序开启默认用户 apache
apache日志 /etc/httpd/logs/*
###修改默认端口##
vim /etc/httpd/conf/httpd.conf
修改42行 8080
systemctl restart httpd
netstat -antlupe | grep 8080 ##显示端口
firewall-cmd --permanent --add-port=8080/tcp ##增加8080端口的http
firewall-cmd --reload
测试:172.25.254.149:8080
###默认发布目录的修改##
vim /etc/httpd/conf/httpd.conf
mkdir /westos/html -p
cd /westos/html
vim index.html
(hello123)
修改120行 DocumentRoot "/westos/html"
<Directory "/westos/html"> ###默认发布目录
Require all granted ###提供所有权限
DirectoryIndex index.html ### 默认发布文件
</Directory>
systemctl restart httpd
###修改默认发布文件
默认发布文件就是访问apache时没有指定文件名称时默认访问的文件这个文件可以指定多个,有访问顺序
vim /etc/httpd/conf/httpd.conf
164 DirectoryIndex index.html test.html ##当index.html不存在时访问test.html
systemctl restart httpd
###apach允许登陆###
mkdir /var/www/html/westos
vim /var/www/html/westos/index.html
vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/westos">
Order Allow,Deny ##后者会覆盖前者
Allow from All
Deny from 172.25.254.49
</Directory> ###不允许49去登陆,其他人可以登陆
systemctl restart httpd
测试:http://172.25.254.149/westos 在49主机中做,发现等不上去
####拒绝登陆
vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/westos">
Order Deny,Allow
Allow from 172.25.254.49
Deny from All
</Directory> ###允许49去登陆,其他人不可以登陆
systemctl restart httpd
测试:http://172.25.254.149/westos 在49主机中做,发现登上去
###允许指定用户去登陆
cd /etc/httpd/conf
ls
htpasswd -cm westosuser admin ##加c创建,会覆盖
cat westosuser
admin:$apr1$sqDHbOUX$g1aGQkStw4xvtQD.iJjN4/
htpasswd -m westosuser admin1
cat westosuser
admin:$apr1$sqDHbOUX$g1aGQkStw4xvtQD.iJjN4/
admin1:$apr1$QwSiZqT8$on4.ERugD1SDs0BAn8xo8/
vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/westos">
#Order Deny,Allow
#Allow from 172.25.254.49
#Deny from All
AuthUserFile /etc/httpd/conf/westosuser
AuthType basic
AuthName "Please input your name and password !!"
Require user admin
# Require valid-user
</Directory>
systemctl restart httpd
测试: http://172.25.254.149/westos
#####允许所有用户登陆,admin,admin1
<Directory "/var/www/html/westos">
#Order Deny,Allow
#Allow from 172.25.254.49
#Deny from All
AuthUserFile /etc/httpd/conf/westosuser
AuthType basic
AuthName "Please input your name and password !!"
# Require user admin
Require valid-user
</Directory> ##只允许所有用户登陆
systemctl restart httpd
测试:http://172.25.254.149/westos
###不同的解析###
首先在真机做解析
vim /etc/hosts
172.25.254.149 www.westos.com news.westos.com music.westos.com
在虚拟机中做
mkdir /var/www/virtual/news/html -p
mkdir /var/www/virtual/music/html -p
vim /var/www/virtual/news/html/index.html
vim /var/www/virtual/music/html/index.html
cd /etc/httpd/conf.d
ls
vim a_default.conf
<Virtualhost _default_:80>
DocumentRoot /var/www/html
CustomLog logs/default.log combined
</Virtualhost>
vim /etc/httpd/conf/httpd.conf
注释以前写的允许谁登陆
vim new.conf
<VirtualHost *:80>
ServerName news.westos.com
DocumentRoot /var/www/virtual/news/html
Customlog logs/news.log combined
</VirtualHost>
<Directory "/var/www/virtual/news/html">
Require all granted
</Directory>
vim music.conf
<VirtualHost *:80>
ServerName music.westos.com
DocumentRoot /var/www/virtual/music/html
Customlog logs/music.log combined
</VirtualHost>
<Directory "/var/www/virtual/music/html">
Require all granted
</Directory>
systemctl restart httpd
测试: news.westos.com music.westos.com
############语言的转换##
yum install php -y
cd /var/www/html
ls
vim index.php
<?php
phpinfo();
?>
systemctl restart httpd
测试: http://172.25.254.149/index.php
http://172.25.254.149/manual
###cgi语言###
yum install httpd-manual
cd /var/www/html/
ls
mkdir cgi
ls
cd cgi
ls
vim index.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n"; ###进manual里面复制
print `date`;
chmod 755 index.cgi
./index.cgi ##查命令是否正确
cd /etc/httpd/conf.d
vim a_default.conf
在后面加
<Directory “/var/www/html/cgi">
Options +ExecCGI ##进manual 里面复制
AddHandler cgi-script .cgi
</Directory>
systemctl restart httpd
测试:172.25.254.149/cgi/index.cgi
#####制造钥匙和锁,生成认证
yum install mod_ssl
yum install crypto-utils
genkey www.westos.com(一个no,1024,敲键盘)
复制钥匙和锁
cd /etc/httpd/conf.d
vim ssl.conf
在100和109行加钥匙和锁。注释以前的
systemctl restart httpd
测试:https://172.25.254.149 https://www.westos.com
2.cp news.conf login.conf
ls
vim login.conf
<VirtualHost *:443>
ServerName login.westos.com
DocumentRoot /var/www/virtual/login/html
Customlog logs/login.log combined
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/www.redhat.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/www.redhat.com.key
</VirtualHost>
<Directory "/var/www/virtual/login/html">
Require all granted
</Directory>
<VirtualHost *:80>
ServerName login.westos.com
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</VirtualHost>
mkdir -p /var/www/virtual/login/html
vim /var/www/virtual/login/html/index.html(写内容login)
systemctl restart httpd
测试:login.westos.com
在真机中加vim /etc/hosts
login.westos.com
#####squid翻墙###
关闭两主机的火墙
首先让虚拟机能上网,加网关加dns 全局网关114.114.114.114
systemctl restart network
route -n(查网关)
yum install squid -y
systemctl start squid
netstat -antlpe | grep squid
tcp6 0 0 :::3128 :::* LISTEN 0 199452 9621/(squid-1)
vim /etc/squid/squid.conf(改56行。将deny改allow,取消注释62行)
systemctl restart squid
在另外一个不能上网的主机中输入firefox。打开长方形,network,setting,选全局,可以上网
#######cdn加速##
在主机中vim /etc/hosts 加172.25.254.249 www.westos.com
在令一台虚拟机中
改ip 改yum源
yum clean all
yum repolist
yum install squid -yname
netstat -antlupe | grep 80
vim /etc/squid/squid.conf(改56行。改62行,改80端口,后面加下列东西
http_port 80 vhost vport
cache_peer 172.25.254.149 parent 80 0 proxy-only round-robin originserver name=web1
cache_peer 172.25.254.124 parent 80 0 proxy-only round-robin originserver name=web2
cache_peer_domain web1 web2 www.westos.com
systemctl restart squid
测试:www.westos.com 看是否轮询在真实主机中