The Curious Website Designer

Troubleshooting Problems With Centos Web Panel

Posted by The Curious Website Designer | Posted on Mon 24 Apr 2017

Troubleshooting Problems With Centos Web Panel

The range and diversity of potential problems and errors with Centos (or any other) Web Panel is so great, that this article could never hope to come close to giving you all of the answers you may be looking for.

In most cases, when something goes wrong - it just goes wrong! The clues, though, can usually be found in the error logs. But where on earth are they ?

The purpose of this article is to not only help you find where they are, but also to provide you with a way of keeping them close at hand.

What's Gone Wrong ?

So something has gone wrong or not worked and the screen is rather unhelpfully telling you nothing. Where should you start looking ?

The first place to start looking is the error logs. But which one; there's so many ?

  • Apache log
  • PHP log
  • CWP log
  • Firewall Log
  • Email logs

And they are scattered all over the server (a slight exaggeration, but you do have to know where to start looking !)

 

Where To Find The Logs

I quickly got frustrated trying to find and then later on remember where the various logs were located, so I thought it would be sensible to have a navigation menu item just for the various error logs.

Fortunately, there is a facility within CWP to create your own custom modules, and once you've mastered the process, it's ridiculously easy to set up a nav menu to add additional modules as and when you need them. Here's the 'Logs' menu that I currently use:

Logs Menu

 

Creating The Modules

Taking the Apache Log as my starter, here is the script:

  1. <?php
  2. /*        Apache Error Log
  3.       This script outputs the content of the apache error log.        
  4. */
  5. $log = shell_exec("cat /usr/local/apache/logs/error_log");
  6. echo "<h3>Apache Error Log</h3>";
  7. echo "/usr/local/apache/logs/error_log";
  8. echo "<pre>".$log."</pre>";
  9. ?>

 

Line 5 puts the contents of the Apache error log into the variable $log.

The 'cat' command sends the whole of the file to the variable $log. If you would rather just have the last few lines change this to the 'tail' command:

tail -100 /usr/local/apache/logs/error_log

will output the last 100 lines of the file. Change the number to dictate how many lines you would like to see from the log

 

Line 6 outputs the page heading

