阿帕奇

作者: ivan_cq | 来源:发表于2018-08-22 12:48 被阅读0次

yum install httpd -y安装
我首先重置了虚拟机。安装后启动httpd。此时无法使用。



关闭防火墙后,可以使用,不过由于默认发布目录为空,并不能显示界面。



生成共享文件 : vim /var/www/html/index.html
此时可以访问,并且看到内容。



httpd的访问控制

<Directory "/var/www/html/cq">
order deny,allow 顺序,意思时allow会覆盖掉deny策略
allow from 172.25.254.67 设置允许
deny from all 设置拒绝
</Directory>



cd /etc/httpd/conf
ls
htpasswd -cm cquser admin 创建访问用户
htpasswd -m cquser admin 再次创建
vim /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/cq">
AuthUserFile /etc/httpd/conf/cquser
AuthType basic
AuthName "please input your name and password!"
Require user admin 仅仅允许这个用户输入密码登陆
</Directory>




阿帕奇的虚拟主机功能

注释掉之前的配置。

mkdir /var/www/virtual/newshtml
mkdir /var/www/virtual/music/html
vim /var/www/virtual/news/html/index.html
vim /var/www/virtual/music/html/index.html
cd /etc/httpd/conf.d/
vim a_default.conf
vim news.conf
vim music.conf
[root@cq conf.d]# cat a_default.conf
<Virtualhost default:80>
documentroot /var/www/html
customlog logs/default.log combined
</Virtualhost>
[root@cq conf.d]# cat news.conf
<Virtualhost> *:80>
servername news.westos.com
documentroot /var/www/virtual/av/html
customlog logs/news.log combined
</Virtualhost>
<Directory "/var/www/virtual/news/html">
require all granted
</Directory>
[root@cq conf.d]# cat 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>
当这些配置完成之后,需要在浏览器一端设置本地域名解析。
vim /etc/hosts
172.25.254.103 www.westos.com news.westos.com music.default.com

展示结果


最后systemctl restart httpd
总结一下这个思路:
首先呢,先注释掉上一个实验所添加的配置文件。
vim /etc/httpd/conf/httpd.conf
然后呢,我们需要建立虚拟主机。
首先
mkdir /var/www/virtual/news/html
mkdir /var/www/virtual/music/html
vim /var/www/virtual/news/html/index.html
vim /var/www/virtual/music/html/index.html
创建好虚拟主机目录,并且编辑好文件。
然后去配置文件。
vim /etc/httpd/conf.d/a_default.conf
vim /etc/httpd/conf.d/news.conf
vim /etc/httpd/conf.d/music.conf
那么这个配置文件是干什么用的呢?



a_default.conf 默认
<Virtualhost default:80>
documentroot /var/www/html 文件存放目录
customlog logs/default.log combined 日志记录文件



**所以说这个文件的意义就是 默认访问显示的内容,无论你在hosts里面怎样设置解析,都可以看到,从上图的实验可以看出。

music.conf
<Virtualhost> *:80> 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>


linux上的cgi,php等

总体的思路是这样的:
关于php
首先yum install php -y 安装成功 服务器要关闭防火墙

然后编辑网页内容为php的测试页 vim /var/www/html/index.php
<?php
phpinfo();
?>
测试: 172.25.254.103/index.php




测试成功
关于cgi
yum install httpd-manual -y

mkdir /var/www/html/cgi
vim /var/www/html/cgi/index.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print 'date';
chmod 755 index.cgi
然而此时访问却只能访问裸露的代码
此时需要配置 vim /etc/httpd/conf.d/a_default.conf
在manual页上复制
<Directory "/var/www/html/cgi">
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
然后systemctl restart httpd 就成功了



关于https

yum install mod_ssl -y
yum install crypto-utils -y
genkey www.westos.com 生成证书 这个过程要注意进度条读完第一个选项是否
vim ssl.conf
crtl+z fg 1 复制锁和钥匙存的目录到这个配置文件里
systemctl restart httpd
此时访问 https://www.westos.com



但是此时的https不是自动的。
实现自动加锁
cd /etc/httpd/conf.d/
cp news.conf login.conf
vim login.conf
:%s/news/login

mkdir -p /var/www/virtual/login/html
vim /var/www/virtuyum isnal/login/html/index.html
vim /etc/httpd.conf/login.conf
sp /etc/httpd/conf.d/ssl.conf
复制钥匙复制锁
<Virtualhost *:443>
servername login.westos.com
documentroot /var/www/virtual/login/html
customlog logs/login.log combined
SSLEngine on
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
</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>

systemctl restart httpd
测试;
访问 login.westos.com
结果自动加 https


vim login.conf

:

相关文章

  • 阿帕奇

    yum install httpd -y安装我首先重置了虚拟机。安装后启动httpd。此时无法使用。 关闭防火墙后...

  • Struts2起始框架的搭建

    struts1是阿帕奇公司开发的耦合性很高xwork是OpenSystem。后来阿帕奇买了xwork。成就了str...

  • 百倍币18:阿帕奇ARPA,隐私计算引领者

    百倍币18:阿帕奇ARPA,隐私计算引领者 AR阿帕奇ARPA,可为主流公链提供隐私计算协议。 PA独有的多方安全...

  • 阿帕奇女人

    人生是怎样的?有时你可能避免不了一些事的发生,同时你也决定不了你的选择。这对塔拉的父亲来说正是如此,车祸不足以致命...

  • 逆向思维

    当思考问题遇到障碍时,不妨试试逆向思维。 阿帕奇族是美洲的原住民,在西班牙人征服美洲时,遭到了阿帕奇族的顽强抵抗。...

  • 跛脚女人|140字微小说

    卡尼尔是个漂亮女人。 阿帕奇从小嫉妒她。 卡尼尔十三岁时,阿帕奇突然问她,你的腿怎么了?然后捂住嘴惊叹自己居然一直...

  • Xampp Apache 无法启动

    今天一如既往的打开xampp的阿帕奇服务器,无缘无故的打不开,貌似80端口被占用,或者是mac自带的阿帕奇服务器已...

  • 你当像鸟飞往你的山2

    事情因果相关,事物累积量变产生质变,在历史的巨轮下格外显眼。一如沙漠中黑色沉积物,一如阿帕奇眼泪的传说。阿帕奇的女...

  • 男孩子还是得多和爸爸玩儿

    今天天儿爸在家,一大早天儿就开始和他爸聊天。 从斯基马萨龙、多智龙、镰刀龙到天眼,从天眼到阿帕奇,从阿帕奇到石墨烯...

  • mac搭建阿帕奇Apache

    http://blog.csdn.net/number_five/article/details/51539186

网友评论

      本文标题:阿帕奇

      本文链接:https://www.haomeiwen.com/subject/ctkpbftx.html