# groupadd apache # useradd -g apache -d /dev/null -s /sbin/nologin apache # # cd /usr/local/src/ # wget http://www.apache.jp/dist/httpd/httpd-2.0.58.tar.gz # tar xvzf httpd-2.0.58.tar.gz # cd httpd-2.0.58 # # ./configure --prefix=/usr/local/apache2 \ --with-mpm=prefork \ --enable-so \ --enable-mods-shared=most \ --enable-access=static \ --enable-alias=static \ --enable-cgi=static \ --enable-dir=static \ --enable-log_config=static \ --enable-mime=static \ --enable-rewrite=static \ --enable-setenvif=static \ --disable-actions \ --disable-autoindex \ --disable-asis \ --disable-auth_anon \ --disable-auth_dbm \ --disable-dav \ --disable-dav_fs \ --disable-env \ --disable-ext_filter \ --disable-expires \ --disable-headers \ --disable-imap \ --disable-include \ --disable-info \ --disable-negotiation \ --disable-speling \ --disable-userdir # make # make install # # cd /usr/local/apache2/ # rm -rf htdocs/ cgi-bin/ logs/ icons/ manual/ error/ # cd conf/ # rm -f highperformance* httpd-std.conf ssl-std.conf # # mkdir /var/www # mkdir /var/www/html # mkdir /var/www/cgi-bin # mkdir /var/log/httpd # chown -R apache:apache /var/www/html # chown -R apache:apache /var/www/cgi-bin # chown -R apache:apache /var/log/httpd # # vi /etc/init.d/httpd
/etc/init.d/httpd
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
# processname: httpd
# pidfile: /var/log/httpd/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/log/httpd/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/log/httpd/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
# chmod +x /etc/init.d/httpd # chkconfig --add httpd # chkconfig --list |grep httpd httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off # # vi /usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
ServerRoot "/usr/local/apache2"
LockFile /var/log/httpd/accept.lock
PidFile /var/log/httpd/httpd.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
Listen 80
#LoadModule auth_module modules/mod_auth.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule status_module modules/mod_status.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#ExtendedStatus On
User apache
Group apache
ServerAdmin root@example.co.jp
ServerName www.example.co.jp:80
UseCanonicalName Off
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html index.htm
AccessFileName .htaccess
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
TypesConfig conf/mime.types
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/httpd/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/httpd/access_log combined
#CustomLog logs/referer_log referer
#CustomLog logs/agent_log agent
ServerTokens Prod
ServerSignature Off
TraceEnable Off
ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
<Directory "/var/www/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi