App::lcpan::Manual::Tutorial::200_SettingUpAMiniCPAN - Setting up a local "mini" CPAN mirror
Setting up a local "mini" CPAN mirror is as easy as:
% lcpan update --verbose
and after a few hours of downloading and indexing, your local CPAN mirror is ready at ~/cpan.
However, usually you might want to tweak a few things first.
To customize the location of the mirror instead of using the default ~/cpan, put this in ~/lcpan.conf (or /etc/lcpan.conf if you run as root):
cpan = /path/to/cpan
and make sure the path exists and is writable.
If you don't want a config file, you can specify --cpan option everytime you invoke lcpan.
The index database that lcpan creates is usually put in the top-level directory of the CPAN mirror (~/cpan/index.db). It is beneficial to put the index on a fast SSD instead of the slower harddisk, so if you happen to put the CPAN mirror on a harddisk, you can point the index to a different location using this configuration line:
Some releases are big (tens to over 100MB files) and some contain a lot (like thousands) of modules. This will require more time to download and index. I usually put these lines in my configuration:
; don't download files over 200MB
; don't index these files which contain thousands of autogenerated modules
skip_index_file_patterns = ^eBay-API-\d
skip_index_file_patterns = ^Google-Ads-GoogleAds-Client-\d
skip_index_file_patterns = ^Google-Ads-AdWords-Client-\d
skip_index_file_patterns = ^GOOGLE-ADWORDS-PERL-CLIENT-\d
skip_index_file_patterns = ^Microsoft-AdCenter-\d
skip_index_file_patterns = ^Paws-\d
skip_index_file_patterns = ^VMOMI-\d
because I never use those modules. You might or might not want to do the same. For me, those lines cut down the amount of indexing from several hours to to under an hour.
To install modules from your local mirror, you can use:
% cpanm --mirror file:/path/to/cpan --mirror-only -n MODULE::NAME
The --mirror-only option prevents cpanm from falling back to a normal, remote CPAN mirror, since your mini CPAN already contains "the whole" CPAN (well, all the indexed modules anyway).
You can make the mirror accessible via HTTP/HTTPS using whatever webserver software or framework, e.g. http://localhost:2020/ or https://example.com/cpan/, and use it just as easily with cpanm:
% cpanm --mirror http://localhost:2020/ --mirror-only -n MODULE::NAME
lcpan is created so you can query the database for various information. For example, to find out what modules the Dist-Zilla distribution requires:
% lcpan deps Dist-Zilla
% lcpan deps Dist::Zilla ;# same thing
% lcpan deps -R Dist::Zilla --exclude-core
If you want to query over HTTP, there's App::lcpan::Daemon which is a PSGI application you can run with a PSGI-compliant webserver.
If you want a nice web interface like MetaCPAN for your local mini CPAN mirror, currently you're out of luck. Maybe I or someone else will get around to it. Note that you can also setup a MetaCPAN of your own, but it's more involved.
This software is copyright (c) 2021, 2020 by firstname.lastname@example.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::lcpan::Manual, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.