ここではCentOSのことに記載します。
# yum install httpd Loaded plugins: rhnplugin, security Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.i386 0:2.2.3-45.el5_6.1 set to be updated --> Processing Dependency: libaprutil-1.so.0 for package: httpd --> Processing Dependency: libapr-1.so.0 for package: httpd --> Running transaction check ---> Package apr.i386 0:1.2.7-11.el5_6.4 set to be updated ---> Package apr-util.i386 0:1.2.7-11.el5_5.2 set to be updated --> Processing Dependency: libpq.so.4 for package: apr-util --> Running transaction check ---> Package compat-postgresql-libs.i686 0:4-1PGDG.rhel5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Installing: httpd i386 2.2.3-45.el5_6.1 rhel-i386- server-5 1.2 M Installing for dependencies: apr i386 1.2.7-11.el5_6.4 rhel-i386-server-5 124 k apr-util i386 1.2.7-11.el5_5.2 rhel-i386-server-5 80 k compat-postgresql-libs i686 4-1PGDG.rhel5 pgdg84 63 k Transaction Summary ================================================================================================= Install 4 Package(s) Upgrade 0 Package(s)
設定ファイル/etc/httpd/conf/httpd.conf ServerRoot /etc/httpd
/var/www
lokkit -q -port=http:tcp
* /etc/httpd/conf/httpd.conf †
Apacheの基本的な設定を行ないます。ドキュメントルートや全体的な挙動設定など。通常のディレクティブ設定も行なえます。ここのファイルで既述されたディレクティブ設定が最優先され、conf.d に同じディレクトリに対しての設定があった場合はここで記述された設定を無視します。
Options Indexes FollowSymLinks → Options Indexes ExecCGI FollowSymLinks AllowOverride None → AllowOverride All AddType application/x-httpd-php .php AddHandler cgi-script .cgi → AddHandler cgi-script .cgi .pl
* /etc/httpd/conf.d/ssl.conf
SSLに関する基本的な設定を行なうファイルです。(サーバー証明書によるSSL化やクライアント認証等) SSLに関するディレクティブ設定も行なえますが、通常、このファイルでは 指定しません。 指定した場合は以下に説明する “ 任意.conf ” よりも優先に評価されます。
* /etc/httpd/conf.d/任意.conf †
/conf.d/ ディレクトリ内に任意の.conf ファイルを設置することで個別に設定ファイルを管理できるようになります。
参考: http://sakura.off-soft.net/centos/php_cgi_module_exchange.html apacheとphpの設定は以下のphp.confの内容で動作する。
etc/httpd/conf.d/php.conf
apachectl start apachectl restart apachectl stop service httpd start service httpd stop service httpd restart
mod_proxyを有効にする
sudo a2enmod proxy proxy_http
/etc/apache2/mods-enabled/proxy.conf
<IfModule mod_proxy.c> ProxyRequests Off <Proxy *> Require all granted </Proxy> ProxyPass /mydir http://srv.com/ ProxyPassReverse /mydir http://srv.com/
mod_rewriteを有効にする
sudo a2enmod proxy proxy_http
/etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80> <Directory /var/www/html> AllowOverride All #これ追加 </Directory> ... </VirtualHost>