Line 7 outputs the location of the log file (so I don't have to scratch around trying to find out where it is if I need that information).

Line 8 outputs the log.

 

That's all that's required for this module - 4 lines of executable code !

So I saved the file as 'apache_log.php'.

I used this file as the template for all of the other log files that I thought I might need and saved them in a folder named 'modules'. These are the files that get called when clicking the relevant links on the nav menu.

I then created a new folder called 'include' and created a file called '3rdparty.php'. This is the file that contains the html code for the nav links.

 

Navigation Links

The (simplified) html structure of the navigation links is as follows:

  1. <li><a href="#">MAIN BUTTON 1</a>
  2.   <ul class="sub">
  3.     <li><a href="index.php?module=module_1">MODULE 1</a></li>
  4.     <li><a href="index.php?module=module_2">MODULE 2</a></li>
  5.  </ul>
  6. </li>
  7.  
  8. <li><a href="#">MAIN BUTTON 2</a>
  9.   <ul class="sub">
  10.     <li><a href="index.php?module=module_3">MODULE 3</a></li>
  11.     <li><a href="index.php?module=module_4">MODULE 4</a></li>
  12.  </ul>
  13. </li>

 

On line 3, you will see that the href refers to 'index.php?module=module_1' - the actual module file in this instance would be called 'module_1.php'.

The html code above does not contain any formatting data (we'll add this later on), but this is what it looks like when it is added to the nav menu system as it stands:

 

The way that CWP allows you to add additional navigation buttons is through the file '3rdparty.php'. Here's how it fits into the html structure:

  1. <li><a href="#">Developer Menu</a>
  2.   <ul class="sub">
  3.     <li><a href="index.php?module=example">Example Module</a></li>
  4.     <?php include('3rdparty.php'); ?>
  5.  </ul>
  6. </li>

 

So all you really need to do is add the <li> </li> tags for the individual log modules (following the format of line 3) and these will appear on the 'Developer Menu' button.

But I don't want to do that - I want a separate button group with a list of all of the logs I'm interested in. So here's what I did:

  1.  </ul>
  2. </li>
  3.  
  4. <li><a href="#">Logs</a>
  5.   <ul class="sub">
  6.     <li><a href="index.php?module=apache_log">Apache Log</a></li>
  7.     <li><a href="index.php?module=php_log">PHP Log</a></li>
  8.     <li><a href="index.php?module=firewall_log">Firewall Log</a></li>

 

Line 1 closes off the subordinate unordered list from the 'Developer Menu' group (ie the individual modules).

Line 2 completes the list item that is the 'Developer Menu' button.

Line 4 starts a new list item for the 'Logs' button.

Line 5 starts the subordinate unordered list which contains the log modules

Lines 6 - 8 are the individual links to the various log modules.

 

Here is the final html code formatted so that it remains consistent with the rest of the navigation menu:

  1.     </ul>
  2. </li>
  3. <li><a href="#" class="hasUl"><span class="icon16 icomoon-icon-quill"></span>Logs<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
  4.  
  5.     <ul class="sub">
  6.                 
  7.         <li><a href="index.php?module=apache_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>Apache Log</a></li>
  8.         <li><a href="index.php?module=php_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>PHP Log</a></li>
  9.         <li><a href="index.php?module=firewall_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>Firewall Log</a></li>
  10.         <li><a href="index.php?module=cwp_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>CWP Log</a></li>
  11.         <li><a href="index.php?module=ftp_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>FTP Log</a></li>
  12.         <li><a href="index.php?module=ssh_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>SSH Log</a></li>
  13.         <li><a href="index.php?module=postfix_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>Postfix / Mail Log</a></li>
  14.         <li><a href="index.php?module=dovecot_log"><span class="icon16 icomoon-icon-arrow-right-3"></span>Dovecot Mail Log</a></li>

 

This is saved in the file '3rdparty.php' and uploaded to the folder:

/usr/local/cwpsrv/htdocs/resources/admin/include/

 

IMPORTANT NOTE: If you already have a file on your server with the same name, you must combine the two files otherwise you will lose access to any custom modules that were available previously

 

The module files should be uploaded to the folder:

/usr/local/cwpsrv/htdocs/resources/admin/modules/

 

For your information, the above logs are in the following locations:

Apache Log /usr/local/apache/logs/error_log
PHP Log /usr/local/apache/logs/suphp_log
Firewall Log /var/log/lfd.log
CWP Log /usr/local/cwpsrv/logs/error_log
FTP Log /var/log/messages
SSH Log /var/log/secure
Postfix / Mail Log /var/log/maillog
Dovecot Mail Log /var/log/dovecot.log

 

Although this article didn't provide answers to any of the actual problems you may be encountering while wrestling with an unmanaged server, hopefully it will have given you an indication as to where to start looking to find the source of the problem.

In addition, I hope it has given you an insight into how you can start to customise your Control Panel so that the modules that are important to you are more easily accessible.

For those of you who can't be bothered to create your own custom Log menu, the files required to add the above log modules to your Web Panel can be found here. Please be sure to read the included file Readme.txt.

 

 

 

Related Articles

How To Use PuTTY to Access Your Server Using SSH

How To Use PuTTY to Access Your Server Using SSH

Posted by: The Curious Website Designer
on Mon 20 Mar 2017

If you have never used SSH to access your VPS, you will probably never have come across PuTTY. This article will put that situation right.

How To Install Centos Web Panel (CWP) On A Centos 7 Server

How To Install Centos Web Panel (CWP) On A Centos 7 Server

Posted by: The Curious Website Designer
on Thu 30 Mar 2017

This is the third in a series of 4 articles aimed at server administrators who have very limited experience. In this article, I will explain how to install CWP on server with Centos 7. The final article will focus on initial configuration of the Web Panel

PHP Startup: Unable to load dynamic library

PHP Startup: Unable to load dynamic library

Posted by: The Curious Website Designer
on Fri 9 Feb 2018

My Apache log was filling up with this error which clearly needed fixing, but was also making it very difficult to find the cause of other problems because they were lost in a mass of PHP Startup entries. Heres how I eventually fixed it.