Difference between revisions of "CentOS"
Line 92: | Line 92: | ||
<pre># tip: Copy/paste two lines at a time | <pre># tip: Copy/paste two lines at a time | ||
yum -y install mysql mysql-server mysql-devel php php-gd php-mysql httpd gcc \ | yum -y install mysql mysql-server mysql-devel php php-gd php-mysql httpd gcc \ | ||
pcre-devel gd mod_ssl glib2-devel gcc-c++ ntp gnutls-devel | pcre-devel gd mod_ssl glib2-devel gcc-c++ ntp gnutls-devel ImageMagick | ||
yum -y install libjpeg-devel perl-Archive-Tar perl-MIME-Lite perl-MIME-tools \ | yum -y install libjpeg-devel perl-Archive-Tar perl-MIME-Lite perl-MIME-tools \ | ||
Line 195: | Line 195: | ||
---- | ---- | ||
Added Dependency: ImageMagick | |||
Removed Dependency: perl-Time-HiRes, which causes a conflict with the default perl package. | |||
Also, mysql seems to install with no password for the root user, and the zm DB create script creates the database on the fly, which means that the database create command needs to have the "-p zm" removed from the command line. | Also, mysql seems to install with no password for the root user, and the zm DB create script creates the database on the fly, which means that the database create command needs to have the "-p zm" removed from the command line. | ||
Could someone verify that this is correct, to make sure it's not just something I missed? | |||
Thanks! | Thanks! | ||
terry@cnysupport.com | terry@cnysupport.com |
Revision as of 11:26, 13 September 2009
The intent of this walk through is to install a very base/bare bones installation of CentOS that will only run ZoneMinder. This would be for a dedicated ZoneMinder server with no GUI or any unnecessary services running. The reason for the very light-weight installation is so that the majority of system resources are available to ZoneMinder and not having to power the OS. With this installation, memory is reduced to around 140-160MB, and CPU usage is practically nonexistent. CentOS is very easy to install the base installation and doesn’t take too much time as long as you have some type of broadband connection. There are many ways to install CentOS, but this will only cover two because they are related.
All CLI operations/commands in this How-To are done as root in the user root's directory. The reasoning is that this system would be in a secure environment to begin with. However, if you need to add a user to run these services to better secure the system then you can, but keep in mind that some items must be ran as root.
CentOS 5.3 & ZoneMinder 1.24.2
This guide is for CentOS v5.3 with ZoneMinder v1.24.2 which are the newest released versions as of this update (9/3/2009). If you are attempting to install newer versions of either using this guide you will have to adjust file and directory names below. Obviously at at the time of this update released versions newer than these have not been tested together.
Step One - Get CentOS
You can download the “.iso” file(s) for CentOS from http://www.centos.org/
Alternatively download the net-install version of CentOS which is basically just the first CD.
Here is one location to download the net-install version:
Download i386: http://mirror.chpc.utah.edu/pub/centos/5.3/isos/i386/CentOS-5.3-i386-netinstall.iso
Download 64 bit: http://centos.cs.wisc.edu/pub/mirrors/linux/centos/5.3/isos/x86_64/CentOS-5.3-x86_64-netinstall.iso
Mirrors List: http://www.centos.org/mirrors/
Step Two - Installation Source
Regardless of which method you use the next few steps are the same.
Begin by booting your system up with either cd/dvd.
Choose the options that best fit your environment until you reach the “Installation Method”.
Choose HTTP ONLY if you are using the net-install method. Otherwise, you probably want to choose Local CDROM.
If you are using the net-install method then enter:
Website Name: mirror.centos.org
CentOS Directory: (for i386) /centos/5.3/os/i386
CentOS Directory: (for 64 bit) /centos/5.3/os/x86_64
Step Three - Installation Packages
The first screen you want to un-check "Desktop - Gnome" and then check "Server" (not Server-GUI)
Then Make sure that you have "Customize now" selected at the bottom (do not check "Packages from CentOS Extras")
Then click "Next" to continue on
Once presented with the custom package selection you need to un-check/check the following:
Applications = Check only "Editors" and "Text Based Internet" Development = Check only "Development Libraries" and "Development Tools" Servers = Un-check everything Base System = Check only "Base" (you can check Administration Tools and System Tools if you need them, but they are not necessary)
Now let the system finish installing
Step Four - Configuration
After the first reboot the setup screen should appear. If not then log into the system and type "setup"
Go into the "Firewall Configuration" disable the Security Level, and Disable SELinux
Next we are going to disable a number of system services. Go back to the setup screen and go into "System Services"
Un-Check:
apmd bluetooth cups hidd ip6tables iptables netfs nfslock pcscd portmap
After disabling the services then select "Disable Now and On Boot", then exit the setup tool, and log into the system if you haven't already.
- Screen is a simple program that allows you to run commands from a "Hosted" command line interface. This helps if you loose your connection to the server for any reason in that it allows you to resume (screen -r) right where you left off. Often times I will start a large update/upgrade, leave it for the day, then come back and see where it is at later. Screen allows you to do that without having to be always connected.
- Install Screen
yum install screen
- To start a screen session just type
screen
- If you get disconnected and need to resume your session of screen simply type
screen -r
Step Five - Installing ZoneMinder 1.24.2
First we need to download files and prepare the system
- Add the RPM Forge repository to CentOS. This will allow the installation of a number of services/applications later on without having to manually install them.
# For i386 CentOS 5.x run: rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm # For 64 bit CentOS 5.x run: rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
- Download the needed files ZoneMinder 1.24.2 and the Cambozola addon
wget http://www2.zoneminder.com/downloads/ZoneMinder-1.24.2.tar.gz wget http://www.zoneminder.com/fileadmin/downloads/cambozola.jar
- Now let's install all the services and programs that will be needed (If you encounter any dependency errors using yum, try running yum clean all and then re-try the install command(s).)
# tip: Copy/paste two lines at a time yum -y install mysql mysql-server mysql-devel php php-gd php-mysql httpd gcc \ pcre-devel gd mod_ssl glib2-devel gcc-c++ ntp gnutls-devel ImageMagick yum -y install libjpeg-devel perl-Archive-Tar perl-MIME-Lite perl-MIME-tools \ perl-Date-Manip perl-LWP-UserAgent-Determined yum -y install perl-PHP-Serialization perl-Device-SerialPort perl-Archive-Zip \ perl-Module-Load subversion git
- Now let's update everything within the new CentOS install
yum -y update
- At this point it might be useful to reboot your system. Oddly, sometimes things don't work right unless you reboot after all the updates
reboot -or- shutdown -r now
- After reboot log back into your system
- Now we need to make sure we use the lasted "tested" version of "ffmpeg". This is the latest version of ffmpeg that the ZoneMinder developers have tested with. Download, compile and install ffmpeg:
git clone git://git.ffmpeg.org/ffmpeg/ cd ffmpeg git clone git://git.ffmpeg.org/libswscale/ ./configure make # Next two commands must be done as root make install make install-libs
- Turn everything on
# These commands must be run as root chkconfig httpd on chkconfig mysqld on chkconfig ntpd on service httpd start service mysqld start service ntpd start
- Next we need to extract the contents of the ZoneMinder "tar" file, and then jump into its directory
cd /root/ # Or your work directory for this installation tar -zxvf ZoneMinder-1.24.2.tar.gz cd ZoneMinder-1.24.2
- Now we are going to configure ZoneMinder with some added statements. What is listed are default CentOS directory placements.
./configure --with-webdir=/var/www/html/zm --with-cgidir=/var/www/cgi-bin
By default ZM_DB_HOST=localhost, ZM_DB_NAME=zm, ZM_DB_USER=zmuser, and ZM_DB_PASS=zmpass.
- Change "zmuser" (if you want) with the user that you will use within MySQL to access the ZoneMinder database
- Change "zmpass" with the password you will be using with the "zmuser" account
So if you wish to change it then use a command like:
./configure --with-webdir=/var/www/html/zm --with-cgidir=/var/www/cgi-bin --with-webuser=apache --with-webgroup=apache ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser ZM_DB_PASS=zmpass
- if you get the configure "error zm requires libmysqlclient.a" with 64 bit CentOS add the following to the end of you configure statement
--with-extralibs="-L/usr/lib64 -L/usr/lib64/mysql"
make # Run next command as root make install
- Need to add a password for the root user of MySQL
- Create the zm database
- Create the zm database user with permissions and password
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
- Import the tables into the zm database
cd /root/ZoneMinder-1.24.2 mysql -u root -p zm < db/zm_create.sql
All remaining CLI commands need to be run as root.
- Make it so that ZoneMinder will startup automatically when the system is rebooted
# from the ZoneMinder-1.24.2 source directory cp scripts/zm /etc/init.d/ chmod +x /etc/init.d/zm chkconfig zm on
- Add the Cambozola Java web interface
cp cambozola.jar /var/www/html/zm/
- and make sure you have permission to view it from apache:
chown apache:apache /var/www/html/zm/cambozola.jar
- Start ZoneMinder
service zm start
- tick the box for support for the Cambozola addon within your ZoneMinder installation: http://ip-address/zm (Options->Images tab->OPT_CAMBOZOLA)
Now have fun and add your cameras to ZoneMinder knowing that you now have a very stable and streamlined OS to run it on.
== '''P.S.''' == aspcicc@jumpy.it (Update: This does not appear to be required any more.)
Hi! and thanks for your guide.. i want to add a little correction that have made me crazy to resolve, when I poweroff or reboot system i obtain an error related to mysql database and i have understood that the problem was because mysqld is stopped before zoneminder to be more specific there isn't a link under rc0.d (halt) and rc6.d (reboot) to zoneminder that for this lack is simply killed by killall. To resolve this problem you need to add at the start of zm (under /etc/init.d) the line
' # chkconfig: 345 99 01 ' (without ' of course)
and then run chkconfig --level 345 zm on chkconfig --level 06 zm off
So the link to shutdown zm is created under rc0.d and rc6.d and zoneminder is started at the end of poweron and stopped at the beginning of the poweroff
For information about priority starting and stopping processes see: http://www.netadmintools.com/art94.html
Added Dependency: ImageMagick
Removed Dependency: perl-Time-HiRes, which causes a conflict with the default perl package.
Also, mysql seems to install with no password for the root user, and the zm DB create script creates the database on the fly, which means that the database create command needs to have the "-p zm" removed from the command line.
Could someone verify that this is correct, to make sure it's not just something I missed?
Thanks! terry@cnysupport.com