q29191 发表于 2018-11-20 13:46:44

Apache快速配置


[*]  Apache默认情况下的简单配置文件
  # egrep -v "^.*#|^$" /application/apache/conf/httpd.conf
  ServerRoot "/application/apache2.2.31"
  Listen 80
  LoadModule php5_module      modules/libphp5.so #整合php,自动增加的模块
  
  
  User www
  Group www#不要使用默认用户,创建虚拟用户:user add www -s /sbin/nologin -M
  
  
  ServerAdmin you@example.com
  ServerName 127.0.0.1:80 #也需要做修改
  DocumentRoot "/application/apache2.2.31/htdocs"
  
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  
  #默认站点目录
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
  
  
  DirectoryIndex index.php index.html
  
  
  Order allow,deny
  Deny from all
  Satisfy All
  
  ErrorLog "logs/error_log"
  LogLevel warn
  
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  
  CustomLog "logs/access_log" common
  
  
  ScriptAlias /cgi-bin/ "/application/apache2.2.31/cgi-bin/"
  
  
  
  
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  
  DefaultType text/plain
  
  TypesConfig conf/mime.types
  AddType application/x-compress .Z
  AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php . php . phtml
      AddType application/x-httpd-php-source . phps
  
  Include conf/extra/httpd-vhosts.conf #虚拟主机配置单独放置在一个配置文件中
  
  SSLRandomSeed startup builtin
  SSLRandomSeed connect builtin
  
  
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
        #增加网站站点目录,就要增加访问权限,否则会报403错误

[*]  extra/httpd-vhosts.conf
  NameVirtualHost *:80
  
  ServerAdmin 1076546426@qq.com
  DocumentRoot "/data0/www/bbs"
  ServerName bbs.chborg.com
  ServerAlias chborg.com
  ErrorLog "logs/bbs-error_log"
  CustomLog "bbs-access_log" common
  
  
  ServerAdmin 1076546426@qq.com
  DocumentRoot "/data0/www/blog"
  ServerName blog.chborg.com
  ErrorLog "logs/blog-error_log"
  CustomLog "blog-access_log" common
  

[*]  站点目录
  # tree /data0/
  /data0/
  └── www
  ├── bbs
  │   ├── index.html
  │   └── index.php
  └── blog
  └── index.html
  

  3 directories, 4 files
  




页: [1]
查看完整版本: Apache快速配置