Centos 5.x/ZM 1.23.1 Setup Guide

Discussion in 'Suggest HOWTO' started by oakleeman, Feb 17, 2008.

  1. oakleeman

    oakleeman New Member

    Below is a modified version of Patrick Harper's Snort install guide that I adapted to work with ZoneMinder. When all of the bugs have been completely worked out then I will make a custom install cd if there is enough demand for it.

    At present I only have a Logitech Quickcam 4000 to use for testing and have confirmed that I am able to view/record video with this procedure.

    Installing CentOS 5:

    This is a minimal install of CentOS 5.X (or you can use RHEL 5.X with no changes or Fedora Core with few changes) this starts with a minimal install, and then uses yum to add the packages needed.

    You will start at a grub screen that has boot:, hit enter. Then you can either choose to check your cd’s or skip. If you know they are good then skip it otherwise you might want to check them out.


    Welcome:
    Click next

    Language:
    English

    Keyboard:
    U.S. English

    Install Type:
    Choose custom

    Disk Partitioning:
    Choose to automatically partition the hard drive.
    Choose to remove all partitions from this hard drive (I am assuming that this not a dual boot box)
    Make sure the review button is checked

    When the warning dialog comes up, choose Yes.

    Accept the default layout. Most of the disk will be /

    Boot Loader:
    Go with the default (if this is a dual boot system then go to google and search for info on how to install grub for dual booting)

    Network Configuration:
    Hit edit, Uncheck “Configure with DHCP”, Leave “Activate on boot”
    Set a static IP and subnet mask for your network
    Manually set the hostname
    Set a gateway and the DNS address(s)

    Additional Language:
    Choose only US English

    Time Setup:
    Choose the closest city within your time zone (for central choose Chicago)

    Root Password:
    Set a strong root password here (a strong password has at least 8 characters with a combination of upper case, lower case, numbers and symbols. It should also not be, or resemble, anything that might be found in a dictionary of any language)

    Packages:
    Uncheck everything, select “customize packages now”, and uncheck everything but BASE to get a minimal install

    After the packages install:

    Reboot – hit the reboot button

    After the reboot:

    Run the Firewall Configuration tool:
    Choose “enabled”
    Select remote login (SSH) and Web Server (HHTP, HTTPS)
    For SELinux, move to disabled.

    You are now in run level 3 – command line only

    Login as root and setup a user account for yourself

    User Account:

    Add a user account for yourself here; make sure to give it a strong password

    The root account should not be used for everyday use, if you need access to root functions then you can “su -“ or “sudo” for root access. (For help with sudo visit google.com)

    Code:
    groupadd <groupname>
    useradd –g <groupname> <username>
    passwd <username>
    You will then be asked to enter and then confirm a password. You can now login as a normal user and, if necessary, if you want root privileges, use su – .

    Disable unneeded services:
    Disable apmd, cups, netfs, nfslock, portmap by typing (as root): Chkconfig <service> off

    You will do this for each service to be terminated.

    Install needed packages
    For some packages we will be installing from the RPMForge repository, they also have a lot of other software. Download the RPM for your distribution from here:

    http://dag.wieers.com/rpm/FAQ.php#B and use rpm –Uvh to install it so you update the existing RPM for yum


    Then use this line to install all the needed software:

    Code:
    yum install mysql mysql-bench mysql-server mysql-devel mysqlclient10 php php-gd php-mysql httpd gcc pcre-devel gd mod_ssl glib2-devel gcc-c++ ntp gnutls-devel libjpeg-devel ffmpeg perl-Archive-Tar perl-MIME-Lite perl-MIME-tools perl-Date-Manip perl-Time-HiRes perl-LWP-UserAgent-Determined perl-PHP-Serialization perl-Device-SerialPort perl-Archive-Zip perl-Module-Load
    Hit “y” to accept this and its dependencies

    Update your system
    Type “yum -y update” and it will check what needs updated and install it.

    (Type “chkconfig yum-updatresd on” and “service yum start” to turn on nightly updates, this is an optional step)

    Reboot in order to boot to the newly downloaded kernel before installing ZoneMinder.


    You are now ready to start installing ZoneMinder. You can either do this from the command line, or SSH into the server from another box. Either will work fine. For the novice it might be easier to do this from SSH so they can cut and paste the commands from this document into the session, instead of typing some of the long strings.

    Preparing for the install:

    Again, if you are not logged in as root, then you will need to su to root ("su -" will load the environmental variables of root. Use that when you su.). Ensure that you have downloaded all of the installation files before you start the install, it will go smoother, trust me. Go to your download directory and start with the following procedures.

    Turn on and set to start the services you will need

    Code:
    chkconfig httpd on
    chkconfig mysqld on
    chkconfig ntpd on
    service httpd start
    service mysqld start
    service ntpd start
    Download all the needed files:

    Remember, you can always check where you are currently by typing “pwd” at the command line. Note: If you are not logged in as root, then you will need to execute “su – “ (“su” gives you the super user or root account rights, the “–“ loads the environmental variables of the root account for you) and then enter the root password.


    !!!DO THE FOLLOWING AS ROOT!!!


    If you want to use a Windows box and need an SSH client, then you can go to the PuTTY http://www.chiark.greenend.org.uk/~sgtatham/putty/ home page and download a free one. This is for windows machines to SSH to Linux/UNIX box‟s OR http://ftp.ssh.com/pub/ssh/SSHSecureShellClient-3.2.9.exe for a client that can both SSH
    and start an SCP connection to the box you have SSH‟d to from within the session. This is free for non-commercial use and pretty nice.


    Place all the downloaded files into a single directory for easy access and consolidation. This directory will not be needed when you are finished with the installation and may be deleted at that time. Create a directory under /root called zminstall. From the command line type:

    Code:
    cd /root
    mkdir zminstall
    cd zminstall
    Use your wget from the command line or an SSH terminal window from inside of /root/zminstall so all your install files are in one place unless otherwise directed to.


    Installing and setting up ZoneMinder:

    Code:
    wget http://www2.zoneminder.com/downloads/ZoneMinder-1.23.1.tar.gz
    tar -xvzf ZoneMinder-1.23.1.tar.gz
    cd ZoneMinder-1.23.1
    
    ./configure --with-webdir=/var/www/html/zm --with-cgidir=/var/www/cgi-bin ZM_DB_USER=your_zm_user ZM_DB_PASS=your_zm_password
    make
    make install
    Setting up the database in MySQL:

    I will put a line with a > in front of it so you will see what the output should be. (Note: In MySQL, a semi-colon ” ; “ character is mandatory at the end of each input line) “password‟ is whatever password you want to give it, just remember what you assign.

    For the zm user use what you put in the ./configure step in the section above)

    Code:
    mysql
    mysql> SET PASSWORD FOR root@localhost=PASSWORD('new_root_password');
    >Query OK, 0 rows affected (0.00 sec)
    mysql> create database zm;
    >Query OK, 1 row affected (0.01 sec)
    mysql> grant CREATE, INSERT, SELECT, DELETE, UPDATE on zm.* to your_zm_user@localhost;
    >Query OK, 0 rows affected (0.02 sec)
    mysql> SET PASSWORD FOR your_zm_user@localhost=PASSWORD('your_zm_password_from_above');
    >Query OK, 0 rows affected (0.25 sec)
    mysql> exit
    >Bye

    Execute the following commands to create the tables:

    Code:
    mysql -u root -p < /root/zminstall/ZoneMinder-1.23.1/db/zm_create.sql zm
    Enter password: [i]the mysql root password[/i]

    Now you need to check and make sure that the zm DB was created correctly:

    Code:
    mysql -p
    >Enter password:
    mysql> SHOW DATABASES;
    (You should see the following)
    
    +------------+
    | Database
    +------------+
    | information_schema 
    | mysql              
    | test               
    | zm                 
    +------------+
    4 rows in set (0.00 sec)
    
    mysql> use zm
    >Database changed
    mysql> SHOW TABLES;
    +------------------+
    | Tables_in_zm
    +------------------+
    | Config         
    | ControlPresets  
    | Controls       
    | Devices        
    | Events          
    | Filters        
    | Frames          
    | Groups          
    | MonitorPresets 
    | Monitors        
    | States          
    | Stats          
    | TriggersX10    
    | Users          
    | ZonePresets     
    | Zones 
    +------------------+
    16 rows in set (0.00 sec)
    mysql>exit;
    Make Zoneminder start at boot:
    Code:
    cp /root/zminstall/ZoneMinder-1.23.1/scripts/zm /etc/init.d/
    chmod +x /etc/init.d/zm
    chkconfig zm on
    Start the Zoneminder service:
    Code:
    service zm start
    From another computer open up a browser and browse to http://your.ip.address/zm and begin configuring your camera equipment.

    Items remaining:
    ZM errors when compiling with ffmpeg enabled
    Add Cambozola
     
  2. falko

    falko Super Moderator Howtoforge Staff

Share This Page