CentOS 6 Linux Server Cookbook - Jonathan Hobson - E-Book

CentOS 6 Linux Server Cookbook E-Book

Jonathan Hobson

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

CentOS is a community-based enterprise class operating system and this book will provide a series of practical solutions that will not only show you how to install and maintain CentOS as a server, but to explore this well-known Linux distribution with the intention of tackling many common issues by providing some tricks of the trade in order to simplify the task of building a server."CentOS 6 Linux Server Cookbook" is a practical guide to installation, configuration, administration, and maintenance. This is a one-stop-shop to all things CentOS, so regardless as to whether you need a mail server, web server, database server, domain server or a file sharing platform, this book provides a comprehensive series of starting points that will give you direct access to the inner workings of this open source, community-based enterprise server."CentOS 6 Linux Server Cookbook" is a practical guide to the complete installation, configuration, administration, and maintenance of one of the world's most popular community-based enterprise servers.From installation to configuration, this book of recipes will take you on a journey to explore inner workings of CentOS server. Within this book you will learn how to install CentOS in variety of settings, enhance your installation with the correct tools of the trade and prepare your server to fulfil almost any role you could ever need.By discovering more about time, networking, package management, system management and security, this book will serve to show you how to get the very best from this freely available, open source server by presenting a series of solutions that will enable you to master the art of building your very own web, database, mail, domain name, file sharing services.CentOS 6 Linux Server Cookbook is a hands-on approach to installing, configuring and managing this ever popular community based enterprise server. By taking you from installation to customization this book will serve all Linux professionals and enthusiasts alike by providing you with a practical guide to using CentOS as a world-class server solution that is capable of delivering your mail, web, ftp, domain and file sharing services.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 506

Veröffentlichungsjahr: 2013

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

