码迷,mamicode.com
首页 > Web开发 > 详细

Apache快速配置

时间:2015-10-28 10:51:36      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:apache简单快速部署

  • Apache默认情况下的简单配置文件

[root@web bbs]# egrep -v "^.*#|^$" /application/apache/conf/httpd.conf

ServerRoot "/application/apache2.2.31"

Listen 80

LoadModule php5_module        modules/libphp5.so #整合php,自动增加的模块

<IfModule !mpm_netware_module>

<IfModule !mpm_winnt_module>

User www

Group www  #不要使用默认用户,创建虚拟用户:user add www -s /sbin/nologin -M

</IfModule>

</IfModule>

ServerAdmin you@example.com

ServerName 127.0.0.1:80 #也需要做修改

DocumentRoot "/application/apache2.2.31/htdocs"

<Directory />

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

    Deny from all

</Directory>

<Directory "/application/apache2.2.31/htdocs">  #默认站点目录

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

<IfModule dir_module>

    DirectoryIndex index.php index.html

</IfModule>

<FilesMatch "^\.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>

    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>

    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

</IfModule>

Include conf/extra/httpd-vhosts.conf #虚拟主机配置单独放置在一个配置文件中

<IfModule ssl_module>

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

</IfModule>

<Directory "/data0">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>        #增加网站站点目录,就要增加访问权限,否则会报403错误

  • extra/httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *: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

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin 1076546426@qq.com

    DocumentRoot "/data0/www/blog"

    ServerName blog.chborg.com

    ErrorLog "logs/blog-error_log"

    CustomLog "blog-access_log" common

</VirtualHost>

  • 站点目录

[root@web bbs]# tree /data0/

/data0/

└── www

    ├── bbs

    │   ├── index.html

    │   └── index.php

    └── blog

        └── index.html


3 directories, 4 files


Apache快速配置

标签:apache简单快速部署

原文地址:http://chboy.blog.51cto.com/9959876/1707124

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!