第一步:下載並安裝Tor 在官方網站下載最新版本的Tor,我下載的是tor-0.2.0.19-alpha.tar.gz,考慮到系統兼容性,我下載的是非RPM的包。 tar zxvf tor-0.2.0.19-alpha.tar.gz cd tor-0.2.0.19-alpha ./configure make make install 如果順利的話應該就安裝成功了,不過我在configure時遇到一下的出錯信息而中斷: checking whether we need extra options to link libevent… configure: error: Found linkable libevent in (system), but it does not seem to run, even with -R. Maybe specify another using ?with-libevent-dir} 雖然Fedora 8日已經安裝好libevent的包的,但顯然配置程序並沒有找到默認路徑,這時候我只能到libevent的官方網站下載最新的libevent版本: http://www.monkey.org/~provos/libevent/ http://www.monkey.org/~provos/libevent-1.4.1-beta.tar.gz libevent包的安裝方式類似,很順利,然後回到Tor的目錄里重新指定libevent目錄重新安裝: ./configure ?with-libevent-dir=/usr/local/lib make make install 順利安裝成功。
第三步:設置Tor啟動和控制文件 以上配置好以後,默認情況下已經可以通過/usr/local/bin/tor -f /usr/local/etc/tor/torrc &來把服務運行在後台了,不過為了讓以後方便管理,可以再配置一下啟動和控制腳本。 回到安裝包的解壓的目錄,進去子目錄contrib。 vi torctl 編輯此文件,並確保相應的指定的文件與目錄都正確: # the path to your binary, including options if necessary TORBIN=」/usr/local/bin/$EXEC」 # the path to the configuration file TORCONF=」/usr/local/etc/tor/torrc」 # the path to your PID file PIDFILE=」/var/run/tor/tor.pid」 # The path to the log file LOGFILE=」/var/log/tor/tor.log」 # The path to the datadirectory TORDATA=」/var/lib/tor」 設置Tor運行用戶,可以指定用戶也可以用root,如果指定用戶的話,需要確保相應目錄的許可權無誤: TORUSER=root TORGROUP=root 然後copy控制文件到相應的調用目錄: cp torctl /usr/local/bin/ 最後配置tor.sh腳本確保對torctl調用目錄的正確以下啟動用戶的正確: TORCTL=/usr/local/bin/torctl TORUSER=root export TORUSER TORGROUP=root export TORGROUP 把編輯好以後的tor.sh複製到啟動腳本目錄就可以運行了: cp tor.sh /etc/rc.d/init.d/ #tor.sh Usage: /etc/rc.d/init.d/tor.sh (start|stop|restart|reload|status)
正常啟動后,應該在tor的日誌文件里看到如下記錄,那麼你的服務就正常了: Feb 23 23:29:36.464 [notice] Tor 0.2.0.19-alpha (r13450) opening log file. Feb 23 23:29:36.466 [warn] You are running Tor as root. You don』t need to, and you probably shouldn』t. Feb 23 23:29:37.054 [notice] Your Tor server』s identity key fingerprint is ………….. Feb 23 23:29:40.083 [notice] We now have enough directory information to build circuits. Feb 23 23:29:41.946 [notice] Self-testing indicates your ORPort is reachable from the outside. Excellent. Publishing server descriptor. Feb 23 23:29:46.656 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. Feb 23 23:30:43.600 [notice] Self-testing indicates your DirPort is reachable from the outside. Excellent. Feb 23 23:31:49.993 [notice] Performing bandwidth self-test…done.