Disable SELINUX in Red Hat ES 5 (CentOS 5)
To check and see if SELINUX (secure linux) is installed and running on your Red Hat ES 5 (CentOS 5, etc) server, use a text editor to open /etc/selinux/config:
vi /etc/selinux/config
Inside you should see a line that says
SELINUX=*some value*
Where *some value* is either enforcing, permissive or disabled. To shut SELINUX off, set the variable to disabled. To receive a set of errors to see what services would be affected if SELINUX was running, set it to perimissive. If you are sure all your services, daemons and everything else is set up with correct SELINUX permissions, you can set it to enforcing.
If you're getting an error after compiling and installing an Oracle OCI8 module for PHP you might want to set SELINUX to permissive or disabled until you are able to resolve the permission problem.
If you have to change the setting you should reboot the server to make sure the change takes effect system wide.
Sync Server Folders Using rsync in Red Hat Enterprise 5
WARNING!!!
The instructions I'm giving below will open the receiving server to access from literally any source available on it's network to write any files to the particular folders you allow access to. THESE INSTRUCTIONS SHOULD ONLY BE USED ON SERVERS THAT ARE COMMUNICATING ON A SECURE LOCAL AREA NETWORK BEHIND A STRONG FIREWALL, NOT DIRECTLY OVER THE INTERNET! AGAIN, THESE INSTRUCTIONS SHOULD NOT BE USED ON A SERVER THAT IS CONNECTED DIRECTLY TO THE INTERNET! If you want to use these instruction to sync web servers, by all means do, it's what I use them for, just make sure your firewall only allows external (Internet) communication over ports 80 and 443 (if you need https) and specifically not TCP 873, since that is the port used by
rsync. If you're running production-grade servers you should be using a strong NAT firewall anyway. If you aren't, I am available at a very decent rate to help secure your setup![]()
If you're like me and you work for a rather large website, at some point you're probably going to have to come up with a nifty way of syncronizing two or more servers in some sort of pool, whether it be for load balancing or some other high availability technique, or simply to keep an active archive on a backup server. The great part about using rsync is that even if you have a huge amount of data in the folder you want to syncronize, rsync is smart and knows only to sync that information which is new, so it can run often and quickly, and literally be able to keep a server syncronized to within about a minute using a cron script. This is not a perfect solution for all situations, but it works well in the situation I use it in, which is archiving flat content from a live, online server to an offline backup machine.
Required Packages:
- rsync
If you need help installing a package, please read how to install packages using YUM.
Required Hardware:
- at least two servers
Log in to each of the servers as root and install rsync. We have to set up one machine to run rsync in daemon mode (as a service) so it can listen for requests from the other machine. Once rsync is installed on both servers, decide which you want the server daemon running on, switch into the /etc/ directory and create a file called rsyncd.conf:
cd /etc/
vi rsyncd.conf
Inside the file enter the following information. The settings below are for a standard installation of Red Hat ES 5 (CentOS 5, etc) running Apache 2 for syncing the default web root directory (/var/www/html/). You can change the path to suit your own needs.
[sync_web]
uid = apache
gid = apache
comment = Sync path for web servers
path = /var/www/
read only = false
Then add an entry at the end of the /etc/bashrc file to initialize rsync in daemon mode when the machine boots:
cd /etc/
vi bashrc
And add this line at the end of the file:
rsync --daemon
To initialize the syncronization, from the non-daemon machine run the command:
rsync -a /var/www/html *rsync_server*::sync_web
where *rsync_server* is the IP or hostname of the machine you just set rsync up on as a daemon. I suggest creating a shell script called by /etc/crontab every few minutes to run that command, that way the servers will stay syncronized by themselves to within minutes.
Set The Runlevel of a Service (Daemon) from the Command Line in Red Hat ES 5
To set the runlevel of a daemon (service) on the command line in Red Hat ES 5 (or CentOS 5, etc) you can use a simple command called chkconfig
To set a daemon to start on runlevels 2-5, which would be a "normal" start, you would use a command like this:
chkconfig --level 2345 *daemonname* on
And replace *daemonname* with the name of the daemon you want to have start, like httpd (Apache) or sendmail or any other daemon.