zoukankan      html  css  js  c++  java
  • apache目录及文件讲解

    apache目录下bin,conf,htdocs,logs,modules讲解
        bin:
            ab  压力测试工具
            apachectl  启动命令
            apxs  安装扩展模块的工具
            htcapacheclean  清理磁盘缓冲区命令
            htpasswd  建立和更新基本认证文件
            httpd  控制命令程序,apachectl执行时会调用
            rotatelogs  日志轮询工具,会用cronolog替代
        conf  配置文件目录
            httpd.conf  主配置文件
            extra  子配置文件目录
        htdocs  默认站点目录
            index.html,index.php,index.jsp   首页文件
                首页名字在httpd.conf中事先定义好了
                    DirectoryIndex index.html  
                        修改好后要重启httpd服务
                            apachectl -t 或 apachectl graceful(平滑重启)
        logs  日志
            access_log  访问日志
            error_log  错误日志
            httpd.pid  http进程启动后,会把所有进程的id号写进来
        modules 模块目录
        
    httpd.conf 主配置文件介绍
        grep -Ev "#|^$" httpd.conf >httpd.conf.ori  排除注释文件
            ServerRoot "/application/apache2.2.31"  //服务的根目录
            Listen 80  //监听端口,是所有ip
            <IfModule !mpm_netware_module>  
            <IfModule !mpm_winnt_module>
            User daemon  //默认用户
            Group daemon  //默认组
            </IfModule>
            </IfModule>
            ServerAdmin you@example.com  //管理员邮箱
            DocumentRoot "/application/apache2.2.31/htdocs"  //默认站点目录
            <Directory />  //根目录权限控制
                Options FollowSymLinks    //允许在此目录中使用符号链接
                AllowOverride None  //服务器将忽略.htacess文件,禁止重载
                Order deny,allow
                Deny from all  //加上面一行表示不允许任何人访问目录
            </Directory>
            <Directory "/application/apache2.2.31/htdocs">  //默认目录权限控制
                Options Indexes FollowSymLinks  //Indexes-->展示目录结构(优化1)
                AllowOverride None
                Order allow,deny
                Allow from all
            </Directory>
            <IfModule dir_module>
                DirectoryIndex index.html  //指定访问首页
            </IfModule>
            <FilesMatch "^.ht">  //对.ht开头的文件设置权限
                Order allow,deny
                Deny from all
                Satisfy All
            </FilesMatch>
            ErrorLog "logs/error_log"  //错误日志
            LogLevel warn  //日志的警告
            <IfModule log_config_module>  //日志格式
                LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
                LogFormat "%h %l %u %t "%r" %>s %b" common
                <IfModule logio_module>
                  LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
                </IfModule>
                CustomLog "logs/access_log" common
            </IfModule>
            <IfModule alias_module>  //cgi配置,以下10行都是,已淘汰,可删掉
                ScriptAlias /cgi-bin/ "/application/apache2.2.31/cgi-bin/"
            </IfModule>
            <IfModule cgid_module>
            </IfModule>
            <Directory "/application/apache2.2.31/cgi-bin">
                AllowOverride None
                Options None
                Order allow,deny
                Allow from all
            </Directory>
            DefaultType text/plain  //缺省类型
            <IfModule mime_module>  //指定MIME类型映射文件
                TypesConfig conf/mime.types
                AddType application/x-compress .Z
                AddType application/x-gzip .gz .tgz
            </IfModule>
            <IfModule ssl_module>  //ssl配置
            SSLRandomSeed startup builtin
            SSLRandomSeed connect builtin
            </IfModule>
            
    子配置文件介绍
        httpd-autoindex.conf
        httpd-info.conf
        httpd-mpm.conf  //重点
        httpd-userdir.conf
        httpd-dav.conf
        httpd-languages.conf
        httpd-multilang-errordoc.conf
        httpd-vhosts.conf  //重点
        httpd-default.conf  //了解
        httpd-manual.conf
        httpd-ssl.conf
        
        httpd-vhost.conf  //大部分网站都在这里面配置
            NameVirtualHost *:80
            <VirtualHost *:80>  //基于域名的虚拟主机
                ServerAdmin webmaster@dummy-host.example.com
                DocumentRoot "/application/apache2.2.31/docs/dummy-host.example.com"
                ServerName dummy-host.example.com
                ServerAlias www.dummy-host.example.com
                ErrorLog "logs/dummy-host.example.com-error_log"
                CustomLog "logs/dummy-host.example.com-access_log" common
            </VirtualHost>
            <VirtualHost *:80>
                ServerAdmin webmaster@dummy-host2.example.com
                DocumentRoot "/application/apache2.2.31/docs/dummy-host2.example.com"
                ServerName dummy-host2.example.com
                ErrorLog "logs/dummy-host2.example.com-error_log"
                CustomLog "logs/dummy-host2.example.com-access_log" common
            </VirtualHost>
        httpd-mpm.conf
            <IfModule !mpm_netware_module>  //pid文件
                PidFile "logs/httpd.pid"
            </IfModule>
            <IfModule !mpm_winnt_module>
            <IfModule !mpm_netware_module>
            LockFile "logs/accept.lock"  //锁文件
            </IfModule>
            </IfModule>
            <IfModule mpm_prefork_module>  //prefor模式,另一模式是worker
                StartServers          5
                MinSpareServers       5
                MaxSpareServers      10
                MaxClients          150  //默认并发数150
                MaxRequestsPerChild   0
            </IfModule>
            <IfModule mpm_worker_module>  //worker模式
                StartServers          2
                MaxClients          150
                MinSpareThreads      25
                MaxSpareThreads      75
                ThreadsPerChild      25
                MaxRequestsPerChild   0
            </IfModule>
            <IfModule mpm_beos_module>
                StartThreads            10
                MaxClients              50
                MaxRequestsPerThread 10000
            </IfModule>
            <IfModule mpm_netware_module>
                ThreadStackSize      65536
                StartThreads           250
                MinSpareThreads         25
                MaxSpareThreads        250
                MaxThreads            1000
                MaxRequestsPerChild      0
                MaxMemFree             100
            </IfModule>
            <IfModule mpm_mpmt_os2_module>
                StartServers           2
                MinSpareThreads        5
                MaxSpareThreads       10
                MaxRequestsPerChild    0
            </IfModule>
            <IfModule mpm_winnt_module>
                ThreadsPerChild      150
                MaxRequestsPerChild    0
            </IfModule>
            
        httpd-default.conf
            Timeout 300  //超时时间s
            KeepAlive On  //保持连接状态
            MaxKeepAliveRequests 100  //最大连接数
            KeepAliveTimeout 5  //在同一连接上等待下一个请求的时间
            UseCanonicalName Off  
            AccessFileName .htaccess  //伪静态的语法写在.htaccess
                开发要用,需要给他权限 AllowOverride ALL
            ServerTokens Full  
            ServerSignature On  //隐藏apache版本  防黑客
            HostnameLookups Off

  • 相关阅读:
    asp.net文件上传
    给图片添加水印效果图的函数(可以在图片上添加自己的版权和LOGO图片的水印)
    DataGrid实现tooltip功能
    DataList编辑、更新、取消、删除、分页(分页控件AspNetPager.dll)
    SQL Server 中千分位格式化输出[转载]
    利用ASP.NET的三种缓存提高站点性能
    带Checkbox的TreeView(一) 完美兼容IE、Firefox ,在js中添加了getCurrentNode(evt)方法,注册方法变为TreeView1.Attributes.Add("onclick", "CheckEvent
    带checkbox的TreeView(二)
    经典blog
    六类UML图
  • 原文地址:https://www.cnblogs.com/tianyik/p/5302705.html
Copyright © 2011-2022 走看看