Archive for the ‘cPanel Tutorial’ category

Changing Dedicated IP to Exim Mail Engine Formats for /etc/mailhelo, mailips, etc.

January 17th, 2011

I have to change how mail is sent from one of our machines because it is on a network with a poor reputation. I have additional ips and can switch the sending ip to something else.

When I look at the options in EXIM CONFIGURATION I see:

** send HELO based on the domain name in /etc/mailhelo (*: HELONAME can be added to the file to change the default helo name) [?]
Send HELO based on the domain name in /etc/mailhelo (*: HELONAME can be added to the file to change the default helo name)

** Send outgoing mail from the ip that matches the domain name in /etc/mailips (*: IP can be added to the file to change the main outgoing interface) [?]
Send outgoing mail from the ip that matches the domain name in /etc/mailips (*: IP can be added to the file to change the main outgoing interface)

** Automaticlly send outgoing mail from the account’s IP address instead of the main IP address. Warning: If you turn this setting on you should make sure reverse DNS entries match the ones in /etc/mail_reverse_dns. [?]
Automaticlly send outgoing mail from the account’s IP address instead of the main IP address.

How do I change the info for these files, all of them are currently empty except for /etc/mail_reverse_dns which has the main server ip and machine name. Do I just edit it manually with VI or PICO and it will work or will it be blown away with the next “upcp”?

What is the format for these three files?

You may use any command-line text editor such as vi (or vim), nano (or pico), to edit the files. As long as the automatic option is not in use you can manually update and manage the mailhelo and mailips files without them being overwritten.

The easiest method to see a full version of the files with proper syntax is to temporarily enable the following “automatic” option:
WHM: Main >> Service Configuration >> Exim Configuration Editor >> Standard Options >> Domains and IPs
* Automatically send outgoing mail from the account’s IP address instead of the main IP address. Warning: If you turn this setting on you should make sure reverse DNS entries match the ones in /etc/mail_reverse_dns

the above option will create the files so you can simply view their contents to see how they are used.

Alternatively, you can manually create them based off the following examples, while being sure to use your own domains and IP addresses where applicable; however, please note that to retain customizations of the two files, mailhelo and mailips, it is necessary to enable the relevant options via the Exim Configuration Editor in WHM as seen below.

WHM: Main >> Service Configuration >> Exim Configuration Editor >> Standard Options >> Domains and IPs
* Send HELO based on the domain name in /etc/mailhelo (*: HELONAME can be added to the file to change the default helo name)
* Send outgoing mail from the ip that matches the domain name in /etc/mailips (*: IP can be added to the file to change the main outgoing interface)

Full Path: “/etc/mailhelo”

Code:

domain2.tld: domain2.tld

sub.domain2.tld: domain2.tld

addondomain.tld: domain2.tld

other.domain3.tld: other.domain3.tld

*: server1.domain1.tld

In mailhelo, the example entry that begins with an asterisk sets the default HELO for domains without their own specific entry; you could, if desired, just have the default set and nothing else.

The “#.#.#.#” entries in the following two examples are meant to represent IP addresses on your system; be sure to use only valid, public IP addresses that are accessible via the Internet.

Full Path: “/etc/mailips”

Code:

domain2.tld: #.#.#.2

sub.domain2.tld: #.#.#.2

addondomain.tld: #.#.#.2

other.domain3.tld: #.#.#.3

*: #.#.#.1

In mailips, the example entry that begins with an asterisk sets the default outbound (sending) IP address for domains without their own specific entry; you could, if desired, just have the default set and nothing else.

You should not have to manually edit or manage the mail_reverse_dns file; the only two that you would manually edit are mailhelo and mailips. For the sake of showing an example, though, here is what the mail_reverse_dns file might look like:

Full Path: “/etc/mail_reverse_dns”

Code:

#.#.#.1: server1.domain1.tld

#.#.#.2: domain2.tld

#.#.#.3: other.domain3.tld

