设为首页 收藏本站
查看: 1463|回复: 0

[经验分享] apache常用配置文件讲解

[复制链接]

尚未签到

发表于 2017-12-24 07:39:28 | 显示全部楼层 |阅读模式
apache常用配置文件讲解
apache 的httpd.conf常用配置说明# ServerRoot: The top of the directory tree under which the server's# configuration, error, and log files are kept.## Do not add a slash at the end of the directory path.  If you point# ServerRoot at a non-local disk, be sure to specify a local disk on the# Mutex directive, if file-based mutexes are used.  If you wish to share the# same ServerRoot for multiple httpd daemons, you will need to change at# least PidFile.#ServerRoot "/usr/local/httpd" # Listen: Allows you to bind Apache to specific IP addresses and/or# ports, instead of the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses.##Listen 12.34.56.78:80Listen 80 (此处可以加其他的全局apache端口如 Listen 8080, 也可以在<VirtualHost> 之外添加某一个虚拟配置的监听端口) LoadModule deflate_module modules/mod_deflate.so 启用压缩的模块LoadModule expires_module modules/mod_expires.so 过期模块LoadModule ssl_module modules/mod_ssl.so (https服务所需要的模块)LoadModule vhost_alias_module modules/mod_vhost_alias.so  (虚拟配置重命名所需模块)LoadModule alias_module modules/mod_alias.so (启用多域名所需模块)LoadModule rewrite_module modules/mod_rewrite.so(重定向所需模块)LoadModule php5_module    modules/libphp5.so (解析php文件所需模块) DSC0000.png <Directory />    AllowOverride none    Require all denied</Directory>这个配置改为以下配置比较通用 <Directory />     DirectoryIndex index.php     Options Indexes FollowSymLinks     AllowOverride All     Require all granted </Directory> DocumentRoot "/var/www/html"(默认文件根路径)  <Directory "/var/www/html">    #    # Possible values for the Options directive are "None", "All",    # or any combination of:    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews    #    # Note that "MultiViews" must be named *explicitly* --- "Options All"    # doesn't give it to you.    #    # The Options directive is both complicated and important.  Please see    # http://httpd.apache.org/docs/2.4/mod/core.html#options    # for more information.    #    Options Indexes FollowSymLinks     #    # AllowOverride controls what directives may be placed in .htaccess files.    # It can be "All", "None", or any combination of the keywords:    #   AllowOverride FileInfo AuthConfig Limit    #    AllowOverride None     #    # Controls who can get stuff from this server.    #    Require all granted</Directory>Directory 配置中建议改为 DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Require all granted比较通用  <IfModule dir_module>(默认路径的首次解析文件)    DirectoryIndex index.php index.html</IfModule> AddType application/x-compress .ZAddType application/x-gzip .gz .tgz以下两行为解析php所需添加的配置AddType application/x-httpd-php .phpAddType application/x-httpd-php-sourece .phps  Include /etc/httpd/extra/httpd-vhosts.conf 引进虚拟配置文件Include /etc/httpd/conf.d/*.conf  引进conf.d目录下的配置文件如ssl.conf文件 //设置过期时间的文件和gzip压缩相关参数<IfModule mod_deflate.c>DeflateCompressionLevel 5SetOutputFilter DEFLATEAddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/jsonSetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-varySetEnvIfNoCase Request_URI .(?:pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-varyAddOutputFilterByType DEFLATE text/*AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript application/javascript application/x-javascriptAddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphpBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4.0[678] no-gzipBrowserMatch \bMSIE !no-gzip !gzip-only-text/html</IfModule><IfModule mod_expires.c>         ExpiresActive On         ExpiresDefault A0         <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">         ExpiresDefault A9030400         </FilesMatch>         <FilesMatch "\.(jpg|jpeg|png|gif|swf|js|css)$">         ExpiresDefault A604800         </FilesMatch></IfModule>  虚拟配置文件:Listen 8080(添加某一个配置的监听端口)<VirtualHost *:8080>    ServerAdmin webmaster@dummy-host.example.com    DocumentRoot "/var/www/html/wtsdata/app/web"    ServerName test.wts.199.com    ServerAlias alais.wts.test.199.com   <Directory "/var/www/html/wtsdata/app/web">     DirectoryIndex index.php     Options Indexes FollowSymLinks     AllowOverride All     Require all granted   </Directory>     ErrorLog "logs/199-error_log"    CustomLog "logs/199-access_log" common</VirtualHost>   DSC0001.png
DSC0002.png

DSC0003.png

     posted on 2017-02-15 14:50 Ryanyanglibin 阅读(...) 评论(...)  编辑 收藏

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-427421-1-1.html 上篇帖子: Apache Commons 系列简介 之 Pool 下篇帖子: centos7 安装apache+php
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表