Configure Sendmail to use your ISP’s mail server
Posted by admin in Mail Server on May 13th, 2009
On a local SMTP server I have for testing I need to use my isp’s mail server for sending emails. My provider, bellsouth, blocks port 25 so all mail has to be routed through their server. Apparently, they use IP based ACL’s so authentication is not required.
After moving my previously working SMTP mail server from an work location to my residence, I spend several days trying to figure out why my mail server no longer worked. Even though test through sendmail in verbose mode told me the email was going through, the qmail command told me that the connection timed out. Apparently, Bellsouth blocks port 25 and you must route email through their server. I was able to finally get it work by defining a SmartHost directive in the sendmail.mc, recompiling the sendmail file and restarting the sendmail service.
All it took was opening
/etc/mail/sendmail.mc
adding/changing:
define(`SMART_HOST',`[mail.bellsouth.net]‘)
and then reseeting the sendmail config via:
make -C /etc/mail
service sendmail restart
Now any mail sent from my machine (system status, php’s mail function, etc) will be routed through my isp’s mail server.
Blank Pages due to PHP Error Reporting being turned off
If you are programming in php and you are getting blank pages you may have PHP’s error reporting turned off. This can be checked by creating a page called “phpinfo.php” and on it, putting:
<?php phpinfo(); ?>
The phpinfo function will output your PHP configuration when viewed in a web browser. Search for the term“error_reporting”. If you are getting blank pages is it mor than likely set to “off.”
This problem can be fixed by turning on error reporting at run-time. To do this, add the following PHP code to the top of your page:
<?php
ini_set ('display_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
?>
This prints out all warnings except for notices. I tend to put this into an include file that gets included on every page. Let’s say you put this into a master include file that resides inside the “includes” folder, which is in your public document root folder (often called “web” or “html” or “httpdocs”). On your regular pages, you might do something like this:
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/master.php'); ?>
Using the $_SERVER[’DOCUMENT_ROOT’] global variable prevents you from having to guess relative paths all the time. Using this also allows you to move scripts freely from host to host, as you never have to hard-code the doc root into your applications.
Turning On PHP Error Reporting
A good way to help you troubleshoot your php code is to use the helpful messages php returns when an error occurs. To do this, enter the following code.
1 2 | ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); |
Getting Going with WordPress
- Copy gz to directory of website
- extract to create wordpress folder
- use the 5 minute start guide (see below)
- create new database in mysql SITE_WordPress
- run install using the website address. http://www.sitedomain.com/wordpress/wp-admin/install.php
- copy themes and plugins from other base system : eflowone
- change settings:permalink
- activate plugins: exec_php,
Here’s the quick version of the instructions, for those that are already comfortable with performing such installations. More detailed instructions follow.
- Download and unzip the WordPress package, if you haven’t already.
- Create a database for WordPress on your web server, as well as a MySQL user who has all privileges for accessing and modifying it.
- Rename the wp-config-sample.php file to wp-config.php.
- Open wp-config.php in your favorite text editor and fill in your database details as explained in Editing wp-config.php to generate and use your secret key password.
- Place the WordPress files in the desired location on your web server:
- If you want to integrate WordPress into the root of your domain (e.g. http://example.com/), move or upload all contents of the unzipped WordPress directory (but excluding the directory itself) into the root directory of your web server.
- If you want to have your WordPress installation in its own subdirectory on your web site (e.g. http://example.com/blog/), rename the directory wordpress to the name you’d like the subdirectory to have and move or upload it to your web server. For example if you want the WordPress installation in a subdirectory called “blog”, you should rename the directory called “wordpress” to “blog” and upload it to the root directory of your web server.Hint: If your FTP transfer is too slow read how to avoid FTPing at : Step 1: Download and Extract.
- Run the WordPress installation script by accessing wp-admin/install.php in your favorite web browser.
- If you installed WordPress in the root directory, you should visit: http://example.com/wp-admin/install.php
- If you installed WordPress in its own subdirectory called blog, for example, you should visit: http://example.com/blog/wp-admin/install.php
That’s it! WordPress should now be installed.
Creating a new Website with Wordpress on an Apache Webserver
One of the things I like best ablout wordpress is that is allows you to quickly and easily get a professional looking website up and running in a flash. Creating multiple websites with Wordpress is a snap.
To create a new site or test site, do the following:
- Create a New CName record with your Registar. Make sure there is a CName record for your domain with your registar (ie, GoDaddy, etc). The CName used for a website is typically www but it can be pretty much anything else as well. For a test site, you may wish to have a CName record of test. You would then get to your test site by using http://test.yourdomain.com. This CName record would typically point to your main IP address. For GoDaddy the default to reference this AREcord is the @ symbol. The A record typically contains the IP address of the computer that hosts yoru site.
- Edit your httpd.conf file to point to a new location. Now that you have a CName record point to your IP address, you need to make sure that your web server know what to do when someone hits test.mydomain.com. By default, it will probably take you to the same default web site. On a CentOS installation, this would the index page that is located in the /var/www/html directory. However, we want a new site, so we need to tell the system to go to a new location for different webpages. You do this by editting the httpd.conf file and adding a Virtual Host Directive.
<VirtualHost *:80>
DocumentRoot /var/www/test.mydomain
ServerName test.mydomain.com
</VirtualHost>.
If you are hosting multiple site, you may wish to separate these VirtualHost directives into files in a sites folder in the httpd folder and then include them in the httpd.conf file using the Include sites/test.mydomain.site line.
After making these changes, you must restart your httpd service. Now test.mydomain.com is point to the right location. Now we add the wordpress site.
- Unzip the wordpress gz file in the new test.mydomain folder located in /var/www/ folder.
- If you have themes and plugins that you typically use, you can copy and paste them from the /wordpress/wp-contents folders to you new folder.
- Create a new mysql database for this instance of wordpress. Typically for multiple site, something like XXX_wordpress works well where XXX is the name of the site.
- Edit the wordpress/wp-config-sample.php file and enter in the database information and save file as wp-config.php
- Run http://test.mydomain.com/wordpress/wp-admin/install.php, this will use the config file and create the tables and install wordpress. It will also give you and admin password. Be sure to record the password.
- Login into the system using http://test.mydomain.com/wordpress/wp-admin/. There you can get going with the final settings. If you copied themes and plugins, you may wish to activate them.
- Change the settings so that http://test.mydomain.com will open the blog instead of having to using the /wordpress extension. This is done by going to the admin|settings|general page and changing the Blog address to http://test.mydomain.com.
- Copy the index.php and .htaccess file fro mthe wordpress directory to the root directory of your site (Blog address)
- Edit the index.php file so that the wp-blog-header.php points to the directory above. ./wordpress/wp-blog-header.php.
- Check out Giving WordPress Its Own Directory for more valuable info.
- Now you are good to go with a brand new website. Enjoy…
Installing VMWare Tools on a Linux Guest Machine
VMWare Tools greatly enhance the user experience by improve the graphics and other device driver such and keyboard and mouse inputs. the most noticable effect is faster screen updates and the ability to dynamically size your VMWare console. VMWare tools also allow you to copy and paste up to 64K of plain text between the guest and the host operating system.
To install VMWare tools,
- select the guest virtual machine from the base console and click on the Install VMWare Tools link on the far right. This will insert a virtual DVD into the guest system.
- Run the RPM to install the VMWare tools.
- After installation is complete, run the vmware-config-tools.pl configuration file from the command line.
- Enter the vmware-user command to start the VMWare User process.
- Enter vmware-toolbox & to start the VMware tools control panel.
Expanding VMWare Virtual Hard Disk Size using SCSI Hard Disk
VMWare is a beautiful piece of software that allows you to run multiple virtual machines on one physical machine. As explained in a previous post, one thing that you can do is create a based virtual machine with one of your favorite operating systems, get all the updates for the operating system, install all your favorite free software, and then just copy and paste or clone the virtual machine to create new virtual machines already setup with all your favorites.
So you are thinking to yourself, that sounds great!! I will create a virtual machine with the base operating system and a small virtual hard drive so I dont take alot of room up on my serve and after I copy it, I will increase the size of the harddrive… Right. Sounds like a good plan and that what I thought. However, not all virtual hard disks are the same. It turns out, the default IDE virtual hard disk does not allow increasing its size on the fly. Therefore, if you are looking to start out with a small virtual hard disk footprint and expand when you need it, it is best to go with the SCSI virtual hard disk. this allows you to increase it storage space on the fly.
Hopefully, you are reading this before you already created your base system with a small IDE hard disk. Unfortunately, I did not and I did not find a way to easily convert the IDE to a SCSI. So I had to start from scratch with a VM machine that was built on a VM SCSI hard drive. Now I am good to go…
Copying and Pasting a VMWare VMDK file
The beauty of using VMWare is that it is very easy to magically “create” a new computer by simply copying the base vmware files of any already existing vmware instance. Are the wheels in your head starting to turn like they did in mine? Probably so. You are thinking to yourself, “Self, if I create a base windows and a base linux machine, get all the updates and then just clone them, I will save myself a TON of time”. You are absolutely correct. Not only that, but if you ever have a motherboard failure, getting a system up and running from your vmware backups is a simply as installing the vmware server base on a system and then reinstalling your backed up VMDK files of all your virtual machines. Pretty cool huh.
The main file that need is the vmdk file. On a CentOS base server setup, these files are stored in folders in the /var/lib/vmware/Virtual Machines directory. To create a new virtual machine from a base virtual machine, do the following…
- Create a new directory for the new machine in the Virtual Machines folder
- Copy vmdk and the vmx files from the base machine folder to the new folder.
- Add Virtual machine to inventory
- Rename the server and edit the notes.
- Depending on how you had your base system setup, you may need to edit static MAC addresses, Host Names, etc.
VMWare running on Linux CentOS 5.2
I decided to take the plunge and move all my servers to VMWare box. My buddy, Dr. Phil Heil got me hooked the VMWare stuff. If you haven’t heard of VMWare, it is the best thing since sliced bread. VMWare allows you to run multiple virture machines (hence, the term VM) on a single box. Essentially, you run a base vmware configuration which runs the vmware software, then you can create as many new virtual machines as you would like.
Running virtual machine is great for computer programs since you can quickly set up a particular computer configuration and test your code on it. Since VMWare supports snapshots and copying of vmdk files, you can quickly get back to your based configuration or create another instance very easily. In my case, I wanted an easy way to experiment with different server setups and a way of isolating web servers, email servers and data SQL servers. Separating servers is a best practice when hosting e-commerce sites.
Phil, our IT guru has been running the companies servers on them for many years now on a windows based system. I wanted to run mine on a linux box since linux is fast and the VMWare server software is free for linux. After doing some research, I found the following tutorials which proved to be exceptional.
VMWare Server in Production by Brian Downey and
How to Install VMWare Server on a CentOS 5.0 Desktop by Falko Timme
Follow these two guys tuitorials and you are as good as gold. After that you can set up as many servers on your box as you would like. Windows on Linux, Linux on Windows, you name it, you can do it.