UbuntuServer Apache2.4 DocumentRoot変更とモジュール有効化

/ Linux/Unix / Comment[0]
デフォルトのDocumentRootが/var/www/htmlだったので
/etc/apache.confに「DocumentRoot /var/www」と書き込んでみたが適応されない。
mod_rewriteも適応させようとLoadModuleを/etc/apache.confに書き込んでみたけど適応しない。
うーむ2.2から2.4でちょっとした仕様変更があったようです。

  • 設定ファイルのディレクトリ構造

  • # ls /etc/apache2/
    apache2.conf  conf-available/  conf-enabled/
    envvars magic mods-available/ mods-enabled/ ports.conf
    sites-available/ sites-enabled/

    *-available/に利用可能な設定ファイルなどが入っており、
    *-enabled/にそのファイルのリンクを張ることで有効化されるという形のようです。
    とりあえずやってみましょう。

  • DocumentRootの変更

  • sites-available/000-default.confを改変してsites-enabledにリンクを張ります。
    # cd /etc/apache2/
    # vi sites-available/000-default.conf
    <VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

    # ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/

  • mod_rewriteの適応

  • # cd /etc/apache2

    有効なmodsとやらを覗いてみると.loadやら.confやら
    # ls mods-available
    access_compat.load  authn_dbd.load        autoindex.conf      dav.load       env.load                  lbmethod_byrequests.load  mime_magic.load   proxy.load           proxy_scgi.load      session_crypto.load    status.conf
    actions.conf authn_dbm.load autoindex.load dav_fs.conf expires.load lbmethod_bytraffic.load mpm_event.conf proxy_ajp.load proxy_wstunnel.load session_dbd.load status.load
    actions.load authn_file.load buffer.load dav_fs.load ext_filter.load lbmethod_heartbeat.load mpm_event.load proxy_balancer.conf ratelimit.load setenvif.conf substitute.load
    alias.conf authn_socache.load cache.load dav_lock.load file_cache.load ldap.conf mpm_prefork.conf proxy_balancer.load reflector.load setenvif.load suexec.load
    alias.load authnz_ldap.load cache_disk.conf dbd.load filter.load ldap.load mpm_prefork.load proxy_connect.load remoteip.load slotmem_plain.load unique_id.load
    allowmethods.load authz_core.load cache_disk.load deflate.conf headers.load log_debug.load mpm_worker.conf proxy_express.load reqtimeout.conf slotmem_shm.load userdir.conf
    asis.load authz_dbd.load cache_socache.load deflate.load heartbeat.load log_forensic.load mpm_worker.load proxy_fcgi.load reqtimeout.load socache_dbm.load userdir.load
    auth_basic.load authz_dbm.load cgi.load dialup.load heartmonitor.load lua.load negotiation.conf proxy_fdpass.load request.load socache_memcache.load usertrack.load
    auth_digest.load authz_groupfile.load cgid.conf dir.conf include.load macro.load negotiation.load proxy_ftp.conf rewrite.load socache_shmcb.load vhost_alias.load
    auth_form.load authz_host.load cgid.load dir.load info.conf mime.conf php5.conf proxy_ftp.load sed.load speling.load xml2enc.load
    authn_anon.load authz_owner.load charset_lite.load dump_io.load info.load mime.load php5.load proxy_html.load session.load ssl.conf
    authn_core.load authz_user.load data.load echo.load lbmethod_bybusyness.load mime_magic.conf proxy.conf proxy_http.load session_cookie.load ssl.load

    ファイルの中身を覗いてみる
    # cat mods-available/rewrite.load
    LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

    これは2.2までapache.confに書き込んでいた書式ですね。

    modsを有効化するにはsitesと同じくmods-availableからmods-enabledにリンクを張ればおk
    # ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

    そして再起動で適応
    # service apache2 restart
関連記事

コメント

:
:
:
:
:
管理人のみ表示を許可