CentOS 6 Linux Server Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Installing CentOS
Introduction
Downloading CentOS and confirming the checksum on a Windows desktop
Getting ready
How to do it...
How it works…
See also
Performing an installation of CentOS using the graphical installer
Getting ready
How to do it...
How it works…
See also
Running a netinstall over HTTP
Getting ready
How to do it...
How it works...
See also
Installing CentOS in Text Mode and building a minimal installation
Getting ready
How to do it...
How it works...
See also
Re-installing the boot loader
Getting ready
How to do it...
How it works...
Updating the installation and enhancing the minimal install with additional administration and development tools
Getting ready
How to do it...
How it works...
See also
Finishing the installation process with Firstboot
Getting ready
How to do it...
How it works...
There's more...
Adding the GNOME desktop environment, changing the runlevel, and installing additional software
Getting ready
How to do it...
How it works...
2. Configuring CentOS
Introduction
Changing the time zone and updating the hardware clock
Getting ready
How to do it...
How it works...
There's more...
Linking time and location
Synchronizing the system clock with NTP
Getting ready
How to do it...
How it works...
There's more...
Synchronizing multiple machines
Modifying the logfile's location
Fudging time
See also
Setting a static IP address
Getting ready
How to do it...
How it works...
There's more...
Substituting the Netmask value with a prefix
Finding your HWADDR/MAC address
Binding multiple IP addresses to a single Ethernet device
Getting ready
How to do it...
How it works...
There's more...
Bonding two Ethernet devices to increase bandwidth and provide redundancy
Getting ready
How to do it...
How it works...
There's more...
Changing the hostname and resolving a fully qualified domain name
Getting ready
How to do it...
How it works...
There's more...
Switching SELinux off
Getting ready
How to do it...
How it works...
See also
Disabling the IPv6 module
Getting ready
How to do it...
How it works...
There's more...
3. Working with CentOS
Introduction
Creating an administrative user and becoming root with the switch user command
Getting ready
How to do it...
How it works...
There's more...
Introducing mailx and forwarding the root's e-mail to an external e-mail address
Getting ready
How to do it...
How it works...
There's more...
Automating tasks with cron
Getting ready
How to do it...
How it works...
There's more...
See also
Synchronizing files and directories with rsync and working towards a full system backup with cron
Getting ready
How to do it...
How it works...
There's more...
See also
Issuing customized e-mail reports with Mutt
Getting ready
How to do it...
How it works...
There's more...
See also
Using logrotate to manage logfiles
Getting ready
How to do it...
How it works...
There's more...
Extending log rotation by adding NTP to logrotate
Getting ready
How to do it...
How it works...
Using chkconfig to enable a custom service at boot
Getting ready
How to do it...
How it works...
There's more...
Evaluating current memory usage with the free and top commands and clearing the memory cache
Getting ready
How to do it...
How it works...
There's more...
4. Managing Packages with Yum
Introduction
Updating the system with YUM
Getting ready
How to do it...
How it works...
There's more...
See also
Cleaning the YUM cache
Getting ready
How to do it...
How it works...
There's more...
See also
Automating Yum updates with Yum-cron
Getting ready
How to do it...
How it works...
See also
Installing packages with YUM
Getting ready
How to do it...
How it works...
There's more...
See also
Removing packages with YUM
Getting ready
How to do it...
How it works...
There's more...
See also
Finding packages with YUM
Getting ready
How to do it...
How it works...
There's more...
See also
Installing Yum Priorities to support additional repositories
Getting ready
How to do it...
How it works...
See also
Enhancing CentOS with the EPEL and Remi repositories
Getting ready
How to do it...
How it works...
See also
5. Securing CentOS
Introduction
Escalating user privilege with sudo
Getting ready
How to do it...
How it works...
There's more...
Change the default timeout
Hardening the secure shell environment
Getting ready
How to do it...
How it works...
There's more...
Changing the SSH port number of your server
Limiting SSH access by user or group
See also
Configuring a firewall and working with IPTables
Getting ready
How to do it...
How it works...
There's more...
Allowing an IP address
Banning an IP address
See also
Protecting SSH with fail2ban
Getting ready
How to do it...
How it works...
There's more...
See also
Preventing dictionary-based attacks with DenyHosts
Getting ready
How to do it...
How it works...
There's more...
Unblocking an IP address
See also
Running antivirus scans with ClamAV
Getting ready
How to do it...
How it works...
There's more...
See also...
6. Working with Samba
Introduction
Configuring Samba as a standalone server and enabling home directories
Getting ready
How to do it...
How it works...
There's more...
Disable printing support in Samba
Relaxing the rules for SELinux
Opening the firewall
Assigning the master browser
See also
Adding, deleting, and disabling a Samba user
Getting ready
How to do it...
How it works...
There's more...
Providing a network recycle bin for Samba
Getting ready
How to do it...
How it works...
There's more...
Hiding folders and files with Samba
Getting ready
How to do it...
How it works...
There's more...
Creating a custom share folder for a specific user or a group of users
Getting ready
How to do it...
How it works...
There's more...
Controlling access and enabling a write list for specific users or groups
Enabling guest-only access to a custom share folder
See also
7. Working with Domains
Introduction
Building a caching-only nameserver with BIND
Getting ready
How to do it...
How it works...
There's more...
Enabling access to a DNS server from behind a firewall
Cleaning expired records
See also
Writing zone files for BIND
Getting ready
How to do it...
How it works...
See also
Adding zones to BIND and configuring a nameserver
Getting ready
How to do it...
How it works...
There's more...
See also
Deploying a local nameserver with dnsmasq
Getting ready
How to do it...
How it works...
See also
Logging events with dnsmasq and combining this with logrotate
Getting ready
How to do it...
How it works...
See also
Enabling domain name wildcards with dnsmasq
Getting ready
How to do it...
How it works...
See also
Hardening BIND with chroot and providing better security measures
Getting ready
How to do it...
How it works...
See also
8. Working with Databases
Introduction
Installing and hardening MySQL server with mysql_secure_installation
Getting ready
How to do it...
How it works...
There's more...
See also
Creating a MySQL database, adding a MySQL user, and assigning user privilege from the command line
Getting ready
How to do it...
How it works...
There's more...
Reviewing and revoking permissions or dropping a user
See also
Installing PostgreSQL, adding a user, and creating your first database
Getting ready
How to do it...
How it works...
There's more...
Connecting to PostgreSQL
Accessing a PostgreSQL database using psql
Creating a copy of a database in PostgreSQL
See also
Configuring remote access to PostgreSQL
Getting ready
How to do it...
How it works...
See also
9. Providing Mail Services
Introduction
Enabling a domain-wide Mail Transport Agent (MTA) and testing your SMTP configuration with Telnet
Getting ready
How to do it...
How it works...
There's more...
See also
Building a local POP3/SMTP server with Postfix and Dovecot
Getting ready
How to do it...
How it works...
There's more...
Setting up e-mail software
See also
Closing the open relay, enabling SMTP authentication and dealing with Spam by configuring SASL, and enabling Postfix header and body checks
Getting ready
How to do it...
How it works...
There's more...
Setting up e-mail software with SMTP authentication
See also
Using Postfix and Dovecot to serve e-mails across virtual domains
Getting ready
How to do it...
How it works...
There's more...
Setting up a catch-all e-mail address for a virtual domain
See also
10. Working with Apache
Introduction
Installing the Apache web server with CGI/Perl, PHP, configuring mod_perl, and preparing httpd for a production environment
Getting ready
How to do it...
How it works...
There's more...
Running a CGI/Perl script
Activating ModPerl::PerlRun
See also
Adding a secure connection to the Apache web server by creating a self-signed SSL certificate using OpenSSL
Getting ready
How to do it...
How it works...
See also
Hosting peers by enabling user directories on the Apache web server and troubleshooting suexec
Getting ready
How to do it...
How it works...
There's more...
Reinstating suexec
See also
Configuring Apache name-based virtual hosting
Getting ready
How to do it...
How it works...
There's more...
See also
Working with publishing directories, vhosts.d, error documents, directives, and the rewrite rule for virtual hosting with the Apache web server
Getting ready
How to do it...
How it works...
See also
11. Working with FTP
Introduction
Building a basic FTP service by installing and configuring VSFTP
Getting ready
How to do it...
How it works...
There's more...
Changing the default time-out
Banning a user from the FTP service
Customizing the banner
See also
Providing a secure connection to VSFTP with SSL/TLS using OpenSSL encryption
Getting ready
How to do it...
How it works...
See also
Implementing virtual users and directories in standalone mode on VSFTP
Getting ready
How to do it...
How it works...
There's more...
Providing an anonymous upload and download or download only FTP server with VSFTP
Getting ready
How to do it...
How it works...
There's more...
Index

CentOS 6 Linux Server Cookbook

CentOS 6 Linux Server Cookbook

Copyright © 2013 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: April 2013

Production Reference: 1090413

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-84951-902-1

www.packtpub.com

Cover Image by Jasmine Doremus (<[email protected]>)

Credits

Author

Jonathan Hobson

Reviewers

Ugo Bellavance

Benoît Benedetti

Frank Lemmon

Acquisition Editor

Joanne Fitzpatrick

Lead Technical Editor

Dayan Hyames

Technical Editors

Dominic Pereira

