LAMP中apache的相关配置

发布时间:2020-06-18 04:11:40 作者:313119992
来源:网络 阅读:346

    关于apache的相关配置再次梳理,之前有转载他人的文章。今天把所有的实验都做了,记录一下。方便以后自己使用。

<VirtualHost *:80>
    DocumentRoot "/tmp/tmp"
    ServerName tmp.com
    <Directory /tmp/tmp/>
        Order allow,deny
        Deny from all
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/data/www"
    ServerName www.mydiscuz.com
    ServerAlias www.sunshine.com

##配置过滤指定类型文件以及日志切割------begin
    SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.png$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.js$" p_w_picpath-request
    SetEnvIf Request_URI ".*\.css$" p_w_picpath-request

    ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/sunshine.com-error_%Y%m%d_log 86400"
    CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/sunshine.com-access_%Y%m%d_log 86400" combined env=!p_w_picpath-request
##配置过滤指定类型文件以及日志切割------end

##配置用户认证------begin
    <Directory /data/www/abc>
        AllowOverride AuthConfig
        AuthName "please input the password..."
        AuthType Basic
        AuthUserFile /data/.htpasswd
        require valid-user
    </Directory>
##配置用户认证------end

##配置域名跳转------begin
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.mydiscuz.com$
        RewriteRule ^/(.*)$ http://www.sunshine.com/$1 [R=301,L]
    </IfModule>
##配置域名跳转------end

##配置静态缓存------begin
    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType p_w_picpath/gif "access plus 1 days"
        ExpiresByType p_w_picpath/jped "access plus 24 hours"
        ExpiresByType p_w_picpath/png "access plus 24 hours"
        ExpiresByType text/css "now plus 2 hours"
        ExpiresByType application/x-javascript "now plus 2 hours"
        ExpiresByType application/x-shockwave-flash "now plus 2 hours"
        ExpiresDefault "now plus 0 min"
    </IfModule>
##配置静态缓存------end

##关于防盗链的设置------begin
    SetEnvIfNoCase Referer "^http://.*\.sunshine\.com" local_ref
    SetEnvIfNoCase Referer ".*\.sunshine\.com" local_ref
    SetEnvIfNoCase Referer "^$" local_ref
    <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
        Order Allow,Deny
        Allow from env=local_ref
    </filesmatch>
##关于防盗链的设置------end

##关于访问控制的配置------begin
    <Directory /data/www/>
        Order deny,allow
        Deny from all
        allow from all
    </Directory>
##关于访问控制的配置------end

##禁止解析php的配置------begin
    <Directory /data/www/data>
        php_admin_flag engine off
        <filesmatch "(.*)php">
            Order deny,allow
            Deny from all
        </filesmatch>
    </Directory>
##禁止解析php的配置------end

##禁止指定user_agent的配置------begin
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_USER_AGENT} ^.*Firefox.* [NC,OR]
        RewriteCond %{HTTP_USER_AGENT} ^.*Tomato.* [NC]
        RewriteRule .* - [F]
    </IfModule>
##禁止指定user_agent的配置------end

##通过rewrite限制访问某些目录配置------begin
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} ^.*/tmp/* [NC]
        RewriteRule .* - [F]
    </IfModule>
##通过rewrite限制访问某些目录配置------end

</VirtualHost>

2016-03-19 21:07:47 于 北京 

推荐阅读:
  1. 部署LAMP架构之Apache安装
  2. LAMP(Apache+Nginx+Php)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

apache 相关配置 he

上一篇:2. Pycharm的介绍与使用

下一篇:Zookeeper原理

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》