欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

考试

程序员文章站 2022-05-07 09:53:23
配置虚拟主机 vi /usr/local/apache2.4/conf/httpd.conf 搜索httpd-vhost,删除行首#号 vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf ServerAdmi ......

 配置虚拟主机

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