Saijul Shah

Project Coordinator

Abhishek Kori

Proofreader

Mario Cecere

Indexer

Hemangini Bari

Production Coordinator

Shantanu Zagade

Cover Work

Shantanu Zagade

About the Author

Jonathan Hobson is a Web Developer, Systems Engineer, and Applications Programmer, who, for more than 20 years has been working behind the scenes to support companies, organizations, and individuals around the world to realize their digital ambitions. With an honors degree in both English and History and as a respected practitioner of many computer languages, Jonathan enjoys writing code, publishing articles, building computers, playing video games, and getting "out and about" in the big outdoors. He has been using CentOS since its inception and over the years, it has not only earned his trust, but it has become his first-choice server solution. CentOS is a first class community-based enterprise class operating system, it is a pleasure to work with, and because of this, Jonathan has written this book in order that his knowledge and experience can be passed on to others.

About the Reviewers

Ugo Bellavance, who has done most of his studies in e-commerce, started using Linux at Red Hat 5.2, got Linux training from Savoir-Faire-Linux at age 20, and got his RHCE on RHEL 6 in 2011. He's been a consultant in the past, but he's now an employee for a provincial government agency for which he manages the infrastructure (servers, workstations, network, security, virtualization, SAN/NAS, PBX). He's a big fan of open source software and its underlying philosophy. He's worked with Debian, Ubuntu, SUSE, but what he knows best is RHEL-based distributions. He's known for his contributions to the MailScanner project (he has been a technical reviewer for the MailScanner book), but also dedicated his time to different open source projects such as Mondo Rescue, OTRS, SpamAssassin, pfSense, and a few others.

I thank my lover, Lysanne, who accepted to allow me some free time slots for this review even with a two year-old and a six month-old to take care of. The presence of these three human beings in my life is simply invaluable.

I must also thank my friend Sébastien, whose generosity is only matched by his knowledge and kindness. I would never have reached that high in my career if it wasn't for him.

Benoît Benedetti works as a Linux System Administrator, for the University of Nice Sophia Antipolis, where he graduated with a degree in computer science.

He is always interested in resolving new problems, as it's an opportunity to work with new technologies. Benoît loves helping users, teaching students, and writing technical articles for GNU/Linux Magazine and GNU/Linux Pratique—the historical monthly magazines about Linux in France.

He would like to thank every person who dedicates their time developing free and open source software, and making them available for us to 
play with.

Frank Lemmon is a Senior Software QA Professional with seven years of CentOS experience. His past work experience includes working at Yahoo!, Qualys, Hewlett-Packard, and various other start-ups.

He worked as a reviewer on the first edition of the book, OWASP Developer's Guide.

In memory of my father, who valued the importance of education and was an inspiration to me.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. 

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

This book is dedicated to my family. I couldn't have done it without you.

Preface

Building a server can present a challenge. It is often difficult at the best of times and frustrating at the worst of times. They can represent the biggest of problems or give you a great sense of pride and achievement. Where the word "server" can describe many things, it is the intention of this book to lift the lid and expose the inner workings of this enterprise-class computing system with the intention of enabling you to build the professional server solution of choice.

CentOS is a community-based enterprise class operating system. It is available free of charge, and as a fully compatible derivative of Red Hat Enterprise Linux (RHEL) it represents the first choice operating system for organizations, companies, professionals, and home users all over the world who intend to run a server. It's widely respected as a very powerful and flexible Linux distribution and regardless as to whether you intend to run a web server, file server, FTP server, domain server, or a multi-role solution, it is the purpose of this book to deliver a series of turn-key solutions that will show you how quickly you can build a fully capable and comprehensive server system using the CentOS 6 operating system.

So with this in mind, you could say that this book represents more than just another introduction to yet another server-based operating system. This is a cookbook about an enterprise-class operating system that provides a step-by-step approach to making it work. So, regardless as to whether you are a new or an experienced user, there is something inside these pages for everyone, as this book will become your practical guide to getting things done and a starting point to all things CentOS.

What this book covers

Chapter 1, Installing CentOS, is a series of recipes that introduces you to the task of installing your server, updating, and enhancing the minimal install with additional tools and adding a desktop environment. It is designed to get you started and to provide a reference that shows you a number of ways to achieve the desired installation.

Chapter 2, Configuring CentOS, is designed to follow on from a successful installation to offer a helping hand and provide you with a number of recipes that will enable you to achieve the desired server configuration. From changing the time zone and updating the hardware clock to binding multiple IP addresses, you will not only learn how to resolve a fully qualified domain name but you will be shown how to work with multiple Ethernet devices and manage SELinux.

Chapter 3, Working with CentOS, provides the building blocks that will enable you to champion your server and take control of your environment. It is here to kick start your role as a server administrator, by disseminating a wealth of information that will walk you through a variety of steps that are required to develop a fully considered and professional server solution.

Chapter 4, Managing Packages with Yum, serves to introduce you to the definitive package manager for CentOS 6 server. From upgrading the system to finding, installing, removing, and enhancing your system with additional repositories, it is the purpose of this chapter to explain the open source command-line package management utility known as the Yellowdog Updater, Modified.

Chapter 5, Securing CentOS, discusses the need to implement a series of solutions that will deliver the level of protection you need to run a successful server solution. From escalating user privileges to preventing dictionary-based attacks, you will see how easy it is to build a server that not only considers the need to reduce risk from external attack but one that will provide additional protection for your users.

Chapter 6, Working with Samba, focuses on the power and simplicity of file sharing with Samba in order to provide CentOS 6 server with the ability to provide a sense of community within the workplace.

