當 Perl 安裝模組透過 cpan 或是 cpanm 時須透過 公司 Proxy 時,這時候可以在 perl 的 shell 來進行設定.
設定 Proxy
進入 perl 的 shell 來進行設定,透過 o conf http_proxy 先觀察有無設定過 .
[root@localhost ~]# perl -MCPAN -e shell Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9600) Enter 'h' for help. cpan[1]> o conf http_proxy http_proxy [] Type 'o conf' to view all configuration items
透過 o conf init /proxy/ 來設定,可以依據需求來設定是 FTP 或是 HTTP Proxy.
cpan[2]> o conf init /proxy/ If you're accessing the net via proxies, you can specify them in the CPAN configuration or via environment variables. The variable in the $CPAN::Config takes precedence. <ftp_proxy> Your ftp_proxy? [] <http_proxy> Your http_proxy? [] a.b.c.d:port <no_proxy> Your no_proxy? [] If your proxy is an authenticating proxy, you can store your username permanently. If you do not want that, just press ENTER. You will then be asked for your username in every future session. Your proxy user id? [] ben10 Your password for the authenticating proxy can also be stored permanently on disk. If this violates your security policy, just press ENTER. You will then be asked for the password in every future session. Your proxy password? Please remember to call 'o conf commit' to make the config permanent!
最後還需要寫回至設定檔.
cpan[3]> o conf commit commit: wrote '/root/.cpan/CPAN/MyConfig.pm'
確認一下 http_proxy 設定.
cpan[4]> o conf http_proxy http_proxy [a.b.c.d:port] Type 'o conf' to view all configuration items
ctrl + D 可跳出 perl 的 shell.
cpan[5]> Terminal does not support GetHistory. Lockfile removed.
取消設定 Proxy
要取消設定 Proxy,一樣需進入 perl 的 shell 來進行設定,透過 o conf http_proxy 先觀察有無設定過 .
[root@localhost ~]# perl -MCPAN -e shell Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9600) Enter 'h' for help. cpan[1]> o conf http_proxy http_proxy [a.b.c.d:port] Type 'o conf' to view all configuration items
取消設定 Proxy.
cpan[2]> o conf http_proxy '' http_proxy [] Please use 'o conf commit' to make the config permanent!
最後還需要寫回至設定檔.
cpan[3]> o conf commit commit: wrote '/root/.cpan/CPAN/MyConfig.pm'
確認一下 http_proxy 設定,的確已取消.
cpan[3]> o conf http_proxy http_proxy [] Type 'o conf' to view all configuration items
ctrl + D 可跳出 perl 的 shell.
cpan[4]> Terminal does not support GetHistory. Warning: Configuration not saved. Lockfile removed.
沒有解決問題,試試搜尋本站其他內容