What do I need to set up and maintain a local CPAN mirror? What scripts and best practices should I be aware of?
-
Here is a complete, easy and step by step, article with all commands ... just copy and paste and it should work pretty much :) [Install your own Perl with your own CPAN](http://perl-node-interface.blogspot.com/2012/02/install-your-own-perl-with-your-own.html) – Gianluca Casati Feb 18 '12 at 01:51
5 Answers
CPAN::Mini is the way to go. Once you've mirrored CPAN locally, you'll want to set your mirror URL in CPAN.pm or CPANPLUS to the local directory using a "file:" URL like this:
file:///path/to/my/cpan/mirror
If you'd like your mirror to have copies of development versions of CPAN distribution, you can use CPAN::Mini::Devel.
Update:
The "What do I need to mirror CPAN?" FAQ given in another answer is for mirroring all of CPAN, usually to provide another public mirror. That includes old, outdated versions of distributions. CPAN::Mini just mirrors the latest versions. This is much smaller and for most users is generally what people would use for local or disconnected (laptop) access to CPAN.

- 2,975
- 19
- 17
-
as of 1.1, http://search.cpan.org/perldoc?App::cpanminus App::cpanminus (cpanm) supports --mirror-only to pull metadata from your local mirror without querying online. >1.1000 Thu Nov 11 23:56:46 PST 2010 - Added --mirror-only to support minicpan and DarkPAN (jonallen, xdg, tokuhirom) – spazm Feb 23 '11 at 21:05
Besides the other answers, check out Leon's CPAN::Mini::Webserver, which gives you a CPAN Search interface to your local CPAN copy.
If you want to do more fancy things, see my "MyCPAN" talk. You can inject your own private modules into your private CPAN with CPAN::Mini::Inject, for instance.

- 61,471
- 9
- 126
- 175

- 129,424
- 31
- 207
- 592
CPAN::Mini is fine. By default it keeps only the latest version of a distribution, not every version as CPAN does.
You can also install CPAN::Mini::Webserver, which provides you with a web interface to your local cpan mirror - very handy if you are offline and still want to work with perl.

- 12,710
- 1
- 41
- 63
Try CPAN::Mini.

- 116,958
- 15
- 196
- 339

- 10,555
- 1
- 31
- 31
-
1Or, if that link disappears because it's tied to a particulr version, try CPAN::Mini. See How to link to CPAN modules in answers for the discussion of timeless linking. :) – brian d foy Sep 20 '08 at 21:21
-
Or stop using search.cpan.org and use the metacpan (better looking, and open source!): https://metacpan.org/pod/CPAN::Mini – Randal Schwartz May 28 '15 at 21:23
The most likely scenario for running a CPAN mirror is so that your network of 50 machines can all be updated from it locally, instead of hitting the network 50 times.
I'd argue that using CPAN in the traditional manner is a poor way to keep a network of servers up to date.
I run a network of RedHat machines. I package all CPAN modules intended for use in production into RPMs (mostly using the cpanflute2 tool from RPM::Specfile) and deploy them that way, thereby ensuring proper dependency tracking which you don't really get from CPAN itself in any sane way.

- 3,097
- 1
- 20
- 15
-
And I hope you don't use RedHat's vendor perl? it's full of problematic "fixes" that the perl developers shake their heads about. If we receive a bug report from a RedHat user, the first step is always to verify that it's a problem with perl, not with RedHat. Most of the time it *is* RedHat. – moritz Sep 23 '08 at 10:13