Sunday, August 28, 2011

Running many sites in WAMP environment

What I Wanted
  • unique urls for many local sites
  • easy links to each url 
I develop websites and end up swapping back and forth between lots of sites.  When i tried to do it with the built-in WAMP alias settings, it threw off some of my code that dealt with the urls.  When I tried to fix that, it created problems when I moved my local work to the remote linux servers.  However, by specifying a url in  Apache, I can side step these problems.

Setting up a WAMP environment with local urls for multiple sites isn't all that hard.  I gathered up pretty much all my info from three sites (one, two, three).  Here's the steps for doing that:

1) Download & install WAMP2
It's easy: www.wampserver.com/en/

2) Edit your hosts file
It's located at C:\Windows\System32\drivers\etc\hosts. After this line:
127.0.0.1  localhost
add this: 
127.0.0.1  my.url.com  
Your url can be absolutely anything; a single word, a few letters or a full domain.

3) Edit your httpd.conf file 
The easiest way to do it is just to click on the tray icon, click the Apache folder and select the httpd.conf icon.  Alternately, it will be located inside your wamp install: something similar to "C:\wamp\bin\apache\Apache2.2.17\conf".

After this line (which is probably the last line of your httpd.conf file)
Include "c:/wamp/alias/*" 
add this block: 
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1> 
ServerName localhost
DocumentRoot "C:/wamp/www/"
</VirtualHost>
<Directory "C:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
 
 

For all future domains, you only need to add the VirtualHost and Directory blocks.  Note: it is important to use forward slashes ( / ) instead of backslashes ( \ ).  

4) Visit my.url.com 
It should be up and running now.

5) Modify WAMP index page (totally optional)
I have a tendancy to forge the urls of sites after a few weeks/months, so I wanted the index page to just keep a running tally for me.  Since we didn't change the localhost settings, if you type in http://localhost, you will still get the WAMP index page.  Kinda handy.  Adding two code blocks will display all your local urls on this page.

