install apache mason

1 篇文章 0 订阅
1 篇文章 0 订阅

What is mason?  http://www.masonhq.com/

Why mason? You are a PERL fan like me.


1. download Apache and make

wget http://www.apache.org/dist/httpd/httpd-2.2.21.tar.bz2

tar xjvf httpd-2.2.21.tar.bz2

./configure --prefix=/home/$USER/local/httpd \
    --enable-so    \
    --enable-cgi \
    --enable-info \
    --enable-rewrite \
    --enable-speling \
    --enable-usertrack \
    --enable-deflate \
    --enable-ssl \
    --enable-mime-magic \
    --enable-dav \
    --with-ssl=/usr/local/ssl

make && make install

If you have question when installing apache, google it. It is not the focus of this article. Make sure --enable-so and --enable-dav is in the option list.

2. download perl and make

I don't want to talk deeper about it, either. Go to http://www.perl.org/get.html and download a latest version. I used perl-5.14.2. There are tons of articles talking about how to install perl. But I suggest you should read the INSTALL file in perl-5.14.2.tar.gz firstly. Generally speaking, you can make perl by the commands below.

   sh Configure --help

   sh Configure -d  # withou the -d options, you have to press enter lots of times.
   make
   make test
   make install


3. make  mod_perl

Go to http://perl.apache.org/download/index.html. Download the latest version of mod_perl. I chose mod_perl-2.0.5 because I setup Apache 2.

   wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz

   tar xzvf .....

   perl Makefile.PL MP_APXS=/home/cydoo/local/httpd/bin/apxs

   make && make install

   file ~/local/httpd/modules/mod_perl.so

If you didn't install a new Apache as I did. You should pay attention. If you are using a pre-packaged Apache, you should read here http://perl.apache.org/docs/2.0/user/install/install.html#Dynamic_mod_perl.


4. Make mason.

Mason is something like PHP in PERL world. If you are a java developer, you can take it as freemaker, velocity, facelet or tiles. A template language and you can separate your business service from web layer. I don't want to dig deep why we need web layer. If you application is big enough, and you want to speed up when generating HTML. You will like to create a web layer for your application.

You can install mason with one line command: $PERL_HOME/bin/cpan HTML::Mason. But I choose to install it from svn.

   svn co https://svn.urth.org/svn/Mason/trunk Mason-trunk   
   cd Mason-trunk
   perl Build.PL
   ./Build
   ./Build install
5. Enable mason preprocessor in Apache.
vi $APACHE_HOME/conf/httpd.conf, add the following lines into httpd.conf
LoadModule perl_module        modules/mod_perl.so                                               
PerlModule HTML::Mason::ApacheHandler

AddHandler perl-script        .mi
AddHandler perl-script        .mason
PerlHandler HTML::Mason::ApacheHandler

DirectoryIndex index.html index.mi

DirectoryIndex index.html index.mason

6. Test if it works.

$APACHE_HOME/bin/apachectl restart

http://localhost:8000           # you can change you LISTEN port in httpd.conf

The page will tell you "It works". It means Apache works.

After then, create a index.mi in htdocs.

   mv index.html index.html.ori

   echo 'Greetings, <% ("Earthlings", "Martians")[rand 2] %>' > index.mi

Visit http://localhost:8000 again, you will get what you are looking for.

There is a sample folder in svn. You can start mason from there. Good luck.


7. Postscripts 

Install Mason on Ubutu again.

cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.3 LTS"

sudo apt-get install libboost-thread-dev
# install perl
wget    http://www.cpan.org/src/5.0/perl-5.12.5.tar.gz
	• CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dusethreads  -Dprefix=$HOME/local/perl-5.12.5   # for 64 bit system
	• ./Configure -des -Dusethreads  -Dprefix=$HOME/local/perl-5.12.5   # for 32bit system
make test
make install
# Add perl into your path.

# Install apache  http://tr.im/4d685 (omitted, -v 2.2.23)
./configure --enable-so --enable-ssl --with-ssl=$HOME/local/openssl  \
                     --enable-mods-shared=all --enable-cgi --enable-rewrite  \
                     --enable-info \
                     --enable-speling \
                     --enable-usertrack \
                     --enable-deflate \
                     --enable-mime-magic \
                     --enable-dav \
                     --prefix=$HOME/local/httpd && make && make install 

# install mod_perl
# Prerequisites, http://tr.im/4d674. Double check if you have time.
perl -MCPAN -e 'install("threads.pm")'   # shell
perl -MCPAN -e 'install("Compress::Zlib")'
wget http://perl.apache.org/dist/mod_perl-2.0.7.tar.gz
perl Makefile.PL MP_APXS=$HOME/local/httpd/bin/apxs && make && make install
ls `$HOME/local/httpd/bin/apxs -q LIBEXECDIR`/mod_perl.so
# Add the line      "LoadModule perl_module modules/mod_perl.so" into $HOME/local/httpd/conf/httpd.conf

# install mason
svn co https://svn.urth.org/^Cn/Mason/tags/release-1.33 mason-1.33
perl -MCPAN -e 'install("Params::Validate")' && \
    perl -MCPAN -e 'install("Exception::Class")' && \
    perl -MCPAN -e 'install("Class::Container")' && \
    perl -MCPAN -e 'install("File::Spec")' && \
    perl -MCPAN -e 'install("Scalar::Util")'  && \
    perl -MCPAN -e 'install("Cache::Cache")' && \
    perl -MCPAN -e 'install("CGI.pm")'
perl Build.PL &&   ./Build    &&    ./Build install
# Add the following lines into $HOME/local/httpd/conf/httpd.conf
<IfModule perl_module>
    PerlModule HTML::Mason::ApacheHandler                                                                                            
    AddHandler perl-script        .m
    AddHandler perl-script        .mi
    AddHandler perl-script        .mason
    PerlHandler HTML::Mason::ApacheHandler

    DirectoryIndex index.html index.m
    DirectoryIndex index.html index.mi
    DirectoryIndex index.html index.mason
</IfModule>

# Verify
echo 'Greetings, <% ("Earthlings", "Martians")[rand 2] %>' > $HOME/local/httpd/htdocs/index.mi
$HOME/local/httpd/bin/apachectl restart

https://yourhost:8000/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值