To help understand why the above examples look the way they do, in terms of why a particular domain has a specific HELO value and or why a particular domain has a specific outbound IP, and to help show what you might expect to see from the aforementioned “automatic” option, the following could be assumed:
1.) “domain2.tld” is a primary domain
2.) “sub.domain2.tld” is a sub-domain of “domain2.tld”
3.) “addondomain.tld” is an add-on domain of “domain2.tld”
4.) “other.domain3.tld” is an also primary domain
5.) “server1.domain1.tld” is the server hostname

If you opt to manually create, update and manage the mailhelo and mailips files, you are free to customize them as needed provided they contain the correct syntax and use only valid domains and IP addresses.

Apache and Tomcat via Cpanel – Servlet Display Problems

March 29th, 2010

Problem

Apache Web Server was not passing servlet requests to Apache Tomcat. Instead it served 404 errors, even though the Apache Tomcat Connector (JK 1.2, mod_jk) was auto-configured by the WHM / Cpanel installation.

Other Possible Descriptions of the Problem

  • Jsp’s work in Tomcat, but servlets do not
  • Apache Http Server won’t pass servlet requests to Tomcat
  • Tomcat problems using the Cpanel plugin
  • Virtual host configuration problem with Cpanel Tomcat
  • Apache not recognizing servlets
  • Servlets can’t be accessed through Apache

In the latest Cpanel Release (11.15.0-RELEASE 17853), Tomcat support has been integrated. Prior to this (I’m not sure for how long), Tomcat was available via a beta plug-in. I experienced this problem with both the beta plug-in and the integrated support.

What’s Happening

Apache Http Server accepts all web requests and determines which are requests for static content, and which requests should be forwarded to Tomcat.

Apache correctly serves static content, and correctly passes all requests for .jsp pages to Tomcat. But when a servlet is requested, e.g. www.myserver.com/myapp/myservlet, Apache looks for the “/myapp/myservlet” directory, and finding none, spits out a 404 error.

How to Resolve the Problem

I tried several things that I thought should work but did not, though I don’t know if it was due to my specific configuration or because they were just the wrong things to do. What finally solved the problem was just adding an .htaccess file to the root of the web application with the following lines:

SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME ajp13

This forces Apache to forward all requests to resources within this context to Tomcat for processing, specifically to worker ajp13. Ajp13 is one of the default workers set up, and is defined (on my system) in /usr/local/jakarta/tomcat/conf/workers.properties.

Other things that I thought should work but didn’t (your mileage may vary):

1) In /etc/httpd/conf/jk.conf (if your httpd.conf file includes jk.conf),
add/edit the switch “+ForwardDirectories.” Normally, if Apache runs
across a directory it doesn’t recognize, it will spit out a 404. This
switch says to forward those requests to Tomcat, and let Tomcat spit
out a 404 if it can’t fulfill the request.

2) In /etc/httpd/conf/jk.conf (if your httpd.conf file includes jk.conf), specifically mount each context, and unmount static content. Mounting tells Apache to pass requests to Tomcat, and unmounting tells Apache to serve the content itself. Newer versions of Tomcat are faster than Apache at serving static content, but apparently, using Apache to serve static content is safer from a security perspective.

