From Campworld

LinuxServersFC5: HOWTO OpenVZ VPS (Virtual Private Server) Base Server Setup

History / Status

Introduction

All of our servers will start with this install. This base server is based on Fedora Core 5. This version of the HOWTO guides you through setting up an OpenVZ virtual server.

Creating the Virtual Private Server

This is the easy part. The example commands below will use an ID of 101 and an ip address of 192.168.150.221. You will need to chose an appropreate ID and ip address for your situation. Type the follwoing.
> vzctl create 101 --ostemplate fedora-core-5-default
> vzctl set 101 --ipadd 192.168.150.221 --save
> vzctl set 101 --hostname basesever.domain.com --save
> vzctl set 101 --nameserver 192.168.150.254 --save
> vzctl set 101 --privvmpages 400M:405M --save

We should increase the VPS's disk quota to 5GB.
> vzctl set 101 --diskspace 5200000:5200000 --save

Now start the VPS.
> vzctl start 101

Once the VPS is started we need to set the root password. So type the follwoing.
> vzctl set 101 --userpasswd root:test

Updating the VPS

Type in the following to update the system.
> vzyum 101 upgrade

When its done reboot the VPS. Type: > vzctl stop 101
> vzctl start 101

Installing Additional Packages

We need to add a couple of repos. One is the Fedora Core 5 Extras. The other one is my own. Add the following to /vz/template/fedora-core/5/i386/config/yum.conf

 
[fc5-extras]
name=Fedora Extras $releasever - $basearch
#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-extras-$releasever
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

[campworld]
name=Campworld repo
baseurl=http://www.campworld.net/repos/FC5/
enabled=1
gpgcheck=0

Now we'll load some php modules that will cause items such as mysql to load with it.
> vzyum 101 install php-gd php-imap php-mysql php-ncurses php-snmp php-mbstring mysql-server

Lets install postfix and get rid of sendmail.
> vzyum 101 install postfix
> vzyum 101 remove sendmail

Some misc packages
> vzyum 101 install nano createrepo yum ncftp

We need SSL support in perl. Setup is easier if you get this installed before webmin.
> vzyum 101 install perl-Net-SSLeay

Now lets install webmin.
> vzyum 101 install webmin

Next log in to the VPS. We need to add the compworld repo to yum inside the VPS. Create /etc/yum.repos.d/campworld.repo with the following info.

 
[campworld]
name=Campworld repo
baseurl=http://www.campworld.net/repos/FC5/
enabled=1
gpgcheck=0

Now we need to do a little house keeping so yum runs correctly. type the following
> localedef -v -i en_US -c en_US.UTF-8

Webmin Configuration

Installing phpMyAdmin

I perfer to phpMyAdmin to manage my MySQL databases. There is no rpm for this package. This package is easy to install.

  1. If you haven't already done so, start MySQL.
  2. Its time to set the root password.
    > /usr/bin/mysqladmin -u root password 'thepassword'
    > /usr/bin/mysqladmin -p -u root -h localhost.localdomain password 'thepassword'
  3. Download the latest version of phpMyAdmin from www.phpmyadmin.net
  4. unpack the package
    > tar -xzvf phpMyAdmin-2.8.1.tar.gz
  5. Move it to the appropriate place.
    > mv phpMyAdmin-2.8.1 /usr/share/
  6. Create the apache config file for phpmyadmin and restart apache.
    > echo "alias /webdb /usr/share/phpMyAdmin-2.8.1" > /etc/httpd/conf.d/phpMyAdmin.conf
    > service httpd restart
  7. Configure phpMyAdmin
    > cd /usr/share/phpMyAdmin-2.7.0-pl1
    > cp libraries/config.default.php config.inc.php
    > nano -w config.inc.php
  8. Locate each of the following lines and be sure each has the following settings.
    $cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (con$
    $cfg['Servers'][$i]['user'] = 'root'; // MySQL user
    $cfg['Servers'][$i]['password'] = ''; // MySQL password (only nee$
  9. Save the file.
  10. now test it out.

Getting root's and other's mail

You need to get some local system user's mail. We'll use postfix's virtual file to get the emails to the right place.

1. Add the following to /etc/postfix/virtual

 
root       admin@yourdomain.com
postmaster admin@yourdomain.com
abuse      admin@yourdomain.com

2. Now add the configuration option to main.cf
> postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

3. Just a couple commands to wrap everything up.
> postmap /etc/postfix/virtual
> /etc/init.d/postfix restart

Creating a Cache File for easy VPS Deployment

We don't want to do this work every time we create a new VPS. So its time to create a cache. Type the following.
> cd /vz/private/101/
> tar czf /vz/template/cache/FC5-baseserver.tar.gz *

When you are ready to deploy a new base VPS server (aka this howto) then you use the created cache file. Below is an example fo how to create a VPS with an ID of 102.
> cp /etc/vz/dists/fedora-core.conf /etc/vz/dists/FC5-baseserver.conf
> vzctl create 800 --ostemplate FC5-baseserver --ipadd 192.168.150.222 --hostname newserver

Conclusion

That's it for the basic server setup. This is an example of a standard linux server setup. See the other pages for info on configuring servers for virtual webhosting or virtual email hosting.

If this is your first VPS I recommend that you don't configure it any further. You should save it for cloning to other VPSes to save time.

Comments

Retrieved from http://www.campworld.net/thewiki/pmwiki.php/LinuxServersFC5/FC5OpenVZBaseServer
Page last modified on May 30, 2007, at 06:37 PM