Using Mac/iWeb with Dreamhost
If you have registered or host a domain with DreamHost and would like to host it with your .Mac/iWeb 08 account, you can do so using the following steps:
The first step is to log into your .Mac/iWeb account page and then click the “Use personal domain” option - enter your domain name into the given field.
Next, log into your DreamHost web panel and navigate to the Manage Domains section. Clicking the “delete” button that appears next to your domain under the ‘Web Hosting’ column, will remove the Dreamhost hosting service from your domain.
After you’ve removed the web hosting service, click the “DNS” link that appears under your domain (you may need to leave and come page to the page before the link appears).
Under the DNS options, enter in www in the Name: field. Change the Type to CNAME and enter in web.me.com into the Value: field.
Click the “Add Record Now!” button to finish. Your done. Everything should be in working order after the DNS propagates.
Detecting IP Abuse at DreamHost
I just came across a handy tool for DreamHost users called ip-abuse-lookup.sh. This shell script analyzes error and access logs for a domain, looking for the IP addresses that have connected to your site the most often.
It checks for IP addresses that cause a Concurrent Connection Limit Exceeded error, which is a strong indication they are an automated bot of some kind. The script also scans for Internal Recursion Errors which can have very negatively effect your speed and server resources often caused by poorly configured .htaccess files.
After the script finishes scanning your logs, it will present you with the .htaccess code you can add to your site’s root .htaccess file to block the IP addresses the script found to be abusive.
For more info: DreamHost wiki page for ip-abuse-lookup.sh - with detailed instructions and full source code.
DreamHost offers shell access, but it needs to be specifically enabled for each user. You can either create a new user with shell access enabled, or modify and existing user to have shell. Here’s how:
Enabling Shell Access for an Existing User:
- Navigate to “USERS > MANAGE USERS” section of the web panel.
- Click the “edit” link next to the user you want to enable shell access for.
- Check the “Enable ssh/telnet?” box for that user, leaving the “Type” as is — unless you need it to be something other than bash.
- Click “Save Changes”.
Creating a New User with Shell Access:
- Navigate to “USERS > MANAGE USERS” section of the web panel.
- Click “Add New User”.
- Check the “Shell account” option, leaving the “Type” as is — unless you need it to be something other than bash.
- Choose a username for the person. This will be there login.
- Enter the full name of the user you’re creating the account for.
- You can let the web panel generate a password for this user or choose one yourself.
- Click the “Add User” button.
Ta da! Yes, it’s that easy.
Remember that it can take about 20 minutes for these changes to take effect.
Decompress ZIP Archives via SSH
Uploading an entire site or script in a ZIP archive then decompressing via SSH is useful, time-saving, and increases your geek webmaster points by +5. Here’s how to do it:
First you need the right tools and setup: Start by making sure you have Shell access enabled for your domain. You are also going to need a SSH client — for Windows users we recommend PuTTY, it’s free. (For Mac or Unix check out this info on how to access SSH.)
Now take the ZIP file, and FTP it to the directory you want the files decompressed to. After it has finished uploading, run PuTTY. Enter the domain and use your FTP login and password to get in.
You will now see the [server]$ prompt, with [server] being the name of your server eg [sprite]$.
Now type the following:
[server]$ ls
- This will display a list of your directories.
Now type:
[server]$ cd subdomain.domain.com
- cd being the command to Change Directory. And subdomain.domain.com being the name of the directory you uploaded your ZIP file to.
Next enter:
[server]$ ls
You should see the name of the ZIP file you uploaded. Now enter:
[server]$ unzip yourfilename.zip
Depending on how many files are in the zip, it might take a while to finish. But, when it does you will have all your files decompressed, exactly where you wanted them. Fancy, eh?
Although you can still use FastCGI, DreamHost now recommends using Passenger to deploy and host Ruby on Rails applications on DreamHost servers.
Enabling Passenger:
To enable Passenger, edit any of your fully hosted domains or add a new domain from the Manage Domains area of the web panel. Check the “Ruby on Rails Passenger (mod_rails)?” option, and save.
Once Passenger has been enabled for your domain, set the web directory to the “public” directory of the RoR app.
Notes: Only enable this option if you are running a Ruby on Rails app as the main application for a specific domain or sub-domain.
In other words: you want to access your RoR application via myapp.mydomainatDH.com or mydomainatDH.com, not as: mydomainatDH.com/path-to-myapp.
For more info see: the wiki entry on Passenger
Making a custom error page with DreamHost is easy. DreamHost servers have built-in special file names that, if present in your domain’s root directory, will load automatically when a visitor gets a particular error message on your website.
Here are the special file names:
failed_auth.html - for Error 401 - Failed Authorization
forbidden.html - for Error 403 - Forbidden
missing.html - for Error 404 - File Not Found
internal_error.html - for Error 500 - Internal Server Error
For instance, if you wanted to make a custom 404 error page, create a file called missing.html and place it in your site’s root directory. Edit missing.html to look and include anything you wish.
Why would you want to create custom error pages?
Instead of a visitor getting a generic 404 File Not Found Error, you could make a custom 404 page that shows your sitemap and/or offers a search form. Now you are re-directing that lost visitor back to your content.
Notes: When creating links on your custom error pages…make your links absolute rather than relative.
In other words, use something like: a href=”http://mydomainatDH.com/mypage.php” rather than ../mypage.php
Advanced users may wish to create custom error pages the old fashion way, via .htaccess — but we will cover that in a future tutorial.
You can also turn off this feature by editing your .htaccess file to include the following lines of code:
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default
For more info see: the DreamHost Wiki
PhpBB Optimization on Dreamhost
PhpBB is one of the most popular free message board applications, and Dreamhost offers it as a “one-click” install from your web panel. Like other database dependent web scripts, phpBB can drain server resources — especially on popular sites.
Here are some tips to help optimize your phpBB forum on Dreamhost (though, the tips will likely work equally as well with other hosts):
Optimization Tips for PhpBB:
- Remove any mods that you don’t use.
- Disable the search function for guests. Only allow it only for registered users.
- Optimize your database via PhpMyAdmin.
- Busy forums with lots of members could benifet from the advanced optimization tips located here.
Troubleshooting:
Spam can be huge problem with phpBB installs. Some mods such as the RAC mod can add an extra layer of protection to fight spam registrations.
Also, for security purposes: remember to keep your version of phpBB up to date. Dreamhost makes it easy (one-click upgrades), so you don’t have any excuses.
For more info check out the DreamHost Wiki’s page on phpBB.
Stop Hotlinking via .htaccess
While Dreamhost offers it’s customers an easy way to prevent hotlinking via the web panel, that method is only suitable for basic websites and beginner webmasters that don’t already rely on .htaccess for URL rewriting and other applications often used in CMS / blogging software.
Also the web panel method to prevent hotlinking doesn’t provide users with very many options for controlling hotlinking.
The following examples are methods of preventing hotlinking using .htaccess files.
Blocking all domains from hotlinking
The following code will return a 403 Forbidden error instead of the requested file, unless the referrer is yourdomainatDH.com, which should be changed to your domain:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomainatDH\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpeg|jpg|gif|png)$ - [F]
Blocking Specific Domains from Hotlinking:
The following code will return a 403 Forbidden error instead of the requested image, but only when the image is requested by hotlinkingsite.net or hotlinkingsite.com:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hotlinkingsite\.net/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?hotlinkingsite\.com/ [NC]
RewriteRule \.(jpeg|jpg|gif|png)$ - [F]
Blocking All Domains with Exceptions
The following code will produce a 403 Forbidden error instead of the requested image, unless requested from yoursiteatDH.com or myspace.com Note: one of the allowed sites should be your domain.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomainatDH\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myspace\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpeg|gif|png)$ - [F]
Note: In the above examples only images with lower-case file extensions are being protected. To protect other resources, such as videos, add additional extensions to the Rewrite Rule parentheses block.
For more info and other options check out Preventing hotlinking on the Dreamhost wiki. If you aren’t familiar with editing .htaccess files you can read more about them here.
Hotlinking occurs when a website directly accesses, rather than links to, a file (like an image, or video) on a remote site. In other words if you have an images on your website and other webmasters choose to display those images on their own sites (rather than link to them) it could end up costing you extra bandwidth and server resources.
There are advantages and disadvantages to allowing other sites to hotlink your content. But this guide assumes that you have decided to not allow hotlinking from your website.
Note: If you have a custom .htaccess file, or if you are using CMS, blogging or other web software that utilizes .htaccess files this method is not for you, you will need to manually edit your .htaccess files to prevent hotlinking.
To prevent image hotlinking from the DreamHost web panel, navigate to the Goodies section > htaccess/webdav, then click on the domain you wish to edit.
Add the directory (the directory from your website you want to protect) such as /images/. Check the link protection button and add any extra allowed domains, if necessary, and submit the form.
Remember this is the simple method, for simple websites.
Many web scripts, like blogs and CMSs use and display the time. The problem is that without modifications, the time displayed will be that of the Dreamhost server you are on which is US West Coast time.
If you would rather have your scripts run and display your local time you can modify your .htaccess file to do so.
The first step is figuring out your timezone in the PHP manual. For instance if you are in Michigan, the correct timezone code would be: America/Detroit
Now, open your .htaccess file and add this line to it:
SetEnv TZ America/Detroit
(replacing America/Detroit with your own timezone).
Ta Da! That was easy — now the scripts on your web server will run in your local time.
About DreamNut
DreamNut is an unofficial DreamHost blog with hints, tips and video tutorials.
Use DreamHost promo code MAXSAVINGS at Dreamhost to get up to $50 off DreamHost web hosting.








