Seitenanfang

Setting up a OpenVZ/MongoDB/YAWF VE

Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.


The YAWF framework is available from CPAN, but it still needs a Webserver and some environment for working at it's best. This tutorial shows everything needed to set up a new OpenVZ VE (VServer) with MongoDB and YAWF framework on an existing OpenVZ host.

Creating the new OpenVZ VE

Latest (OpenVZ) Ubuntu is 11.04 and the precreated Ubuntu package is ready for download from then OpenVZ homepage:

wget http://download.openvz.org/template/precreated/ubuntu-11.04-x86_64.tar.gz

Ubuntu doesn't have a usable root account. You may change this, but it's not recommended and not needed at all. I downloaded the image into my home directory and moved it to the place where OpenVZ expects template images:

sudo mv ubuntu-11.04-x86_64.tar.gz /var/lib/vz/template/cache/

Setting up a new VE is easy: Choose a free VE number (use sudo vzlist -a to see existing VEs), add some arguments and you're done.

sudo vzctl create 51 --ostemplate ubuntu-11.04-x86_64 --ipadd 111.222.333.444 --hostname yawf01

Notice: The template name must not contain the final .tar.gz of the downloaded file, vzctl add it when creating the ve. My new VE will  use the VE number 51 and obviously the sample IP 111.222.333.444 has to be replaced by a free IP address from your IP range. Creating a VE will take up to some minutes, be patient.

Some additional configuration settings should be set once the VE has been created. I added three nameservers, enabled auto-start of this VE when the OpenVZ server boots and set some other values. Don't just copy this string, set the values based on your needs and available hardware!

sudo vzctl set 51 --save \   --nameserver 222.222.222.222 --nameserver 333.333.333.333 --nameserver 444.444.444.444 \   --onboot yes --diskspace 80G:999G --vmguarpages 262144 --oomguarpages 262144 \   --privvmpages 524288:786432 --numfile 65535:65535 --numflock 32768:32768

The VE is ready for it's first startup, let's run it now:

sudo vzctl start 51Starting container ...Container is mountedAdding IP address(es): 111.222.333.444Setting CPU units: 1000Configure meminfo: 524288Set hostname: yawf01File resolv.conf was modifiedContainer start in progress...

It takes seconds to minutes for the VE to finally boot, but the OpenVZ part is over now, let's switch into our new VE and prepare the environment for Apache, MongoDB and YAWF.

sudo vzctl enter 51

Look at this vzctl bugreportif your "vzctl enter" hangs.

Setting up Apache and other stuff

Everything below should be done within the VE and not on the OpenVZ host.

First let's remove some stuff installed by the templates we don't need:

apt-get remove openssh-server xinetd

xinetd will be reinstalled if any depending service will be installed and openssh-server isn't necessary while we're using vzctl enter. Now install the required packages:

apt-get update
apt-get install apache2 libapache2-mod-perl2 libcgi-pm-perl libclass-xsaccessor-perl libdbix-class-perl \
   libfile-sharedir-perl libfile-spec-perl libtemplate-perl libtime-local-perl mongodb \   libipc-sharedcache-perl libdbd-sqlite3-perl libany-moose-perl libdatetime-perl libmouse-perl \   libjson-xs-perl libjson-perl libipc-sharelite-perl libtest-deep-perl libtest-fatal-perl \   libdata-types-perl libyaml-perl build-essential libgd-securityimage-perl libyaml-tiny-perl

The "apt-get" command will add all the dependencies and install a huge number of packages.

Some required modules are not packed by Ubuntu, but CPAN could get them.

cpan

[...]

Would you like me to configure as much as possible automatically? [yes]

[...]

cpan[2]> o conf prerequisites_policy follow prerequisites_policy [follow]Please use 'o conf commit' to make the config permanent!

cpan[3]> o conf build_requires_install_policy yes build_requires_install_policy [yes]Please use 'o conf commit' to make the config permanent!

cpan[4]> o conf commitcommit: wrote '/etc/perl/CPAN/Config.pm'

cpan[5]> install YAWF YAWF::Object::MongoDB

Installation of YAWF and it's dependencies will take some time, be patient.

YAWF::Object::MongoDB might fail installation depending on the installed MongoDB version. Using "force install" should be save, but a MongoDB server version >= 1.9 is recommended. Get it from the MongoDB download page, a 64 bit server is preferred if you installed a 64 bit OpenVZ template before.

/etc/init.d/mongodb stopcdwget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.1.tgztar -xzvf mongodb-linux-x86_64-2.0.1.tgzcp mongodb-linux-x86_64-2.0.1/bin/* /usr/lib/mongodb/rm -rf mongodb-linux-x86_64-2.0.1*/etc/init.d/mongodb startcpan YAWF::Object::MongoDB

Everything should be installed now.

Configuring Apache for YAWF

One step left: Set up a basic configuration for Apache to run YAWF based projects.

YAWF benefits from the vhost_alias Apache module (but it's not required), enable it:

cd /etc/apache2/mods-enabledln -sv ../mods-available/vhost_alias.load .

Create a new virtual host config file "yawf-multidomain" in /etc/apache2/sites-available:

<VirtualHost 111.222.333.444:80> ServerAdmin webmaster@localhost ServerName 111.222.333.444

DocumentRoot /var/www/yawf-multidomain/htdocs VirtualDocumentRoot /var/www/yawf-multidomain/htdocs/%-2.0.%-1 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/yawf-multidomain> Options -Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>

<Files yawf.yml> Deny from all </Files>

PerlSetEnv PERL5LIB /var/www/yawf-multidomain/lib PerlModule YAWF::Apache PerlOptions +GlobalRequest +SetupEnv PerlResponseHandler YAWF::Apache

SetHandler perl-script

<FilesMatch "\.(jpe?g|gif|css|png|js|ico|mp3|wav|swf)"> SetHandler default-handler </FilesMatch>

</VirtualHost>

Switch to /etc/apache2/sites-enabled and add a symlink for the new config:

ln -sv ../sites-available/yawf-multidomain

Create the directories mentioned in the virtual host config above:

mkdir -p /var/www/yawf-multidomain/lib /var/www/yawf-multidomain/htdocs

You're done, everything is ready for adding your YAWF project.

Create a folder named like a domain (without www.) in /var/www/yawf-multidomain/htdocs and set up your yawf.yml in /var/www/yawf-multidomain/htdocs/yawf.yml and the YAWF framework will help you rapid-developing web-projects which may life in /var/www/yawf-multidomain/lib or anywhere else within your Perl's @INC...cpan[4]

 

Noch keine Kommentare. Schreib was dazu

Schreib was dazu

Die folgenden HTML-Tags sind erlaubt:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>