11月15日任务php
11.18 Apache用户认证html
11.19/11.20 域名跳转linux
11.21 Apache访问日志apache
11.18 Apache用户认证vim
[root@zgxlinux-01 ~]# vim /usr/local/apache2.4.37/conf/extra/httpd-vhosts.conf
浏览器
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/htpasswd -c -m /data/.htppasswd zhangguoxiang #-c 建立 -m 表示md5加密
curl
[root@zgxlinux-01 ~]# cat /data/.htppasswd
zhangguoxiang:$apr1$RKbRex0f$R0QtyiT0EuEsfJmxwSwhl0
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/htpasswd -m /data/.htppasswd zhangsan #这时候不须要指定-c 由于这个文件已经建立过
New password:
Re-type new password:
Adding password for user zhangsan
[root@zgxlinux-01 ~]# cat /data/.htppasswd
zhangguoxiang:$apr1$RKbRex0f$R0QtyiT0EuEsfJmxwSwhl0
zhangsan:$apr1$q/7YWXFI$OQJYI5OfO8in3KdDYi.Eo1
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl -t
Syntax OK
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl graceful
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl graceful
[root@zgxlinux-01 ~]# curl -x127.0.0.1:80 111.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>ide
#针对单文件操做测试
#建立一个123phoui
[root@zgxlinux-01 ~]# vim /data/wwwroot/111.com/123.php
11.19 、域名跳转
#编辑配置文件 /usr/local/apache2.4.37/conf/extra/httpd-vhosts.conf ,301表示永久跳转
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl -t
Syntax OK
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl graceful
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl -M |grep rewrite
[root@zgxlinux-01 ~]# vim /usr/local/apache2.4.37/conf/httpd.conf #修改配置文件,注释这一行,加载module模块。
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl -M |grep rewrite
rewrite_module (shared)
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl -t
Syntax OK
[root@zgxlinux-01 ~]# /usr/local/apache2.4.37/bin/apachectl graceful
[root@zgxlinux-01 ~]# curl -x192.168.56.128:80 2111.com.cn -I #-I表示不显示结果而显示状态码
HTTP/1.1 301 Moved Permanently
Date: Sat, 17 Nov 2018 09:43:04 GMT
Server: Apache/2.4.37 (Unix) PHP/5.6.32
Location: http://www.111.com/
Content-Type: text/html; charset=iso-8859-1
[root@zgxlinux-01 ~]# curl -x192.168.56.128:80 2111.com.cn
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.111.com/">here</a>.</p>
</body></html>
11.21 、Apache访问日志
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.123.com"
ServerName www.123.com
ServerAlias 123.com
CustomLog "logs/123.com-access_log" combined
</VirtualHost>
[root@zgxlinux-01 ~]# ls /usr/local/apache2.4.37/logs/
111.com-access_log abc.com-access_log access_log httpd.pid
111.com-error_log abc.com-error_log error_log
[root@zgxlinux-01 ~]# vim /usr/local/apache2.4.37/conf/httpd.conf
[root@zgxlinux-01 ~]# vim /usr/local/apache2.4.37/conf/extra/httpd-vhosts.conf