zoukankan      html  css  js  c++  java
  • Apache 安装及常用参数设置

    1. 禁用 selinux

      setenforce 0

      sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

      sed -i "s/SELINUXTYPE=targeted/#SELINUXTYPE=targeted/g" /etc/selinux/config

    2. 安装 apache

      yum -y install httpd php

    3. 更改 apache 参数

      a. 修改 ServerLimit 默认为 256

      b. 修改 MaxClients 默认为 256

      根据服务器性能做相应调整。下载服务器一般调到 1024 或更大

      且值 ServerLimit >=MaxCliens

      sed -i "s/256/1024/g" `grep 256 -rl /etc/httpd/conf/httpd.conf`

      c. 取消 #ServerNamewww.example.com:80 的注释

      sed -i "s/#ServerName www.example.com:80/ServerName www.example.com:80/g" /etc/httpd/conf/httpd.conf

      d. 修改 OptionsIndexes FollowSymLinks —> Options FollowSymLinks 禁止显示 Apache 目录列表

      sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/g" /etc/httpd/conf/httpd.conf

      e. 修改 AllowOverride 参数 None —>All   .htaccess 文件将启用

      sed-i "s/AllowOverride None/AllowOverride All/g"  /etc/httpd/conf/httpd.conf

      f. 一个持久链接中允许的最大请求数量

      sed -i "s/MaxKeepAliveRequests 100/MaxKeepAliveRequests 500/g"  /etc/httpd/conf/httpd.conf

    4. 添加 vhost 文件

      <VirtualHost*:80>  
           ServerAdmin webmaster@youwebsite.com  
           ServerName youwebsite.com  
           ServerAlias www.youwebsite.com *.youwebsite.com serverIP
           DocumentRoot /home/youwebsite.com/public_html/  
           ErrorLog /home/youwebsite.com/logs/error.log  
           # LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %{cookie}n" usertracklog
           # CustomLog /home/youwebsite.com/logs/access.log combined usertracklog
           CustomLog /home/youwebsite.com/logs/access.log combined 
      </VirtualHost>  
      Vhost Code
    5. 创建网站目录

      mkdir–p /home/youwebsite.com/public_html/

      mkdir/home/youwebsite.com/logs/

    6. 设置 apache 开机启动,重启 apache

      chkconfig–levels 235 httpd on

      service httpd restart

    7. 自定义 apache 日志

      修改 httpd.conf 文件中的 LogFormat 即可。但是 LogFormat 无法剔除日志

      使用 SetEnvIf 参数可以剔除日志

      (可以根据请求主机名 Remote_Addr、Request_Method 的 get 或者 post 请求、Request_URI 请求的文件名或浏览器语言 Accept-Language 做分离)

      例子:不记录 172.16.193.1 的访问日志

      SetEnvIf Remote_Addr "172.16.193.1" dontlog

      Customlog /home/test.com/logs/nolocal.log common env=!dontlog

  • 相关阅读:
    Sql Server 2005 遍历结果集方法之一
    WinForm 程序托盘及右键退出
    WinForm 程序托盘
    JavaScript 简单定时器原理
    利用Httphandler实现URL重写(重写URL及伪静态)
    CYSCode 生成ORM框架的属性代码
    WinForm开机启动 判断 设置
    同级元素,鼠标经过高亮,鼠标离开还原(除选中已高亮元素时),点击确定高亮
    JavaScript 获取地址栏参数值
    openssl aes 加解密
  • 原文地址:https://www.cnblogs.com/Mrhuangrui/p/4556456.html
Copyright © 2011-2022 走看看