Chapter 7, Working with Domains, considers the steps required to implement domain names, domain resolution, and DNS queries on a CentOS 6 server. The domain name system is an essential role of any server and whether you are intending to support a home network or a full corporate environment, it is the purpose of this chapter to provide a series of solutions that will deliver the beginning of a future-proof solution.

Chapter 8, Working with Databases, provides a series of recipes that delivers instant access to MySQL and PostgreSQL with the intention of explaining the necessary steps required to deploy them on a CentOS 6 server.

Chapter 9, Providing Mail Services, introduces you to the process of enabling a domain-wide Mail Transport Agent to your CentOS 6 server. From building a local POP3/SMTP server to configuring SASL and dealing with SPAM, the purpose of this chapter is to provide the groundwork for all your future e-mail-based needs.

Chapter 10, Working with Apache, investigates the role of this well known server technology to full effect, and whether you are intending to run a development server or a live production server, this chapter provides you with the necessary steps to deliver the features you need to become the master of your web based publishing solution.

Chapter 11, Working with FTP, concentrates on the role of VSFTP with a series of recipes that will provide the guidance you need to install, configure and manage the File Transfer Protocol you want to provide on a CentOS 6 server.

What you need for this book

The requirements of this book are relatively simple and begin with the need to download the CentOS operating system. The software is free, but you will need a computer that is capable of fulfilling the role of a server, an Internet connection, some spare time, and a desire to have fun.

In saying that, many readers will be aware that you do not need a spare computer to take advantage of this book as the option of installing CentOS on virtualization software is always available. This approach is quite common and where the recipes contained within these pages remain applicable, you should be aware that the use of virtualization software is not considered by this book. For this reason any requests for support regarding this the use of this software should be directed towards the appropriate supplier.

Who this book is for

This is a practical guide for building a server solution, and rather than being about CentOS itself, this is a book that will show you how to get CentOS up and running. It is a book that has been written with the novice-to-intermediate Linux user in mind who is intending to use CentOS as the basis of their next server. However, if you are new to operating systems as a whole, then don't worry; this book will also serve to provide you with the step-by-step approach you need to build a complete server solution with plenty of tricks of the trade thrown in for good measure.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Again, if you experience any difficulties, simply check the logfile located at /var/log/maillog."

A block of code is set as follows:

include "/etc/named.rfc1912.zones"; zone "XXX.XXX.XXX.in-addr.arpa" IN { type master; file "/var/named/hostname.domainname.lan.db"; allow-update { none; }; };

Any command-line input or output is written as follows:

vi /etc/named.conf

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The second step is to choose the button labeled Configure Network (located in the lower-left portion of the screen) and use the resulting Network Connections dialog box to record any changes to your Ethernet settings."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Installing CentOS

In this chapter, we will cover:

Downloading CentOS and confirming the checksum on a Windows desktopPerforming an installation of CentOS using the graphical installerRunning a netinstall over HTTPInstalling CentOS in Text Mode and building a minimal installationRe-installing the boot loaderUpdating the installation and enhancing the minimal install with additional administration and development toolsFinishing the installation process with FirstbootAdding the GNOME desktop environment, changing the runlevel, and installing additional software

Introduction

This chapter is a collection of recipes that will guide you through the process of un-wrapping the box and exploring a wide range of installation techniques by downloading CentOS and confirming the checksum on a Windows desktop; performing an installation of CentOS using the graphical installer; running a netinstall over HTTP; installing CentOS in Text Mode and building a minimal installation; re-installing the boot loader; updating the installation and enhancing the minimal install with additional administration and development tools; finishing the installation process with Firstboot; adding the GNOME desktop environment, changing the runlevel and installing additional software.

Downloading CentOS and confirming the checksum on a Windows desktop

In this recipe we will learn how to download and confirm the checksum of one or more CentOS 6 disk image(s) using a typical Windows desktop computer.

CentOS is made available in various formats by HTTP, FTP, or via a Torrent-based client from a series of mirror sites located across the world. It supports both the 32-bit and 64-bit architectures, and having downloaded one or more image files, it is often a good idea to validate those files' checksum in order to ensure that any resulting media should function and perform as expected.

Getting ready

To complete this recipe it is assumed that you are using a typical Windows-based computer (Windows 7, Windows Vista, or similar) with full administration rights. You will need an Internet connection to download the required installation files and access to a standard DVD/CD disk burner with the appropriate software in order to create the relevant installation disks.

How to do it...

Regardless as to what type of installation files you download, the following techniques can be applied to all image files supplied by the CentOS project:

So let's begin by visiting http://www.centos.org/mirrors-list in your browser.

Note

This URL was correct at the time of writing this book, but if it's no longer functional or is not available, then simply visit http://www.centos.org and navigate to Downloads | Mirrors | CentOS Public Mirror List or review the links associated with the latest release announcements made on the home page.

The mirror sites are categorized, so from the resulting list of links, choose a mirror that best suits your current location. For example, if you are in London (UK), you can choose European Mirrors (Countries N-Z).From the resulting list and depending on your preferred method of downloading the CentOS images, scroll down and choose a mirror site by selecting either, the HTTP or the FTP link.Having made your selection, you will now see a list of directories or folders that will allow you to choose the version of CentOS you want to install. To proceed, simply select the appropriate folder that reads 6.X, where X is the required minor release of CentOS 6.Having chosen the preferred minor release of CentOS you want to install, you will now see an additional list of directories that includes centosplus, contrib, cr, extras, fasttrack, isos, os, and updates. To proceed, choose the isos directory.At this point you are now given the opportunity to choose the preferred architecture. The directory labeled i386 is a container for the 32-bit version while the directory labeled x86_64 is a container for the 64-bit version. Make the appropriate selection to proceed.You will now be presented with a series of files available for download. Begin by downloading a copy of the valid checksum result labeled or identified as md5sum.txt.

