二.编译安装apache(httpd).apache的执行用户为nobody.
cd /usr/local/src
tar -zxf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure –prefix=/usr/local/apache –enable-headers –enable-mime-magic –enable-proxy –enable-rewrite –enable-ssl –enable-suexec –disable-userdir –with-included-apr –with-mpm=prefork –with-ssl=/usr –with-suexec-caller=nobody –with-suexec-docroot=/ –with-suexec-gidmin=100 –with-suexec-logfile=/usr/local/apache/logs/suexec_log –with-suexec-uidmin=100 –with-suexec-userdir=public_html
make
make install
mkdir /usr/local/apache/domlogs
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
1.编辑/etc/init.d/httpd,在首行#!/bin/sh下添加:
# Startup script for the Apache Web Server
#
# chkconfig: – 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache/logs/httpd.pid
# config: /usr/local/apache/conf/httpd.conf
ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384
ulimit -n 32768
ulimit -n 65535
保存退出.
2.配置apache配置参数文件httpd.conf,位于/usr/local/apache/conf/目录
cd /usr/local/apache/conf/
mv httpd.conf httpd.conf.bak
mkdir vhosts
vi httpd.conf
输入以下内容:
PidFile logs/httpd.pid
LockFile logs/accept.lock
ServerRoot "/usr/local/apache"
Listen 0.0.0.0:81
User nobody
Group nobody
ServerAdmin admin@evlit.com
ServerName host.evlit.com
Timeout 300
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5
UseCanonicalName Off
AccessFileName .htaccess
TraceEnable Off
ServerTokens ProductOnly
FileETag None
ServerSignature Off
HostnameLookups Off
# LoadModule perl_module modules/mod_perl.so
DocumentRoot "/usr/local/apache/htdocs"
<Directory "/">
Options ExecCGI FollowSymLinks Includes IncludesNOEXEC -Indexes -MultiViews SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AllowOverride All
</Directory>
<Directory "/usr/local/apache/htdocs">
Options Includes -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
DefaultType text/plain
RewriteEngine on
AddType text/html .shtml
AddHandler cgi-script .cgi .pl .plx .ppl .perl
AddHandler server-parsed .shtml
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/perl .pl .plx .ppl .perl
AddType application/x-img .img
AddType application/x-httpd-php .php .php3 .php4 .php5 .php6
AddType application/x-httpd-php-source .phps
AddType application/cgi .cgi
AddType text/x-sql .sql
AddType text/x-log .log
AddType text/x-config .cnf conf
AddType text/x-registry .reg
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddType application/x-tar .tgz
AddType application/rar .rar
AddType application/x-compressed .rar
AddType application/x-rar .rar
AddType application/x-rar-compressed .rar
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlc .wmlc
AddType application/vnd.wap.wmlscriptc .wmlsc
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.htm index.shtml index.php index.perl index.pl index.cgi
</IfModule>
<Files ~ "^error_log$">
Order allow,deny
Deny from all
Satisfy All
</Files>
<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/ "/usr/local/apache/cgi-bin/"
</IfModule>
<Directory "/usr/local/apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
<IfModule mpm_prefork_module>
StartServers 3
MinSpareServers 3
MaxSpareServers 5
MaxClients 150
MaxRequestsPerChild 1024
</IfModule>
<IfModule mod_headers.c>
<FilesMatch ".(html|htm|shtml)$">
Header set Cache-Control "max-age=3600, must-revalidate"
</FilesMatch>
</IfModule>
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
Include conf/extra/httpd-languages.conf
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
ExtendedStatus On
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
<IfModule ssl_module>
Listen 0.0.0.0:443
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLCipherSuite ALL:!ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
SSLPassPhraseDialog builtin
SSLSessionCache dbm:/usr/local/apache/logs/ssl_scache
SSLSessionCacheTimeout 300
SSLMutex file:/usr/local/apache/logs/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
#Vhosts
NameVirtualHost 127.0.0.1:81
NameVirtualHost *
<VirtualHost 127.0.0.1:81 *>
ServerName host.evlit.com
DocumentRoot /var/www/html
ServerAdmin admin@evlit.com
</VirtualHost>
Include conf/vhosts/*上述出现的127.0.0.1请改为你本机公网IP.