【工具】
yum install gcc gcc-c++ make
【yum安装】
以下命令基本上把perl的模块给安装齐了:
yum install perl*
安装CPAN,这样以后有什么需要直接用cpan编译安装:
yum install cpan
参考:http://httpd.apache.org/docs-2.0/howto/cgi
【升级】
参考:https://www.quyu.net/info/739.html
参考:https://yq.aliyun.com/articles/476622
下载:http://www.cpan.org/src/5.0/
手册:http://www.cpan.org/src/README.html
意图:通过源码编译实现升级到Perl最新版本 Perl 5.28.0
先看一下 Perl 的安装路径:
which perl
输出:
/usr/bin/perl
ll /usr/bin/perl
输出:
-rwxr-xr-x 2 root root 5396 Mar 22 2017 /usr/bin/perl
下载源码开始编译安装:
wget http://www.cpan.org/src/5.0/perl-5.28.0.tar.gz && tar -zxvf perl-5.28.0.tar.gz && cd perl-5.28.0 ./Configure -des -Dprefix=/usr/local/perl -Dusethreads -Uinstalluserbinperl -Dcc=gcc make -j4 && make install
安装完成后 Perl 所在目录为 /usr/local/perl,Perl 执行文件在 /usr/local/bin 里。
替换系统原有的 Perl:
mv /usr/bin/perl /usr/bin/perl.bak ln -s /usr/local/perl/bin/perl /usr/bin/perl
查看版本:
perl -v
输出:
This is perl 5, version 28, subversion 0 (v5.28.0) built for x86_64-linux-thread-multi Copyright 1987-2018, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
升级成功!
重启系统,登入shell时报错:
Can't locate local/lib.pm in @INC (you may need to install the local::lib module) (@INC contains: /usr/local/perl/lib/site_perl/5.28.0/x86_64-linux-thread-multi /usr/local/perl/lib/site_perl/5.28.0 /usr/local/perl/lib/5.28.0/x86_64-linux-thread-multi /usr/local/perl/lib/5.28.0). BEGIN failed--compilation aborted.
那就执行:
cpan install local::lib
重启系统,登入shell时正常。
【通过apxs工具添加cgi模块】
apxs工具可以在不重新编译Apache的情况下添加模块,如cgi模块。
参考:http://www.cnblogs.com/52php/p/5669833
Apache运行cgi程序需要用到2个模块:mod_cgi.so 与 mod_cgid.so:
LoadModule cgi_module modules/mod_cgi.so LoadModule cgid_module modules/mod_cgid.so
如要额外安装cgi,先找到mod_cgi.c及mod_cgid.c。一般在apache安装包目录下:
wget http://www-us.apache.org/dist//httpd/httpd-2.4.23.tar.gz && tar -zxvf httpd-2.4.23.tar.gz && cd httpd-2.4.23/modules/generators
编译安装 cgi模块:
/usr/local/apache2/bin/apxs -i -a -c mod_cgi.c
输出:
... Libraries have been installed in: /usr/local/apache2/modules ... chmod 755 /usr/local/apache2/modules/mod_cgi.so [activating module `cgi' in /usr/local/apache2/conf/httpd.conf]
最后一行表示,在httpd.conf中已经加载了cgi module。
编译安装 cgid模板:
/usr/local/apache2/bin/apxs -i -a -c mod_cgid.c
输出:
... Libraries have been installed in: /usr/local/apache2/modules ... chmod 755 /usr/local/apache2/modules/mod_cgid.so [activating module `cgid' in /usr/local/apache2/conf/httpd.conf]
最后一行表示,在httpd.conf中已经加载了cgid module。
查看下配置文件 httpd.conf ,发现cgi与cgid模块已被加载:
... LoadModule cgi_module modules/mod_cgi.so LoadModule cgid_module modules/mod_cgid.so
重启Apache:
service httpd stop && service httpd start
查看phpinfo:
Loaded Modules ... mod_cgi mod_cgid
Apache(httpd.conf)加载cgi模块正常。
4. 配置Apache运行cgi
编辑 /usr/local/apache2/conf/extra/httpd-vhosts.conf :
<virtualhost 123.123.123.123:80> ServerName stats.amon.org DocumentRoot /usr/local/awstats/wwwroot/ Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/" Alias /awstatscss "/usr/local/awstats/wwwroot/css/" Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/" ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/" <directory "/usr/local/awstats/wwwroot"> Options Indexes FollowSymLinks AllowOverride All Require all granted </directory> </virtualhost>