apache web服务器常用配置
2017-01-07 20:07
435 查看
lamp基础上搭建DiscuzX3.2论坛,通过配置/path/to/apache/conf/extra/httpd-vhosts.conf,实现以下功能。
httpd-vhosts.conf配置内容如下:
httpd-vhosts.conf配置内容如下:
# Virtual Hosts # # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.4/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # # #默认主机 <VirtualHost *:80> DocumentRoot "/tmp/111" ServerName 11.com </VirtualHost> #Discuz虚拟主机配置 <VirtualHost *:80> DocumentRoot "/data/www" ServerName www.test.com ServerAlias www.test2.com #设置用户访问权限 <Directory /data/www/auth> AllowOverride AuthConfig AuthName "Please enter the username and password!" AuthType Basic AuthUserFile /data/.htpasswd require valid-user </Directory> #访问控制 <Directory /data/www> AllowOverride None Options None Order allow,deny Allow from all Deny from 192.168.1.100 </Directory> <FilesMatch "(.*)admin(.*)"> Order deny,allow Deny from all Allow from 192.168.1.99 192.168.1.103 </FilesMatch> #禁止/ /目录php文件解析 <Directory /data/www/data> php_admin_flag engine off <filesmatch "(.*)php"> Order deny,allow Deny from all </filesmatch> </Directory> #设置访问日志不记录image请求 SetEnvIf Request_URI ".*\.gif$" image-request SetEnvIf Request_URI ".*\.jpg$" image-request SetEnvIf Request_URI ".*\.png$" image-request SetEnvIf Request_URI ".*\.bmp$" image-request SetEnvIf Request_URI ".*\.swf$" image-request SetEnvIf Request_URI ".*\.js$" image-request SetEnvIf Request_URI ".*\.css$" image-request #错误日志和日志分割 ErrorLog "logs/test.com-error_log" CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com-access_log_%Y%m%d 86400" combined env=!image-request #301跳转_rewrite和禁止user_agent访问 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www.test2.com$ RewriteRule ^/(.*)$ http://www.test.com/$1 [L,R=301] #RewriteCond %{HTTP_USER_AGENT} ^.*curl.* [NC,OR] #RewriteCond %{HTTP_USER_AGENT} ^.*chrome.* [NC] #RewriteRule .* - [F] RewriteCond %{REQUEST_URI} ^.*/tmp/.* [NC] RewriteRule .* - [F] </IfModule> #配置防盗链 SetEnvIfNoCase Referer "^http://.*\.test\.com" local_ref #白名单url <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)"> Order Allow,Deny Allow from env=local_ref </FilesMatch> #配置浏览器缓存_expires <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/gif "access plus 1 days" ExpiresByType image/jpeg "access plus 1 days" ExpiresByType image/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> </VirtualHost>
相关文章推荐
- Apache Web服务器资源使用限制配置
- APACHE_WEB_服务器安全配置
- apache,mysql等常用web服务器命令所在地
- Tomcat 服务器/web.xml常用配置
- Web服务器(Apache)虚拟主机的配置
- WIN环境下用Apache+PHP+MySql配置web服务器(菜鸟版)
- web服务器中默认首页和默认网站的配置(以apache服务器为例)
- Apache Web服务器安全配置全攻略
- 抛弃IIS,青睐Apache Web服务器的配置方法
- apache Web服务器资源使用限制配置
- Apache Web服务器资源使用限制配置 推荐
- Apache WEB服务器配置全攻略
- Apache Web服务器资源使用限制配置
- Web 服务器的配置与应用(一) —— Apache 简介
- squid(双向转发+缓存)+apache(双向转发)+web服务器配置详细
- Redhat Linux9.0下最新web服务器环境配置指南withPHP5,Apache2.0.47(转载)
- 引用-Apache Web服务器安全配置全攻略
- Apache Web服务器安全配置
- [apache] Linux全能web服务器配置方案
- Web服务器(Apache)的配置与使用