トップ  >  CentOS  >  trac - lighttpd+FASTCGI構築

trac - lighttpd+FASTCGI構築

CentOSにtracを導入して、lighttpd + FASTCGI を使用して、apache経由で快適に使ってみる。

trac + Apache + FASTCGIよりもかなり快適。
インストール手順はsubversionから記述。

  1. subversionの本体とapacheのsvnモジュールをインストール
    # yum -y install subversion mod_dav_svn
  2. apacheのsvn用コンフィグファイルを設定する
    # vi /etc/httpd/conf.d/subversion.conf
    LoadModule dav_svn_module     modules/mod_dav_svn.so
    LoadModule authz_svn_module   modules/mod_authz_svn.so
    
    #
    # Example configuration to enable HTTP access for a directory
    # containing Subversion repositories, "/var/www/svn".  Each repository
    # must be readable and writable by the 'apache' user.  Note that if
    # SELinux is enabled, the repositories must be labelled with a context
    # which httpd can write to; this will happen by default for
    # directories created in /var/www.  Use "restorecon -R /var/www/svn"
    # to label the repositories if upgrading from a previous release.
    #
    
    #
    # To create a new repository "http://localhost/repos/stuff" using
    # this configuration, run as root:
    #
    #   # cd /var/www/svn
    #   # svnadmin create stuff   
    #   # chown -R apache.apache stuff
    #
    
    <Location /svnrepo>
    DAV svn
    SVNParentPath /var/www/svn
    
    # Limit write permission to list of valid users.
    <LimitExcept GET PROPFIND OPTIONS REPORT>
      # Require SSL connection for password protection.
      # SSLRequireSSL
    
      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /var/www/svn/.htpasswd
      Require valid-user
    </LimitExcept>
    </Location>
  3. svn用ディレクトリを作成
    # mkdir /var/www/svn
  4. svn用パスワードファイルを設定(test ユーザで作成)
    # htpasswd -c /var/www/svn/.htpasswd test
  5. svn用のリポジトリを作成(svntest リポジトリを作成)
    # svnadmin create /var/www/svn/svntest
  6. 所有者をapacheに変更します
    # chown -R apache:apache /var/www/svn/
  7. 一度yumを使いRPMforgeからtracをインストールします
    RPMforgeの設定がしてない場合は設定が必要になります
    # yum -y --enablerepo=rpmforge install trac
  8. trac日本語インストールするため、インストールしたtracパッケージをアンインストールします
    # yum -y remove trac
  9. trac最新版(日本語)をダウンロード
    ※一次保管ディレクトリは /usr/local/src とします
    # cd /usr/local/src/
    # wget http://www.i-act.co.jp/project/products/downloads/Trac-0.11.7.ja1.zip
  10. 落としてきたtracを解凍し、インストールします
    # unzip Trac-0.11.7.ja1.zip
    # cd Trac-0.11.7.ja1
    # ./setup.py install
  11. trac用ディレクトリを作成します
    # mkdir /var/www/trac
  12. tracのプロジェクトを作成(tractest を作成)
    # trac-admin /var/www/trac/tractest initenv
    Creating a new Trac environment at /var/www/trac/tractest
    
    Trac will first ask a few questions about your environment 
    in order to initialize and prepare the project database.
    
     Please enter the name of your project.
     This name will be used in page titles and descriptions.
    
    Project Name [My Project]> tractest
     
     Please specify the connection string for the database to use.
     By default, a local SQLite database is created in the environment
     directory. It is also possible to use an already existing
     PostgreSQL database (check the Trac documentation for the exact
     connection string syntax).
    
    Database connection string [sqlite:db/trac.db]> そのままエンター
     
     Please specify the type of version control system,
     By default, it will be svn.
    
     If you don't want to use Trac with version control integration,
     choose the default here and don't specify a repository directory.
     in the next question.
    
    Repository type [svn]> そのままエンター
    
     Please specify the absolute path to the version control
     repository, or leave it blank to use Trac without a repository.
     You can also set the repository location later.
    
    Path to repository [/path/to/repos]> /var/www/svn/svntest
    
    Creating and Initializing Project
     Installing default wiki pages
    
    ・・・・・・
    
    The latest documentation can also always be found on the project
    website:
    
      http://trac.edgewall.org/
    
    Congratulations!
  13. 所有者をapacheに変更します
    # chown -R apache:apache /var/www/trac
  14. trac用fcgiファイルをコピーします
    # cp -p /usr/local/src/Trac-0.11.7.ja1/cgi-bin/trac.fcgi /var/www/trac/trac.fcgi
  15. apacheにtrac用設定ファイルを追加
    # vi /etc/httpd/conf.d/trac.conf
    # Enable fastcgi for .fcgi files
    # (If you're using a distro package for mod_fcgi, something like
    # this is probably already present)
    
    <IfModule mod_fcgi.c>
       AddHandler fcgi-script .fcgi
       SocketPath /tmp/fcgid_sock/
    </IfModule>
    
    ScriptAlias /trac /var/www/trac/trac.fcgi
    
    <Location "/trac">
       SetEnv TRAC_ENV_PARENT_DIR "/var/www/trac"
       #FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/var/www/trac
       #FastCgiConfig -initial-env TRAC_ENV_EVN_DIR=/var/www/trac/tractest
       #DefaultInitEnv TRAC_ENV /var/www/trac/tractest
    </Location>
    
    
    #Alias /trac /var/www/trac
    <Directory "/var/www/trac">
      Order allow,deny
      Allow from all
    </Directory>
  16. apacheを再起動し、ブラウザより参照する(apacheで繋がるかだけチェック。tracのユーザ認証はしてません。)
    # /etc/rc.d/init.d/httpd restart
  17. lighttpdをインストール
    # yum --enablerepo=rpmforge -y install lighttpd lighttpd-fastcgi
  18. lighttpdの自動起動設定をする
    # chkconfig lighttpd on
  19. tracログイン用パスワードファイルを作成(test ユーザで作成)
    # htpasswd -c /var/www/trac/tractest/.htpasswd test
  20. lighttpd.conf(lighttpdの設定)を編集する
    # cp -p /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.org
    # vi /etc/lighttpd/lighttpd.conf
    ※コンフィグファイルが長いので抜粋
    #                               "mod_rewrite",
                                    "mod_rewrite",
    
    #                               "mod_alias",
                                    "mod_alias",
    
    #                               "mod_auth",
                                    "mod_auth",
    
    #                               "mod_fastcgi",
                                    "mod_fastcgi",
    
    #server.document-root        = "/srv/www/lighttpd/"
    server.document-root        = "/var/www/html/"
    
    #server.port                = 81
    server.port                 = 81
    
    #server.username            = "lighttpd"
    server.username            = "apache"
    
    #server.groupname           = "lighttpd"
    server.groupname           = "apache"
    
    #### SSL engine
    #ssl.engine                 = "enable"
    #ssl.pemfile                = "/etc/ssl/private/lighttpd.pem"
    
    ############# trac add ##################
    #  This is for handling multiple projects
      alias.url      += ( "/trac/" => "/var/www/trac/" )
    
      fastcgi.server += ("/trac"  =>
                          ("trac" =>
                            (
                              "socket" => "/tmp/trac.sock",
                              "bin-path" => "/var/www/trac/trac.fcgi",
                              "check-local" => "disable",
                              "bin-environment" =>
                                ("TRAC_ENV_PARENT_DIR" => "/var/www/trac/" )
                            )
                          )
                        )
    #And here starts the global auth configuration
      auth.backend = "htpasswd"
      $HTTP["url"] =~ "^/trac/tractest/login$" {
      auth.backend.htpasswd.userfile = "/var/www/trac/tractest/.htpasswd"
        auth.require = ("/" =>
                         (
                           "method"  => "basic",
                           "realm"   => "trac",
                           "require" => "valid-user"
                         )
                       )
      }
    
    #
    #  $HTTP["url"] =~ "^/trac/projectB/login$" {
    #  auth.backend.htpasswd.userfile = "/var/www/trac/projectB/.htpasswd"
    #    auth.require = ("/" =>
    #                     (
    #                       "method"  => "basic",
    #                       "realm"   => "trac",
    #                       "require" => "valid-user"
    #                     )
    #                   )
    #  } # 上記コメントアウト部分はプロジェクトが増えたときにはずして適宜に変更して対応。 
  21. ログディレクトリの所有者をapacheに変更
    # chown -R apache:apache /var/log/lighttpd/
  22. apache用trac設定を無効化・lighttpdをapache経由で表示設定する
    # mv /etc/httpd/conf.d/trac.conf /etc/httpd/conf.d/trac.conf.org
    # vi /etc/httpd/conf/httpd.conf
    ※コンフィグファイルが長いので抜粋
    #
    # Proxy Server directives. Uncomment the following lines to
    # enable the proxy server:
    #
    #<IfModule mod_proxy.c>
    <IfModule mod_proxy.c>
    #ProxyRequests On
    ProxyRequests On
    
       ProxyRequests Off
       ProxyPreserveHost On
    
       ProxyPass /trac http://localhost:81/trac
       ProxyPass /lighttpd http://localhost:81/lighttpd
    #
    #<Proxy *>
    #    Order deny,allow
    #    Deny from all
    #    Allow from .example.com
    #</Proxy>
    
    #
    # Enable/disable the handling of HTTP/1.1 "Via:" headers.
    # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
    # Set to one of: Off | On | Full | Block
    #
    #ProxyVia On
    
    #
    # To enable a cache of proxied content, uncomment the following lines.
    # See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.
    #
    #<IfModule mod_disk_cache.c>
    #   CacheEnable disk /
    #   CacheRoot "/var/cache/mod_proxy"
    #</IfModule>
    #
    
    #</IfModule>
    </IfModule>
    # End of proxy directives.
  23. lighttpdを起動する
    # /etc/rc.d/init.d/lighttpd start
  24. apacheを再起動する
    # /etc/rc.d/init.d/httpd restart

●以上でざっくりとした設定は終了です。

ざっくりなので、甘いところは多々ありそうです・・・。予めご了承ください。

プリンタ用画面
友達に伝える
前
lighttpd導入
カテゴリートップ
CentOS
次
LV作成