Note

As this is a standard text file, place your mouse on the link, right-click and choose Save As to download a copy of md5sum.txt. When finished, store this file in a safe place for future reference. For the purpose of this recipe, it is assumed that all downloads will be stored in your C:\Users\<username>\Downloads folder.

Now, depending on which installation image best suits your needs, start downloading the relevant file(s) in the usual way.

Note

If you are new to CentOS or are intending to follow the recipes found throughout this book, then the minimal installation is ideal. However, you should be aware that there are other options available to you.

For a full 64-bit DVD-based installation, you will need both:

CentOS-6.X-x86_64-bin-DVD1.iso

CentOS-6.X-x86_64-bin-DVD2.iso

For a full 32-bit DVD-based installation, you will need both:

CentOS-6.X-i386-bin-DVD1.iso

CentOS-6.X-i386-bin-DVD2.iso

For a minimal installation, you should choose either:

CentOS-6.X-i386-minimal.iso (32-bit version)

CentOS-6.X-x86_64-minimal.iso (64-bit version)

For a network installation, you should choose either:

CentOS-6.X-i386-netinstall.iso (32-bit version)

CentOS-6.X-x86_64-netinstall.iso (64-bit version)

If you choose to download a torrent file, then you will need to extract these files in the usual way in order to build the appropriate ISO image file(s).

When you have finished downloading the required files, visit http://mirror.centos.org/centos/dostools/ in your browser.Now download the following DOS-based tool in order that we can use it to validate our installation files:
md5sum.exe

Note

The full URL is http://mirror.centos.org/centos/dostools/md5sum.exe.

It is assumed that you have downloaded all the files to the typical downloads folder of the current user profile on your Windows desktop (C:\Users\<username>\Downloads), so when the download is complete, open Command Prompt (typically found at Start | All Programs | Accessories | Command Prompt) and type the following command to access this location:
cd downloads
To see the list of files and the relevant extensions, type the following command:
dir
The command prompt should now list all the files in your download folder (including all image files, md5sum.txt, and md5sum.exe). Based on the file names shown, modify the following command in order to check the checksum of your ISO image file and type:
md5sum.exe your_image_file_name_here.iso

Note

For example, you can type md5sum.exe CentOS-6.X-x86_64-minimal.iso

Press the Return key to proceed and then wait for the command prompt to respond. The response is known as the sum and the result could look like this:
087713752fa88c03a5e8471c661ad1a2 *CentOS-6.X-x86_64-minimal.iso
Now look at the value given, this is known as the sum, and compare against the relevant listing for your particular image file listed in md5sum.txt. If both numbers match, then you can be confident that you have indeed downloaded a valid CentOS image file.Now repeat this process for any remaining image files and when you have finished, simply burn your image file(s) to a blank CD-Rom or DVD-Rom using your preferred desktop software.

How it works…

The act of downloading an installation image and validating the file's integrity is just the first step towards building the perfect server, and although the process of downloading CentOS is very simple, many do forget the need to confirm the checksum.

So what have we learned from this experience?

We began this recipe by showing you how to download CentOS by outlining the various options available to you. It is not expected that you will need to do this often, but during the course of this recipe you also learned how to navigate the CentOS Project website and select the best download location based on your current location.

Having done this, our next step was to obtain a copy of md5sum.txt before downloading the preferred image files.

Note

The choice as to whether you selected a 32-bit or 64-bit version is largely dependent on the specification of your intended server. However, given the abilities of most modern computers, for most people the obvious choice will be the 64-bit version in order that you can take advantage of the improved code base and support more than 4 GB of RAM.

The time required to complete the task of downloading the relevant files will depend largely on the speed of your Internet connection, but it was important that we obtained a copy of md5sum.exe in order to confirm file integrity and compare the value given against those listed in md5sum.txt.

The DOS-based tool was obtained from http://mirror.centos.org/centos/dostools/md5sum.exe.

Having completed these steps, we then proceed to open a command prompt session and navigate to the expected destination of all the files by typing:

cd downloads

We then proceeded to view the contents of C:\Users\<username>\Downloads by typing the following command:

dir

This action lists the filenames concerned, thereby enabling us to modify the following command in order to validate the appropriate ISO files:

md5sum.exe your_image_file_name_here.iso

The resulting response provides us with the checksum value of the file in question in order that we can compare it with the corresponding value found in md5sum.txt.

For example, the content of md5sum.txt may look like this:

087713752fa88c03a5e8471c661ad1a2 CentOS-6.X-x86_64-minimal.iso

Whereas the display in command prompt may show:

087713752fa88c03a5e8471c661ad1a2 *CentOS-6.X-x86_64-minimal.iso

You should repeat this process for all image files, and if these values match, then you can be confident that your download is verified. A fact that not only reduces the chance of wasting optical disks, but with security in mind, it also implies that what you downloaded is what you were expecting to download (and not something else).

So remember, with every new release the CentOS team will update the main website and enable you to download the required image files. Unless the CentOS project states otherwise, you will only need to do this once, as all minor updates can be managed like any other operating system (discussed later in this book). However, if you do intend to download them again, then it is always a good idea to check the integrity of your image files with the md5sum checksum tool.

See also

