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