linux/BSD WEB服务器Apache搭建 完全笔记
系统REDHAT5
安装Apache: rpm –ivh httpd-2.2.3.-6-el5.i386.rpm
如果系統是最小安裝需要另外三个RPM包:
[root@localhost Server]# rpm -ivh httpd-2.2.3-6.el5.i386.rpm apr-util-1.2.7-6.i386.rpm apr-1.2.7-11.i386.rpm postgresql-libs-8.1.4-1.1.i386.rpm
配置httpd.conf:(/etc/httpd/conf/httpd.conf)
ServerRoot “/etc/httpd” #配置文件和日志文件的位置
PidFile run/httpd.pid #用来指定httpd.pid的位置
Timeout 300 #指定超时时间
KeepAlive On #保持和服务器连接默认Off
MaxKeepAliveRequests 100 #每次连接的最大请求数量
KeepAliveTimeout 15 #连续两个请求的间隔时间
StartServers 8 #启动8个httpd进程
MinSpaceServers 5 #最小空闲进程数
MaxSpaceServers 20 #最大空闲进程数
MaxClient 150 #最大连接数
MaxRequestsPerChild 1000 #每个子进程的最大请求数量
Listen 80 #监听的端口默认80
#Listen 8000 #可添加8000端口侦听
User apache
Group apache #用哪个账号和组来启动httpd
ServerAdmin root@localhost #指定管理员邮件地址
ServerName xxxxxx:80 #指定服务器名来替代真实主机名
DocumentRoot “/var/www/html” #存放网页的根目录位置
<Directory “/var/www/html”> #设置服务器网页的根目录和目录访问权限
AllowOverride NONE #不允许用户修改访问权限
</Direcroty> #目录访问控制结束符
UserDir disable #是否允许用户在个人目录中建立网站
#UserDir public_html #指定用户目录,管理员可在user/HOME下建立
DirectoryIndex index.asp index.html index.php index.cgi #设定每个目录的默认网页文件
AccessFileName .htaccess #指定访问目录权限的文件名
<File ~ “^\.ht”> Deny from all #设置.ht*文件的访问权限,默认任何人不能访问
TypesConfig /etc/mime.types #设置各种文件类型的关联位置
DefaultType text/plain # 当无法识别时候的缺省文件类型默认是文本类型
HostnameLookups Off #记录连接到网站的主机名默认记录IP地址
ErrorLog logs/error_log # 记录错误的日志位置
LogLevel warn # 记录错误的级别
CustomeLog logs/agent_log agent # 记录浏览者使用的浏览器版本种类
ServerSignature On # 错误网页中加入服务器名和版本
Alias /icons/ “/var/www/icons/” # 为某一目录建立别名
ScriptAlias /cgi/bin “/var/www/cgi-bin/” # 为脚本程序目录设置别名
Opitions ExceCGI # 可执行CGI程序
IndexOpitions Fancyindexing Versionsort #找不到index文件会显示文件列表时显示小图标
indexignore .??* * HEADER # 遇到这些名字时候不列出
AddType application/x-tar.tgz # 定义MIME类型
AddHandler cgi-script .cgi # 指定某些扩展名文件的处理方式
BrowserMatch “Mozila/2” nokeepalive # 当浏览器是此版本则不提供keepalive
BrowserMatch “realplayer 4\.0” force response-1.0 #强制应用程式使用HTTP1.0响应方式
AddDefaultCharset Off #设置网页缺省字符 默认是UTF-8可能乱码
虚拟主机配置:
NameVirtualHost *:80 #虚拟主机IP,基于多域名单IP需开启,*多域名单IP适用
<VirtualHost *:80> #配置虚拟主机名或IP地址,*表示所有,多域名单IP适用
ServerAdmin xxx@xx.com
DocumentRoot /xxxx/xxxxx1 #网站目录请根据自己路径设定
ServerName http://www.xxxxx.com/ #指定虚拟主机名,可设定多个域名使用1個IP的主机
ErrorLog /group/xxxxxxx1
</ VirtualHost>
<VirtualHost *:80>
ServerAdmin xxx@xx.com
DocumentRoot /xxxx/xxxxx2 #网站目录请根据自己路径设定
ServerName http://www.xxxxx2.com/ #指定虚拟主机名,可设定多个域名使用1個IP的主机
ErrorLog /group/xxxxxxx2
</ VirtualHost>
<VirtualHost default *> #指定默认的虚拟主机
启动/停止httpd: /etc/rc.d/init.d/httpd start (stop/restart)
开机自动运行:命令行--setup---system services---选择httpd服务
查看日志:/var/httpd/logs access_log 记录用户访问记录 error_log记录启动停止和访问错误
apache乱码解决的方法:
直接在httpd.conf配置文件中将AddDefaultCharset ISO-8859-1 改为
AddDefaultCharset GB2312 .ZH-CN .zh-cn
也可改为AddDefaultCharset off 或者注释掉
注:如果是编译安装最新版本的Apache配置文件是分开的如虚拟主机并不在httpd.conf中设置是在其他配置文件中的
安装Apache: rpm –ivh httpd-2.2.3.-6-el5.i386.rpm
如果系統是最小安裝需要另外三个RPM包:
[root@localhost Server]# rpm -ivh httpd-2.2.3-6.el5.i386.rpm apr-util-1.2.7-6.i386.rpm apr-1.2.7-11.i386.rpm postgresql-libs-8.1.4-1.1.i386.rpm
配置httpd.conf:(/etc/httpd/conf/httpd.conf)
ServerRoot “/etc/httpd” #配置文件和日志文件的位置
PidFile run/httpd.pid #用来指定httpd.pid的位置
Timeout 300 #指定超时时间
KeepAlive On #保持和服务器连接默认Off
MaxKeepAliveRequests 100 #每次连接的最大请求数量
KeepAliveTimeout 15 #连续两个请求的间隔时间
StartServers 8 #启动8个httpd进程
MinSpaceServers 5 #最小空闲进程数
MaxSpaceServers 20 #最大空闲进程数
MaxClient 150 #最大连接数
MaxRequestsPerChild 1000 #每个子进程的最大请求数量
Listen 80 #监听的端口默认80
#Listen 8000 #可添加8000端口侦听
User apache
Group apache #用哪个账号和组来启动httpd
ServerAdmin root@localhost #指定管理员邮件地址
ServerName xxxxxx:80 #指定服务器名来替代真实主机名
DocumentRoot “/var/www/html” #存放网页的根目录位置
<Directory “/var/www/html”> #设置服务器网页的根目录和目录访问权限
AllowOverride NONE #不允许用户修改访问权限
</Direcroty> #目录访问控制结束符
UserDir disable #是否允许用户在个人目录中建立网站
#UserDir public_html #指定用户目录,管理员可在user/HOME下建立
DirectoryIndex index.asp index.html index.php index.cgi #设定每个目录的默认网页文件
AccessFileName .htaccess #指定访问目录权限的文件名
<File ~ “^\.ht”> Deny from all #设置.ht*文件的访问权限,默认任何人不能访问
TypesConfig /etc/mime.types #设置各种文件类型的关联位置
DefaultType text/plain # 当无法识别时候的缺省文件类型默认是文本类型
HostnameLookups Off #记录连接到网站的主机名默认记录IP地址
ErrorLog logs/error_log # 记录错误的日志位置
LogLevel warn # 记录错误的级别
CustomeLog logs/agent_log agent # 记录浏览者使用的浏览器版本种类
ServerSignature On # 错误网页中加入服务器名和版本
Alias /icons/ “/var/www/icons/” # 为某一目录建立别名
ScriptAlias /cgi/bin “/var/www/cgi-bin/” # 为脚本程序目录设置别名
Opitions ExceCGI # 可执行CGI程序
IndexOpitions Fancyindexing Versionsort #找不到index文件会显示文件列表时显示小图标
indexignore .??* * HEADER # 遇到这些名字时候不列出
AddType application/x-tar.tgz # 定义MIME类型
AddHandler cgi-script .cgi # 指定某些扩展名文件的处理方式
BrowserMatch “Mozila/2” nokeepalive # 当浏览器是此版本则不提供keepalive
BrowserMatch “realplayer 4\.0” force response-1.0 #强制应用程式使用HTTP1.0响应方式
AddDefaultCharset Off #设置网页缺省字符 默认是UTF-8可能乱码
虚拟主机配置:
NameVirtualHost *:80 #虚拟主机IP,基于多域名单IP需开启,*多域名单IP适用
<VirtualHost *:80> #配置虚拟主机名或IP地址,*表示所有,多域名单IP适用
ServerAdmin xxx@xx.com
DocumentRoot /xxxx/xxxxx1 #网站目录请根据自己路径设定
ServerName http://www.xxxxx.com/ #指定虚拟主机名,可设定多个域名使用1個IP的主机
ErrorLog /group/xxxxxxx1
</ VirtualHost>
<VirtualHost *:80>
ServerAdmin xxx@xx.com
DocumentRoot /xxxx/xxxxx2 #网站目录请根据自己路径设定
ServerName http://www.xxxxx2.com/ #指定虚拟主机名,可设定多个域名使用1個IP的主机
ErrorLog /group/xxxxxxx2
</ VirtualHost>
<VirtualHost default *> #指定默认的虚拟主机
启动/停止httpd: /etc/rc.d/init.d/httpd start (stop/restart)
开机自动运行:命令行--setup---system services---选择httpd服务
查看日志:/var/httpd/logs access_log 记录用户访问记录 error_log记录启动停止和访问错误
apache乱码解决的方法:
直接在httpd.conf配置文件中将AddDefaultCharset ISO-8859-1 改为
AddDefaultCharset GB2312 .ZH-CN .zh-cn
也可改为AddDefaultCharset off 或者注释掉
注:如果是编译安装最新版本的Apache配置文件是分开的如虚拟主机并不在httpd.conf中设置是在其他配置文件中的
posted on 2010-01-13 21:09 At all times growing 阅读(396) 评论(0) 编辑 收藏 举报