JkMount /mywebapp/* ajp13
JkUnMount /*.gif ajp13
JkUnMount /*.jpg ajp13

A separate issue that is outside the scope of this post is whether you should use Apache Web Server to front Tomcat requests, or whether you should just have Tomcat accept requests over port 80. If you’re using a recent Tomcat version (5.5+), Tomcat can serve both static and dynamic content faster than Apache.

Use Tomcat if: 1) you’re only dealing with a single server; 2) and you’re not using any other software that requires Apache (e.g. forums or wikis written in PHP).

Use Apache to front Tomcat requests if: 1) you want to load balance across multiple servers; 2) or you want different web applications or virtual hosts to be served by different processes.

Disclaimer

I know embarrassingly little about hardware, networking, or server setup. This solution might be a hack or it might be obvious to some more familiar with the components mentioned, but it couldn’t be resolved through a dedicated server help desk or through the Cpanel help desk, so I assume there are others out there that this could help. Everything in this post is based on my limited experience with the aforementioned software and my own research. If you know of a better, cleaner way to do this, or if you know how better to describe this problem or solution, please forward to me and I’ll amend this post.

Rationale Behind this Post

I recently (as in yesterday) resolved a difficult to diagnose problem involving Cpanel, Apache Web Server, Apache Tomcat, and the Apache Tomcat Connector (JK 1.2, mod_jk2). My googling skills tend to be above average, but I could find no reference to this specific problem anywhere, and the sole purpose of this post is to hopefully save someone else the aggravation. So please disregard the keyword-heavy text — it’s altruistic in nature, I assure you.

cPanel web hosting tutorials

September 17th, 2009

cPanel® and WHM™ (WebHost Manager) is the next generation web hosting control panel system. Both cPanel & WHM are extremely feature rich as well as include an easy to use web based GUI (Graphical User Interface

cPanel is designed for the end users of your system and allows them to control everything from adding / removing email accounts to administering MySQL databases.

cPanel is a linux based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilized a 3 tier structure that provides functionality for administrators, resellers, and end-user website owners to control the various aspects website and server administration through a standard web browser.
 In addition to the GUI interface cPanel also has command line and API based access that allows third party software vendors, web hosting organizations, and developers to automate standard system administration processes.

cPanel is designed to function either as a dedicated server or virtual private server and it supports centOS, Red Hat Linux, and FreeBSD.

Application based support includes Apache, PHP, MySQL, Postgres, Perl, Python and BIND. Email based support includes POP3, IMAP, SMTP services.

cPanel – enabling and configuring spam assassin

September 17th, 2009

Email spam is a very frustrating reality of the online world we live in. Many tools have been developed along the way to try and combat this probelm including both server and desktop solutions. This tutorial will guide you through enabling Spam Assassin on your hosting account using your cPanel.

Enabling And Configuring Spam Assassin

Spam Assassin is a very effective antipsam tool and it is offered with all of AUSWEB cPanel hosting plans.By default Spam Assassin is disabled in your cPanel but it is a relatively simple procedure to activate it. The key is configuring it to offer you extra protection whilst producing as few false positives as possible.

Enabling Spam Assassin

Once logged into your cPanel you will see Spam Assassin located under the Mail tab.

Clicking on the link will take you to the main configuration page where you will see a variety of options. To get started, simply select the “Enable Spam Assassin” button. This will turn Spam Assassin on using its default settings.

Filters

The default filter level is set to 5 which is good for most end users. A higher number will result in less spam getting tagged and reduces false positives. You can always change this number down the track if you find you get a high level of false positives.

e.g.
Low threshhold = 5 (default)
Medium threshold = 7.5 (slightly less spam caught but fewer false positives)
High threshold = 10 (much less spam caught but least likely to produce false positives)

You can also select to automatically delete spam as soon as it arrives. This can be helpful in keeping things easy to manage but is generally only recommended if you can deal with occassionally losing legitimate emails. Again, you need to be very careful with the settings you apply to reduce the chance of false positives.

Spam Box

When you first enable Spam Assassin it will simply tag emails as spam by putting ***SPAM*** in front of the subject(unless you have enabled “Auto-Delete Spam”). This setting allows you to then configure your email client to filter these message based on the tag. Enabling the Spam Box means that rather than emails just being tagged they are actualy moved to special folder on the server, therefore not actually getting to your desktop inbox. This folder is automatically created when the first spam message is caught.

The upside to enabling the Spam Box is that you avoid having to download unccessary junk, yet you can easily login to your webmail account to see if a message has ended up there by mistake. The downside to filtering with this method is that you then need to frequently login to cPanel to empty the Spam Box, otherwise it will use up your valuable disk space.

Configure Spam Assassin

This section provides you with a few advanced settings that can assist in either blocking or allowing mail based on a prtucluar address or an entire domain. For exmaple, if you were constantly losing emails from one company you could add their domain to the Whitelist, therefore telling Spamm Assassin that it is legitimate and to let it through. You can also do the exact opposite by blocking addresses using the Blacklist. Both the Blaicklist and Whitelist work in the same way and can accept wild cards * and ?; e.g. *@isp.com or *.domain.com.

To add a name to either list just put it in the appropriate box and hit save.

Upgrade scripts through Fantastico

September 17th, 2009

Fantastico helps you install numerous excellent additions to your website, and for many of the scripts it installs, upgrades are released on a regular basis. Not only do these updates add new features, they patch security holes and fix bugs, making them an essential process to carry out.

Luckily, Fantastico makes this possible with only a few clicks of the mouse. This tutorial will guide you through this process.

Firstly, login to cPanel by going to yourdomain.com/cpanel. Now scroll down until you see the Fantastico De Luxe link. Click on it to access the Fantastico control panel.

On the main page you will see a list of scripts which have upgrades available. Click on the Upgrade link next to the script you want to upgrade to proceed.

You will now be presented with the Upgrade page.

Read the notices carefully; if your script has been modified in a certain way, Fantastico might not be able to upgrade it. Make sure that you understand the notices and if you are sure that they don’t apply to you, click Upgrade. If all goes well, you will be presented with a page similar to this:

Keep in mind that the page might vary depending on the script you are upgrading. Now that the Upgrade is complete, check that your data has been transferred correctly by having a look at your website. Also, note down the instructions for restoring your old installation; if something goes wrong it is fairly easy to restore it.

How To Set A Default Webmail Application Using cPanel

September 17th, 2009

This tutorial will guide you through setting up a subdomain that will allow you to use your favourite webmail client everytime you access your webmail.

How to set a default webmail application using cPanel

With the addition of RoundCube, VERSION NEXT now provides access to three webmail applications which also includes Horde and SquirrelMail. When accessing your webmail you are normally presented with a page that allows you to choose the application you would like to use.

One method to always use the same application evry time is to “Enable AutoLoad”. Although the autoload feature is nice and easy to use, there is actually another way you can set the default and that is by setting up a subdomin and a redirect. To do this please perform the following setps:

1) Access your webmail applications tab by typing http://www.yourdomain.com/webmail. You will be presented with a pop up box requesting your username and password. Here you need to enter your full email address and the password you set up when creating your email account.

2) Once logged in you will be presented with a page giving you the option to choose the webmail application you would like to use. Select your application; for this example we are going to use RoundCube.

3) Once the webmail client of your choice has opened, copy the full url from the browser’s address bar and save it somwhere handy(e.g. into windows notepad). You will need this a little later when we create your new webmail subdomain.

4) Now that you have the url saved somewhere safe, logout of your webmail and then open up your cPanel and login. From the main cPanel page, select the “Subdomain” option under the “Domains” panel.

5) On the Subdomains page, enter “webmail” into the “Subdomain” form field(excluding the quotes) and then select “Create”. Don’t be concerned by the “Document Root” form field as this will auto populate.

6) Once the creation process has completed you should now be able to see your new subdomain under the “Modify a Subdomain” section. At this point it is not redirecting anywhere so this is our next task. Next to the newly created subdomain, select the “Manage Redirection” link.

8) In the “Subdomain Redirection” form field, enter the full url you copied down earlier(Using RoundCube as the example, this should look something like http://yourdomain.com:2095/3rdparty/roundcube/?_task=mail). Click save and your done.

9) Before closing down cPanel, you can test the redirect by opening up a new browser window and typing in your newly created subdomain http://webmail.yourdomain.com. When the login pop box appears(make sure you ahve allowed popups in your browser) enter in your email address and password. You should now be directed to your default webmail application. If it doesn’t work then you will need to go through all the steps again, this time carfully checking that you have correctly entered all details with no spelling mistakes.

PHP Freelancer