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
[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
相关文章推荐
- cronolog apache 日志分割
- apache 用户验证详解
- 通过apache 访问日志access.log 统计IP 和每个地址访问的次数
- apache与IIS共用80端口冲突解决方法
- 关于mac上面apache服务器的配置
- Apache rotatelogs命令
- Apache apxs命令
- Apache ab命令
- Ubuntu Apache配置以及cgi配置方法
- [转]应用服务器ApacheSocketUnixthread
- Apache Commons工具集简介
- Apache访问控制
- 此为传送门,关于学习html、css、js、apache、php、mysql的学习
- apache flume sources
- Apache通过多端口配置多站点
- WebService报错:org.apache.cxf.interceptor.Fault: No such operation
- Discuz! X3.0/X3.1/X3.2通用 Apache伪静态规则
- 使用 Apache Pig 处理数据
- wamp下 配置 apache 的ssl
- Apache环境.htaccess伪静态301跳转(www与不带www)