考试

2019-12-28 11:54:18来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

考试

 配置虚拟主机

vi    /usr/local/apache2.4/conf/httpd.conf

搜索httpd-vhost,删除行首#号

 

vi     /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin admin@gmd.com

    DocumentRoot "/data/wwwroot/gmd.com"

    ServerName gmd.com

    ErrorLog "logs/gmd.com-error_log"

    CustomLog "logs/gmd.com-access_log" common

</VirtualHost>

<VirtualHost *:80>

    DocumentRoot     "/data/wwwroot/www.test0920.com"

    ServerName     www.test0920.com
</VirtualHost>

退出保存

 mkdir   -p    /data/wwwroot/gmd.com  data/wwwroot/www.test0920.com

 echo    "www.0920.com"     >     /data/wwwroot/www.test0920.com/index.html

 echo "gmd.com"    >    /data/wwwroot/gmd.com/index.html

 /usr/local/apache2.4/bin/apachectl     -t

 /usr/local/apache2.4/bin/apachectl     graceful

关闭防火墙

 systemctl stop firewalld

到真实电脑上修改hosts

 最后一行加上

192.168.89.128    www.test0920.com

域名跳转

vi    /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

 

<VirtualHost *:80>
    DocumentRoot    "/data/wwwroot/www.test0920.com"
    ServerName    www.test0920.com
    ServerAlias   test0920.com
    ServerAlias   testdomain.com
    <IfModule mod_rewrite.c>
       RewriteEngine   on
       RewriteCond   %{HTTP_HOST}     !^www.test0920.com$
       RewriteRule    ^/(.*)$     http://www.test0920.com/$1     [R=301,L]
    </IfModule>
</VirtualHost>

 

vi    /usr/local/apache2.4/conf/httpd.conf

搜索rewrite,行首#号删除

/usr/local/apache2.4/bin/apachectl     graceful

/usr/local/apache2.4/bin/apachectl   -M|grep   -i   rewrite

 curl   -x127.0.0.1:80   -I   test0920.com

 curl   -x127.0.0.1:80   -I   testdomain.com

出现301

 

用户认证

vi    /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

 

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/www.test0920.com"
    ServerName www.test0920.com
    ServerAlias test0920.com
    ServerAlias testdomain.com
    <Directory /data/wwwroot/www.test0920.com>
       AllowOverride AuthConfig
       AuthName "www.test0920.com user auth"
       AuthType Basic
       AuthUserFile /data/.htpasswd
       require valid-user
   </Directory>
</VirtualHost>

创建用户

 /usr/local/apache2.4/bin/htpasswd -cm /data/.htpasswd xmcz

 /usr/local/apache2.4/bin/apachectl     -t

 /usr/local/apache2.4/bin/apachectl     graceful

 

访问控制(IP)

vi    /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

 编辑

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/www.test0920.com"
    ServerName www.test0920.com
    ServerAlias test0920.com
    ServerAlias testdomain.com
    <Directory /data/wwwroot/www.test0920.com/download/dw01.php>
      Order deny,allow
      Deny from all
      Allow from 192.168.89.128
    </Directory>
</VirtualHost>

保存

 /usr/local/apache2.4/bin/apachectl     -t

 /usr/local/apache2.4/bin/apachectl     graceful

 

mkdir /data/wwwroot/www.test0920.com/download

cd  /data/wwwroot/www.test0920.com/download

vi dw01.php


<?php
        echo"22"
?>

 

curl  -x127.0.0.1:80  -I  www.test0920.com/download/dw01.php  -uxmcz:123456

 

访问控制(限制解析

vi    /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/www.test0920.com"
    ServerName www.test0920.com
    ServerAlias test0920.com
    ServerAlias testdomain.com
    <Directory /data/wwwroot/www.test0920.com/upload>
      php_admin_flag engine off
    </Directory>
</VirtualHost>

 

 

 /usr/local/apache2.4/bin/apachectl     -t

 

 /usr/local/apache2.4/bin/apachectl     graceful

 mkdir   /data/wwwroot/www.test0920.com/upload

 cd   /data/wwwroot/www.test0920.com/upload

 vi up01.php

 


<?php
        echo"123"
?>

 

访问控制(用户)

vi    /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

 

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/www.test0920.com"
    ServerName www.test0920.com
    ServerAlias test0920.com
    ServerAlias testdomain.com

    <IfModule mod_rewrite.c>

       RewriteEngine on
       RewriteCond %{HTTP_USER_AGENT} .*curl.* [NC,OR]
       RewriteCond %{HTTP_USER_AGENT} .*baidu.com.*[NC]
       RewriteRule .* - [F]
    </IfModule>

</VirtualHost>

 

 

 /usr/local/apache2.4/bin/apachectl     -t

 

 /usr/local/apache2.4/bin/apachectl     graceful

 curl -A "11" -x127.0.0.1:80 -I www.test0920.com

 

模块加载

 cd /usr/local/src/

 yum install -y wget

 wget http://pecl.php.net/get/redis-2.2.5.tgz

 tar -zxvf redis-2.2.5.tgz 

 cd redis-2.2.5

  yum install -y autoconf

  /usr/local/php/bin/phpize

 ./configure --with-php-config=/usr/local/php/bin/php-config

 make

 make install

 /usr/local/php/bin/php -i |grep extension_dir

 ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226

 vi /usr/local/php/etc/php.ini

 最后一行加

 extension=redis.so

 /usr/local/php/bin/php -m |grep redis

 


原文链接:https://www.cnblogs.com/tui463/p/12111682.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:C、C++和C#区别概述

下一篇:Nginx配置location与rewrite规则教程