您的位置:首页 > 运维架构 > Apache

Apache快速配置

2015-10-28 09:57 681 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: