# 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.2.2.tar.gz # tar xvzf httpd-2.2.2.tar.gz # cd httpd-2.2.2 # # ./configure --prefix=/usr/local/apache2 \ --with-mpm=prefork \ --enable-so \ --enable-mods-shared=most \ --enable-alias=static \ --enable-authz_host=static \ --enable-cgi=static \ --enable-dir=static \ --enable-log_config=static \ --enable-mime=static \ --enable-setenvif=static \ --enable-rewrite=static \ --disable-actions \ --disable-asis \ --disable-autoindex \ --disable-authn-anon \ --disable-authn-dbd \ --disable-authn-dbm \ --disable-authz-owner \ --disable-authz-dbm \ --disable-charset-lite \ --disable-dav \ --disable-dav_fs \ --disable-dbd \ --disable-deflate \ --disable-env \ --disable-ext_filter \ --disable-expires \ --disable-filter \ --disable-headers \ --disable-ident \ --disable-imagemap \ --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/ # # 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:on 3:on 4:on 5:on 6:off # # vi /usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
ServerRoot "/usr/local/apache2"
PidFile /var/log/httpd/httpd.pid
LockFile /var/log/httpd/accept.lock
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
ServerSignature Off
HostnameLookups Off
TraceEnable Off
Listen 80
#LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_default_module modules/mod_authn_default.so
#LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
#LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule authz_default_module modules/mod_authz_default.so
#LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule logio_module modules/mod_logio.so
#LoadModule status_module modules/mod_status.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
User apache
Group apache
ServerAdmin root@example.co.jp
ServerName www.example.co.jp:80
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.html
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
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
CustomLog /var/log/httpd/access_log common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
<Directory "/var/www/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
DefaultType text/plain
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler cgi-script .cgi