CentOS project home page: http://www.centos.orgCentOS project – mirror list: http://www.centos.org/mirrors-listCentOS project – approved vendors: http://www.centos.org/vendorsCentOS project – download FAQ regarding md5 checksum: http://www.centos.org/modules/smartfaq/faq.php?faqid=46CentOS project – how to burn an ISO image: http://www.centos.org/docs/5/html/CD_burning_howto.html

Performing an installation of CentOS using the graphical installer

In this recipe we will learn how to perform a typical installation of CentOS using the graphical tools provided by the system installer.

In many respects this is considered to be the recommended approach to installing your system as it not only provides you with the chance to create the desired hard disk partitions, but also provides the ability to customize package selection. Your installation will then form the basis of a server on which you can build, develop, and run any type of service you may want to provide in the future.

Getting ready

Before we begin, it is assumed that you have followed a previous recipe in which you were shown how to download CentOS, confirm the checksum of the relevant image files, and create the relevant installation disks.

Depending on which installation image(s) were downloaded, in order to complete this recipe you will be expected to have completed the initial stages of a network install or that you are using one of the following DVD suites:

To complete a full 64-bit installation you will need:
CentOS-6.X-x86_64-bin-DVD1.iso CentOS-6.X-x86_64-bin-DVD2.iso
To complete a full 32-bit installation you will need:
CentOS-6.X-i386-bin-DVD1.iso CentOS-6.X-i386-bin-DVD2.iso

In addition to this, you should be confident that your server can meet the following minimum specifications:

An Intel or AMD-based CPU (Pentium, AMD, Via, AMD64/EM64T)At least 768 MB RAM (1 GB or more recommended)At least 10 GB hard disk space

Of course, it should be said that the preceding specification acts as guidance only and further details concerning the minimum system requirements can be found at the end of this recipe.

Note

For a typical server you should always consider the need to maximize your resources in terms of RAM and available hard disk space. You should also plan for the long term. Remember, the use of a 64-bit capable CPU will not only tend to run faster with a 64-bit operating system but the system as a whole will be able to take advantage of more than 4 GB of RAM and therefore provide a long-term, scalable solution that can grow with the needs of your network.

How to do it...

To begin this recipe, start by booting your computer from the first CentOS installation DVD and wait for the welcome screen:

On the welcome splash screen, use the Up and Down arrow keys to select and highlight install or upgrade an existing system. When you are ready, press the Return key to proceed.Having loaded the necessary files, you will be presented with the disc found screen and asked if you would like to test the integrity of your DVD. Remember, file integrity in this context refers to the quality of the data on your DVD media only, so if you are confident that your installation media is error free and wish to continue with the installation, simply use the Left and Right arrow keys to choose Skip and press the Return key to proceed.Alternatively, if you would prefer to test the integrity of your optical media, choose OK and follow the onscreen instructions. A single test should take between three to five minutes and you will have the opportunity to test one or more discs. When this process is complete, choose Continue to exit this phase and return to the main installation menu.

Note

You should be aware that the verification process performed during this phase will not always guarantee a trouble-free installation as it will not monitor hardware or measure environmental conditions. This feature is not always used, but it can serve to increase the frequency of success by checking the file integrity of your installation media.

The CentOS installer will now prepare the onscreen environment and present the installation welcome screen. From this point onwards you can now use your keyboard and mouse, there is no time limit for completing any section, but remember to enable the number lock on your keyboard if you intend to use the keypad. When you are ready, choose the Next button to proceed.On the language selection screen, select the preferred system language. All changes to your language settings will take immediate effect, so when you are ready, choose the Next button to proceed.On the keyboard selection screen, select the appropriate keyboard for the system. When you are ready, choose the Next button to proceed.On the next screen you are required to choose the type of devices your installation intends to support. You have two primary choices, and if you intend to install CentOS on a SAN device, then choose specialized storage devices. However, in most cases (and for a typical computer) that will be using a local hard disk; so simply choose the default option of basic storage devices. When you are ready, choose the Next button to proceed.

Note

If you are using a new hard disk or a virtual disk, you may see what could be described as a warning/error message. The message may read:

The storage device below may contain data

Don't worry, this is to be expected and the message is simply asking you to initialize your hard disk because it is considered to be blank, unpartitioned, or a virtual drive. In most cases, especially if you have more than one hard drive, simply enabling the checkbox and choosing yes, discarding any data will complete the task of disk initialization and enable you to proceed to the next step.

