Run SENDMAIL as it’s own different user

You may need to change Sendmail to run as another user instead of root. In order to do this, run the commands below. We are using sendmail for the user, and sendmail for group. Make sure to stop the sendmail service by using the service sendmail stop command. You may also need to kill any running processes by using the killall sendmail command. groupadd -g 24 sendmail useradd -u 24 -g 24 -M -d /var/spool/mqueue \-s /dev/null sendmail chown -R sendmail:sendmail /var/spool/mqueue chmod 700 /var/spool/mqueue chgrp -R sendmail /etc/mail chmod -R...

read more

Supporting legacy code, using global variables and register_globals with PHP 5.4.x

Recently we ran into some issues with some of our old sites that are relying on the register_globals  for variable access after upgrading to PHP 5.4 which wisely no longer supports this kind of setup.  Using globals in this fashion  is a horrible practice, but sometimes you gotta maintain some legacy code. To use global variables you can add a line of code to htaccess that will run a “globalizer” file before loading the main page on every page load and extract the required variables. globalizer.php file <!--?php...

read more

CentOS list recent installed updates, YUM, RPM

rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -n

read more

Apache mod_status, which site uses which process and resources

If you need detailed information about Apache processes and which site is using them. Edit your httpd_conf file, and change the following directives: <Location /secret-name-server-status> SetHandler server-status Order deny,allow Deny from none Allow from all </Location> You can set Allow from [specific IP address or range] for greater security Also change un-comment the # by removing the # character: ExtendedStatus On Then, go to Listen On directives, and add an unused port: Listen 4567 Save changes, restart apache service...

read more

Linux CentOS multiple default gateway for Virtual NIC interface

If your server needs to have multiple IP addresses on the same physical NIC, you need to create multiple Virtual Interfaces. For example, the default eth0 configuration will have an IP address from one network IP block, but you need to add another IP address, from a different IP block, with a different gateway. Here are the steps to add multiple IP addresses with multiple default gateways on the same physical NIC: Create a separate file in /etc/sysconfig/network-scripts called eth0:1 or eth0:2, etc.  Increment for each new IP address. File...

read more

Linux CentOS – copy .htaccess file into every subdirectory

If you need to copy a file into every sub-directory within a directory, navigate there, and run this command: find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess The maxdepth 1 switch allows you to go only 1 subdirectory deep, you can change it to 2, or 3 or leave it out altogether to copy into every subdirectory, regardless of depth. You can copy any file, not just .htaccess this way. find -type d -print0 | xargs -0 -n1 cp .htaccess This can be especially useful for WordPress media files and upload directories organized by...

read more