Category Archives: Linux Servers and Software

General Linux server and software information.

Turning off WordPress redirects index.php to index.html on Cpanel Apache

I spent a bit of time today trying to research why Apache on Cpanel insisted on redirecting from index.php when it was entered as an explicit URL to the default index.html page in the website home directory.

As it turned out, while I am searching for “cpanel apache redirects” I should have been asking “Why does WordPress redirect…” and that change of question led me to this WordPress forum thread that addressed the actual issue.

Now normally I would not repeat the information here, but just in case that link disappears, I do want to be able to get to it again, so here it is.

The issue actually is not Apache or Cpanel driven, but is an issue with WordPress and the way that it redirects all requests to the home page for the site. Hence despite me trying to access index.php, WordPress was redirecting to index.html, and that prevented me from seeing the new WP site.

Ultimately the purpose of this was to allow for WordPress to be installed alongside an existing page based site and deploy for final user acceptance before switching off the old site and moving to WordPress as the new site.

The trick is simply a manually installed plugin that can be removed after final commissioning to production.

1. Open your site with an FTP program or SSH depending on you preference

2. Navigate to yoursite_folder/wp-content/plugins/

3. Create a new folder for the plugin – call it disable-canonical-redirects – or dcr for short

4. Change to that folder

5. Create a new index.php file and include (copy and paste or re-type) this PHP code into that file:

[text]
<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/

remove_filter(‘template_redirect’, ‘redirect_canonical’);
?>
[/text]

5. Visit your WordPress Admin backend and activate this new plugin

6. All is now good to go and access index.html by default or index.php for WordPress explicitly.

Many thanks to Mark and others in that discussion thread.

 

SME Server 8.0 Outlook email external connection imaps

I had the need to setup Outlook to connect to an SME Server 8.0 recently and at first glance it seemed easy enough but it did not work as expected.

The primary issue appears to be that Outlook does not like to play with the SME Server SSL or Ports without being shown the way.

The end result is a step by step guide that I have published over at the WrenMaxwell Knowledgebase complete with screenshots of each step.

I suspect that this may well apply to other self-hosted servers beyond SME Server and kept the text generic for that purpose, but if you are trying to get your SME Server to work then the first thing to do is make sure that the imaps and smtps ports are open on the firewall and on the SME server.

The only other thing that needs doing is aligning the server name with the external hostname and the self-issued SSL certificate.

It was interesting that setting up a couple of portable devices, an iPhone, iPad, and Android all worked with the SME Server connection without any specific settings being required, the server was just accepted and worked from the get-go.  Microsoft Outlook, however, seems to raise barriers.

I did reference this Microsoft article KB286197 as a preliminary to this process and found it lacking for the options of secure SSL connections and certainly it has the basics but insufficient detail to guide an appropriate outcome for an SME Server connection.

The SME documentation over at contribs.org is also lacking a bit of input and I might try to help out there if I can make some time.

SME Server as a Nagios NRPE Client only

If you are wanting to install Nagios on an SME Server version 8 then you will probably start with the Wiki Contribs page for a Nagios Server install. http://wiki.contribs.org/Nagios

Which is going to lead you down a path of installing a complete Nagios Server assuming you overcome the issues with those instructions.

But if you have a Nagios Server elsewhere and you want to just add the SME Server as a client then a different set of instructions can be found in the forums.

http://forums.contribs.org/index.php/topic,48587.msg241615.html#msg241615

Which is really helpful but is missing a couple of key points for a complete set of instructions. So here is a re-write of that instruction set.

NRPE SME Server 8 Installation

1. Configure the dag repository

The following command will configure the dag repository on SME Server.

[text]

/sbin/e-smith/db yum_repositories set dag repository
Name ‘Dag – EL5’
BaseURL ‘<a href="http://apt.sw.be/redhat/el5/en/" target="_blank">http://apt.sw.be/redhat/el5/en/</a>$basearch/dag’
EnableGroups no
GPGCheck yes
GPGKey <a href="http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt" target="_blank">http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt</a>
Visible no
Exclude freetype,htop,iptraf,rsync,syslinux
status disabled

[/text]

2. After adding it to the database we have to update the changes to the configuration file:

[text]signal-event yum-modify[/text]

3. Then run this to enable the repo

[text]

/usr/bin/yum –enablerepo=dag install
nagios-plugins
nagios-plugins-setuid
perl-Config-Tiny
perl-Class-Accessor

[/text]

4. Copy nrpe rpm’s

Current download for the files are:

http://pkgs.repoforge.org/nagios/nagios-3.2.1-5.el5.rf.i386.rpm

http://pkgs.repoforge.org/nagios-nrpe/nagios-nrpe-2.5.2-1.el5.rf.i386.rpm

http://pkgs.repoforge.org/nagios-nrpe/nagios-plugins-nrpe-2.5.2-1.el5.rf.i386.rpm

5. Install the nrpe rpm’s

[text]

yum localinstall nagios-3.2.1-5.el5.rf.i386.rpm
yum localinstall nagios-nrpe-2.5.2-1.el5.rf.i386.rpm
yum localinstall nagios-plugins-nrpe-2.5.2-1.el5.rf.i386.rpm

[/text]

6. Modify the nrpe.cfg file to allow the external ip of your Nagios server  (swap vim for your favourite editor)

[text]

vim /etc/nagios/nrpe.cfg

[/text]

the allowed_hosts parameter is already in the file, remove the # from the start of the line and add your nagios server ip

[text]

allowed_hosts=127.0.0.1,nagios.server.ip.here

[/text]

Save the file and exit.

7. Add the service

[text]

cd /etc/rc7.d

cp -s /etc/init.d/nrpe S95nrpe

[/text]

8. Port forward 5666 to localhost (swap vim for your favourite editor)

a)

[text]

mkdir -p /etc/e-smith/templates-custom/etc/hosts.allow/

[/text]

(if you get an error it means the directory already exists.)

b)

[text]

vim /etc/e-smith/templates-custom/etc/hosts.allow/nrpe

[/text]

and add the following lines to the nrpe file, adding your nagios server ip

[text]

{
$OUT="nrpe: " . ($nrpe{HostsAllow} ? $nrpe{HostsAllow} : "127.0.0.1 nagios.server.ip.here" );
}

[/text]

Save the file and exit.

9. Configure the new template

[text]

expand-template /etc/hosts.allow

[/text]

10. Start NRPE

[text]

service nrpe restart

[/text]

And then off to your Nagios server to add the new SME Server as a client.

Raid 1 repair on SMEServer

I had the displeasure to find a failing drive within a server earlier today.

But with trusty SME Server and the Linux software raid process it was relatively painless, albeit that I had the wrong drive out at the first attempt.

The reference at How-to Forge was the one I used and it made it easy to follow. http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array