On the network settings screen you will be required to complete the following two steps:
In the first step you will need to determine the hostname of your server. As you can see in the text field located at the top-left hand portion of the screen, this value will automatically default to localhost.localdomain. Setting the hostname is an important part of installing a server, so change this value to something more suitable, but don't worry, as this book will show you, this value can be changed after the installation process.The second step is to choose the button labeled Configure Network (located in the lower-left portion of the screen) and use the resulting Network Connections dialog box to record any changes to your Ethernet settings. To do this, simply highlight the relevant Ethernet device listed under the Wired tab and choose Edit. Check the box labeled connect automatically and then make the necessary changes to the IPv4/IPv6 values including the address, netmask, gateway, and DNS servers. You may even elect a DHCP connection at this stage if your network supports this feature. When finished, choose Apply and then close the Network Connections dialog box. Your computer will now try to initialize and activate the relevant Ethernet connection(s).When you have finished both these steps, choose Next to proceed.
On the next screen, you are required to confirm a time zone for your server. You can do by using the interactive map or by simply scrolling through the list of locations to select your nearest city. When finished, ensure the checkbox labeled System Clock Uses UTC is checked before choosing Next to proceed.On the next screen you will be required to create and confirm a root password for the root user. Typically, it is advised that you should avoid using simple phrases, dictionary-based words, or include any whitespaces. Passwords should consist of no less than six characters, so when you are ready, input your choice and choose Next to proceed.On the next screen, you will be asked to determine a hard disk layout for the server as a whole. This will determine the installation type and you can choose from Use All Space (use the entire hard drive and utilize the default partition scheme), Replace Existing Linux system (s) (remove all current Linux partitions and replace with the default partition scheme), Shrink Current System (shrink the current file system to make room for the default partition scheme), Use Free Space (use the remaining free space to create the default partition scheme), or Create Custom Layout. You are given the option to review the partition scheme and the ability to customize your partitions is a useful option. However, if you are new to Linux or are not yet comfortable with the concept of building a custom layout, then for the purpose of this recipe you should select Use All Space and click Next to proceed.You will now be asked to confirm your hard disk partitioning instruction. If you feel that you have made a mistake, now is the time to correct it by choosing Go Back. However, if you are confident that the correct choice has been made, then simply click the button labeled Write changes to disk in order to complete this phase of the installation process.CentOS will now format your hard disk(s) before proceeding to the next screen where you will be invited to make any relevant changes to the boot loader. Otherwise known as the GRand Unified Bootloader (GRUB) unless you feel confident enough to change the location of boot loader, it is always best to accept the defaults. However, should you wish to set a boot loader password to improve security, then this can be achieved by selecting the checkbox labeled Use a boot loader password followed by the Change password button in order to make the relevant changes.When you are ready, click Next to proceed.On the package group selection screen, you will notice that CentOS provides for a number of Package Selection Groups that simplifies the process of selecting individual packages. Use the descriptions provided to make your primary choice, but for a typical server (and for someone who wishes to take full advantage of the recipes contained within this book) it is often better to begin with a minimal install and add packages as and when you need them.

On the other hand, and should you feel inclined to do so, you can take this opportunity to explore the individual packages found on your installation media by choosing to customize the software selection. To do this, simply check the box labeled Customize Now before leaving this screen.

When you are ready, click Next to proceed.

CentOS will now resolve any dependencies and the installer will begin writing to the hard disk. This may take some time, but a progress bar will indicate the status of your installation. When finished, the congratulations screen will inform you that the entire process is complete and that the installation was successful. So when you are ready, click Reboot to finalize this recipe and to recover the installation media. Congratulations, you have now installed CentOS 6.

How it works…

In this recipe you have discovered how to install the CentOS 6 operating system, and having covered the typical approach to the graphical installation process you are now in a position to develop the server with additional configuration changes and packages that will suit the role you intend the server to fulfill.

So what have we learned from this experience?

We started by initializing the main installer and determining whether we would like to check the installation media for possible corruption and defects. Of course, validating the data on your disk is always a useful process and it can save time in the long run, but you should be aware that it will not necessarily guarantee a trouble-free installation. For this reason, most users who have already validated the checksum tend to skip this process.

The next steps then welcomed us to CentOS and invited us to confirm the appropriate language, keyboard, location, hostname, root password, network, and storage settings.

For example, any changes to the language setting were immediate, whereas the configuration of your network settings was simply a matter of ensuring the Ethernet device would connect automatically and modifying the appropriate IPv4/IPv6 settings. You were able to create a static or dynamic IP address, while the setting of a root password was simply a matter of choosing an appropriate series of alpha-numeric values that did not consist of known words, typical phrases, or contain any whitespace. Whatever password you decide on, it should consist of no less than six characters to avoid any warnings issued by the installer.

During the next stage, we then considered the need to partition the hard disks by selecting the default option known as Use All Space. By choosing this option, you were allowing the installer to determine the relative sizes of each partition and to build a logical volume that would assign GRUB to a default location. Of course, diving in to the depths of partition management was beyond the purpose of this recipe, but you did see that the various options that enable you to build your own custom layout should this be the preferred option.

You were then given the option to change the location of GRUB. This is not always deemed to be necessary, as moving GRUB can be an awkward process for even the most experienced users but ignoring this, you did discover an option that would enable you to password-protect the boot loader and provide additional system-wide protection.

Finally we came upon the package group selection screen where we discovered that CentOS not only enables us to choose a minimal install, but it also provides for a significant number of package selection groups that are designed for convenience.

The sole purpose of these groups is to simplify the process of selecting the correct packages for your installation. I think you would agree that most of the group titles are self-explanatory, but it is generally accepted that a minimal install is by far the most efficient method of installing any server because it is far easier to add and configure packages when we need them rather than simply installing everything at once. This rule of thumb not only reduces your initial workload, but it also ensures that your server remains safe and secure which is of a particular concern if it is located in the public domain.

So in conclusion, I think it would be appropriate to say that there is always more to discover about the installation process and that there are many different ways to install your server, but at this early stage you should now take the time to sit back and relax. Well done, you have now completed the recommend installation process and yes, you can now install CentOS.

See also

CentOS project home page: http://www.centos.orgCentOS project Wiki home page: http://wiki.centos.orgCentOS product specifications: http://wiki.centos.org/About/Product

Running a netinstall over HTTP

In this recipe we will learn how to initiate the process of running a netinstall over HTTP (using the URL method) in order to install CentOS 6.

The CentOS network installation is a process by which a small image file is used to boot the computer and enable the download of all the necessary files that will be required to complete the installation of the full operating system.