Open the wamp index.php file located at C:\www\wamp\index.php and add this block of code anywhere near the top (for instance, after the '
isset($aliasContents)' test on line 291).    
 
// get virtual hosts from hosts.txt file$vhosts = '';
$winfile = 'C:\Windows\System32\drivers\etc\hosts';
if(is_file($winfile)){

   $file_handle = fopen($winfile, "r");
   while (!feof($file_handle)) {
        $line = fgets($file_handle);
       if(!(preg_match('/^#/',$line))){
           preg_match('/127.0.0.1\s+([\w._-]*)/',$line,$urls);
           if(count($urls)) {
               $vhosts .= "<li><a href='http://$urls[1]'>$urls[1]</a></li>";
           }
       }
   }    fclose($file_handle);
}

 And  towards the bottom after this block (around 472):


<ul class="utility">
<li>Version ${wampserverVersion}</li>
<li><a href="?lang={$langues[$langue]['autreLangueLien']}">{$langues[$langue]['autreLangue']}</a></li>
</ul>


add this block:

<h2>Local Virtual Hosts</h2>
<ul class="aliases">
${vhosts}
</ul>


This change will give you a nice little list of your local hosts so that you don't have to remember what three letter abbreviation you used way back when.  

Hope that helps. 

Sunday, February 6, 2011

Setting up SVN on MediaTemple DV host

What I Wanted
  • SVN repo
My Case
  • Linux server
  • MediaTemple DV acct
  • Tortiose SVN client  
Article Details
  • I will add more detail when I see some comments on this article.
A client has an account with MediaTemple and I want some kind of version control.  I'm most familiar with using SVN, so that's what I went for.  I haven't been too impressed with the knowledge base for their Dedicated Virtual accounts yet and this project was no exception.  There were several promising articles that just lead me down dead-end paths for hours.  This is what ended up working for me:

1. Install MediaTemple Developer Tools (link)
This will install svn on the host, as well as several other things you'll probably use eventually.

2. Create the Repository:
Follow these instructions, Setting up Subversion in 4 minutes. These links were also useful for me, a novice linux user
  • Problem: "Could not use external editor to fetch log message". 
  • Solution 
  • Problem: How do I reload .bash_profile again?
  • Solution 
    Restart svnserve (if necessary, not sure..):
    1. Get svnserve process id (link)
    2. kill it: kill -HUP  
    3. then restart it: /usr/bin/svnserve -d -r /var/www/svn/repos 
     Checkout repository into empty folder:
    • Using Tortiose, right click on folder and select "SVN Checkout"
    • In dialog that pops up, for url use: svn://ipaddress/repo_name
    • In the password dialog that pops up use whatever you set in the file /var/www/svn/repos/repo_name/conf/passwd

    Thursday, December 23, 2010

    Catching Emails w/ Gmail's Multiple Inboxes

    The Problem
    I've got 2-4 different sources I need to keep a very close eye on.  They all come in through email so it's just a matter of organizing them well.  Here's my criteria:
    1. If there's an important email I don't want to miss it.
    2. I don't want to have to check multiple accounts to stay on top of things.
    3. I don't want to have email from different sources mixed in with my personal email.
    The Solution 
    A combination of email forwarding and a gmail tool called 'multiple inboxes.'  You can see below that items from Stardust and Business Travel Connect show up in their own little blocks, and not in my inbox.


    However, once I've read messages in those inboxes (or marked them as read) they slide out of the way and into little messages that tell me everything is cool.



    How-To

    Step 1: If all the emails are being sent to the same address, go to the next step.  Otherwise set up your other email accounts (outlook, yahoo, etc) to forward to your gmail account.  This is probably preferable to redirecting email so that you always have the originals somewhere else.

    Step 2: Configure your gmail filters to automatically A) apply a label and B) archive them.

    Step 3: Add google lab's multiple inbox to your account.

    Step 4: Configure the multiple inboxes under gmail's settings tab.   The only important option is your 'search query.'  Type in "is:[your-label-name] is:unread".



    Now when you go back to your inbox all messages that are both unread and have the labels you selected will show up in their new inboxes.  Once you've read them they will disappear from the inbox.  Or if you have a copy in another email account you can just delete them.  Good luck!

    ~ Micah

    Thursday, December 9, 2010

    Avoiding MySQL 4.1+ Old Authentication Error

    What I Wanted
    • connect to mysql
    I have a functioning site and working database running remotely on a LAMP system.  I just want to get it going locally using a WAMP system.

    PROBLEM:
    When I try to run the site on localhost I get
    Warning: mysql_connect(): OK packet 6 bytes shorter than expected in C:\wamp\www\conn\connection.php on line 2 
    Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\conn\connection.php on line 2 
    Could not Connectmysqlnd cannot connect to MySQL 4.1+ using old authentication  

    SOLUTION:
    Lots of people ran into this same problem, but very few posts were any help.  I followed this guy's hints.  My wamp installation was using PHP 3.0 but my server where the code was working fine used PHP 5.2.6.  I'd like to know why this is a problem, but not badly enough to spend my time on it.  Do this:
    1. Figure out what the functioning version of PHP is Create a phpinfo page, put it where you can see it, check the version and then delete it:
      <?php phpinfo(); ?>

    2. Download that version of WAMP
      Go here to do it.  Just pick the correct version & click to download.

    3. Install itShutdown WAMP if you have it running and then double click - it's self installing.

    4. Restart WAMP and select your version of PHPSelecting the php version is as simple as clicking on the tray icon, going to the PHP directory, going to the 'version' directory and picking your version.  When you click on it WAMP will restart using that executable.
       
    5. Check it in the browser
      God I hoped that worked... 

    Friday, October 8, 2010

    SEF URLs with Joomla 1.5.15

    What I Wanted
    • easy legible urls
    What I Used
    • Joomla 1.5.15
    • ISP using Apache 
    • Putty (to ssh into my host) 
    Step 1: SSH to Host (only necessary if your server runs Apache)
    You will need to understand how to log into your server and minimal familiarity with linux. I used putty (www.putty.com).  So login, then..
    1. Navigate to your joomla installation (eg cd path-to/yourdomain.com/)
    2. Backup your htaccess.txt file (mv htaccess.txt htaccess.txt.bak)
    3. Copy and rename that file (cp htaccess.txt.bak .htaccess) 

    Step 2: Configure Joomla
    Login as your administrator in the Joomla admin panel
    1. Go to Site -> Global Configuration
    2. Set both Search Engine Friendly URLs  and Use Apache mod_rewrite to 'yes' and hit apply.
    3. Reload an inside page on your site, that might have done it. 
    Step 3: If that didn't do it..
    There's one more good trick.  Follow instructions at http://docs.joomla.org/SEF#Fixing_Broken_Site_When_SEF_is_Enabled.  This will also require you to ssh in to your host and alter one of the Joomla files.  If you're nervous about that back up the file first.

    That worked for me.

    Sunday, March 14, 2010

    Obligatory Post #1

    I'm well aware that folks that start a blog generally write their first entry as soon as the textfield pops up, regardless of whether they have anything of consequence to say.  Who am I to break tradition?

    Luckily the process of creating a mindlessly (not to mention tastelessly) simple blog fits the exact topic that I want to blog about.  That is, straightforward instructions on various tasks, adequately documented and highly skimmable.

    What I Wanted
    • Simple blog
    • ability to start immediately
    • flexibility to make modifications later

    Task the First » I Just Want a Blog

    1. Go to www.blogger.com
    2. Create login & follow prompts & wizards 
    Update » Custom templates for new blogger posts  
    I want to have a little box on the right side of each post for summary info so people can quickly tell if my solution is going to apply to their situation.  Unfortunately it's kind of awkward/tiresome to copy & paste the format from old posts every time (or will be I suspect).  Jennine Jacob has a simple solution on her blog.