多trac的安裝和配置

來源:互聯網
上載者:User
        多個trac的安裝有一點複雜,關鍵是設定上會產生衝突,需要多多注意。具體的安裝方法和一個trac的安裝區別不是很大,需要注意的是每個trac項目必須使用自己的資料庫,而且所有trac要在同一個父目錄下。下面是我建立兩個trac的過程,建立父路徑在/home/trac下,兩個trac的名字分別叫project1和project2:

        首先要建立兩個資料庫,因為在之前的trac建立過程中,我們已經使用過了名叫trac的資料庫了,如果再次使用,會出現資料庫衝突,無法建立項目。所以我們要先刪除之前的項目和資料庫,然後再建立兩個新的資料庫:

sudo  rm  -rf  /home/hust_smartcar/trac  (刪除之前的trac項目)sudo  -u  postgres  sh (切換到postgres使用者)createuser  -A  -D  -P  hcx(建立hcx使用者,並提示輸入密碼,請輸入123456 )Shall the new role be allowed to create more new roles? (y/n)  ydropdb  trac   (刪除之前的資料庫)createdb  -O  hcx  trac (建立trac資料庫)createdb  -O  hcx  trac2 (建立trac2資料庫)exit (退出postgres使用者,回到正常使用者提示行)
        資料庫建立完畢,然後就可以開始建立項目了。建立第一個項目:
cd  /homesudo  mkdir  traccd  tracsudo  mkdir  project1sudo  chown  -R  www-data:www-data  project1sudo  -u  www-data  trac-admin  project1  initenvProject Name [My Project]> project1(在這裡輸入你的項目名稱)Database connection string [sqlite:db/trac.db]> postgres://hcx:123456@localhost/trac (輸入PostgreSQL資料庫的位置)Repository type [svn]>Path to repository [/path/to/repos]> Templates directory [/usr/share/trac/templates]>
        建立第二個項目:

sudo  mkdir  project2sudo  chown  -R  www-data:www-data  project2sudo  -u  www-data  trac-admin  project2  initenvProject Name [My Project]> project1(在這裡輸入你的項目名稱)Database connection string [sqlite:db/trac.db]> postgres://hcx:123456@localhost/trac2 (輸入PostgreSQL資料庫的位置)Repository type [svn]>Path to repository [/path/to/repos]> Templates directory [/usr/share/trac/templates]>
         建立完畢後,需要設定管理員:

sudo  a2enmod  pythonsudo  gedit  /etc/apache2/sites-available/trac
      然後編輯如下的配置:

<VirtualHost 192.168.0.108:80>    ServerName   hcx_project    ServerAdmin   407643110@qq.com    DocumentRoot   /home/trac    <Directory "/home/trac/project1">         Options Indexes FollowSymLinks MultiViews         AllowOverride None         Order allow,deny         allow from 127.0.0.1 192.168.0.0/24 192.168.1.0/24     </Directory>    <Directory "/home/trac/project2">         Options Indexes FollowSymLinks MultiViews         AllowOverride None#        Order allow,deny#        allow from 127.0.0.1 192.168.0.0/24 192.168.1.0/24 218.199.23.94 115.156.219.36 115.156.219.35    </Directory>    <Location />        SetHandler mod_python        PythonInterpreter main_interpreter        PythonHandler trac.web.modpython_frontend        PythonOption TracEnvParentDir /home/trac/ (這裡一定要改成TracEnvParentDir)        PythonOption TracUriRoot /        SetEnv PYTHON_EGG_CACHE /tmp    </Location>
    <Location /project1/login>        AuthType Basic        AuthName "TEST1 TRAC"        AuthUserFile /home/trac/project1/.htpasswd        Require Valid-user    </Location>    <Location /project2/login>        AuthType Basic        AuthName "TEST2 TRAC"        AuthUserFile /home/trac/project2/.htpasswd        Require Valid-user    </Location>    ErrorLog "/var/log/apache2/trac_errors.log"    CustomLog "/var/log/apache2/trac_accesses.log" common   </VirtualHost>
        設定Trac的存取權限

sudo  htpasswd  -c  /home/hust_smartcar/ trac/.htpasswd hcx
        將該虛擬機器主機啟用:

sudo  a2ensite  tracsudo  /etc/init.d/apache2  restart
        至此,兩個trac全部安裝完畢,在瀏覽器中輸入原生IP地址,可以看到兩個項目的目錄,就可以分別登入了:









聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.