Using this approach implies the advantage of not being required to download the DVD-based image files and for computers that do not have access to DVD drive; this can be of enormous benefit. Moreover, where you will only download the packages you need, unless you are intending to install more than one server then the entire netinstall-based approach (starting from downloading the initial installation image to finalizing the installation of your computer) not only provides greater flexibility, but it will also save time and offers the benefit of the full installer.

Getting ready

Before we begin, it is assumed that you have followed a previous recipe in which you downloaded the netinstall image of Centos 6, confirmed the checksum values of the image file, and that you have already created the relevant installation disk.

To complete this recipe you will need an active Internet connection, and because this recipe will serve as a starting point to the graphical installation process, you should be confident that your server can meet the following minimum requirements:

An Intel-based or AMD-based CPU (Pentium, AMD, Via, AMD64/EM64T)At least 768 MB RAM (1GB or more recommended)At least 10 GB hard disk space

Note

You should be aware that these specifications act as guidance only and further details concerning the minimum system requirements can be found at http://wiki.centos.org/About/Product.

How to do it...

To begin this recipe, insert the netinstall disc, boot your computer from the optical drive, and wait for the welcome screen to appear:

On the welcome splash screen, use the Up and Down arrow keys to select and highlight install or upgrade and existing system. When you are ready, press the Return key to proceed.Having unpacked the necessary files, you will be presented with the disc found screen and asked if you would like to test the integrity of your installation disc. Remember, file integrity in this context refers to the quality of the data on the disc only, so if you are confident that your installation media is error-free and wish to continue with the installation, simply use the Left and Right arrow keys to choose Skip and press the Return key to proceed. Alternatively, if you would prefer to test the integrity of your optical media, choose OK and follow the onscreen instructions. A single test should take a few minutes depending on your hardware. When this process is complete, choose Continue to exit this phase and return to the main installation menu.

Note

You should be aware that the verification process performed during this phase will not always guarantee a trouble-free installation as it cannot monitor hardware or measure environmental conditions. This feature is not always used but it can serve to increase the frequency of success by checking the file integrity of your installation media.

On the Language Selection screen, use the Up and Down arrow keys to select the preferred language. When ready, press the Return key to proceed.On the Keyboard Selection screen, use the Up and Down arrow keys to select the preferred keyboard settings and press the Return key to proceed.At this point you will now be asked to confirm the installation method. As we will be installing over HTTP (also referred to as the URL method), you should choose URL and press the Return key to proceed.On the Configure TCP/IP screen, you will be asked to configure your network settings. By using the Up and Down arrow keys in conjunction with the Space bar, place a * in the preferred values. If your local area network supports dynamic IP assignment, then choose DHCP and when you are ready, highlight OK and press the Return key to proceed.

Note

If you have elected to use a static IP address you will be presented with the Manual TCP/IP Configuration screen. This implies that you will be expected to confirm your IP address, Netmask, Gateway, and Nameserver (or DNS) settings by typing in the respective values as required. When you are finished, highlight OK and press the Return key to proceed.

At this stage, your server will now attempt to configure the Ethernet devices before inviting you to complete the URL Setup screen. So depending on whether you have chosen a 32-bit or 64-bit installation, in the first dialog box use one of the following values:
For a 64-bit installation use http://mirror.centos.org/centos/6/os/x86_64For a 32-bit installation use http://mirror.centos.org/centos/6/os/i386Otherwise, you can obtain a list of local mirror sites from http://www.centos.org/mirrors

Tip

Remember, if you need to enable an HTTP proxy, do this now by entering the relevant details. If you are in doubt, know that you do not use a Proxy or you are unaware of such a feature on your network then leave this section blank.

Alternatively, you can also use a personal repository on your local network should you have access to such a facility.

When you are ready, by using the Tab key, highlight OK and press the Return key to proceed.

On success, the installer will begin to retrieve the appropriate install.img file. This may take several minutes to complete, but once resolved a progress bar will then indicate all the download activity. When this process has finished, the installer will prepare the onscreen environment and present you with the installation welcome screen.

Note

From this point onwards you will be able to install CentOS using the graphical installer in the usual way but with one difference. Having resolved the necessary package dependencies all required packages will be downloaded from the Internet.

How it works...

The purpose of this recipe was to introduce you to the concept of the CentOS network installation process in order to show you just how simple this approach can be. By completing this recipe you have not only saved time by limiting your initial download to those files required by the installation process, but you have been able to take advantage of the full graphical installation method without the need for a complete DVD suite.

So what have we learned from this experience?

We have learned how to boot from the netinstall image, initialize the main installer, test the optical media for errors, provide the relevant network settings for the host computer, and provide a URL in order to download the relevant files.

The URL in this case was web-based and dependent on the preferred architecture, but as an alternative you could have modified this instruction to use a local mirror site or even implement an installation from a local repository from your local network.

So in conclusion, it must be said that if you are intending to install more than one server at a time (with a full array of packages), then this may not be the best approach, but for a single server or multiple servers using a minimal install, then the netinstall image represents a far more flexible approach. Rather than waiting to download a complete set of installation files you may never need, the installer will download the required files directly from the chosen location thereby ensuring that you will not only reduce the overall time it takes to get your server up and running, but you will be able to take advantage of the full installation without the need for a DVD drive.

See also

CentOS project home page: http://www.centos.orgCentOS project Wiki home page: http://wiki.centos.orgCentOS product specifications: http://wiki.centos.org/About/Product

Installing CentOS in Text Mode and building a minimal installation

In this recipe we will learn how to install CentOS in Text Mode.

For new users, Text Mode may not be the first choice when deciding how to install your server but it does remain a popular and useful option for a variety of reasons.

Installing a system in Text Mode offers reduced