|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP LINKS YOU MUST CLICK ON Features
How to Migrate from Microsoft IIS Web Server to Apache on Linux
Plan and pick the right tools
By: Jon Walker
Jun. 25, 2005 12:45 PM
Digg This!
In Part 1 (Why Are You Waiting?, September 2004 issue), I discussed the business and technical considerations in migrating Microsoft IIS Web servers to Apache on Linux as well as the overwhelming cost, security, and stability benefits of making the move. Based on the tremendous feedback I've gotten, it appears many LinuxWorld readers agree with me (evidently I'm preaching to the choir).
Plan, Plan, Plan Choose Your Programming Language As many of you already know PHP is open source software and free of licensing fees. It's also considered by many to be a superior choice among Web programming languages due to its speed, excellent scalability, world-class memory management, integration with the MySQL database, and cross-platform development portability. If you decide to migrate from ASP to PHP, an open source program called asp2php will help. It seeks to convert ASP sites over to PHP automatically. While not perfect, many of the tedious changes in the conversion are made easier. If you're migrating to a new language, make a list of all the components you're using (especially third-party components) and map those to their PHP (or other language) counterparts. Most likely you'll find that a number of components that you had to purchase for your ASP solution are freely available with PHP including e-mail, image manipulation, and PDF generation. In addition, there are entire frameworks for such things as shopping cart applications. My company uses an excellent open source tool called OS Commerce for our e-commerce needs. Making this list has a second purpose - you can use it to help determine installation options for Apache later. Keep in mind that Apache can take advantage of several languages besides PHP including Perl, Python, and Java (via JSP). New languages and development paradigms are introduced often in the open source world. A good example is Ruby on Rails (www.rubyonrails.org). Choose Your Hardware Manually Performing the Migration Step #1: Install and Configure the Target Linux System Step #2: Install and Configure Apache When installing Apache 2, you must decide which method to use for multiprocessing (MPM). This detail is important since there are a few modules that only run with one of the process models in Apache 2. Your choices are "prefork" and "worker." Simply put, "prefork" uses the Apache 1.3 process model where every server runs in its own process. "Worker" is intended to be a more efficient thread-based model incompatible with some Apache modules (some versions of mod perl being a good example). For stability and the greatest module support, I suggest using the "prefork" process model. Step #3: Install and Configure Support Languages and Tools Installing Apache Modules Some other popular modules you may want to install are:
Installing Java Installing Additional Modules Step #4: Copy Web Documents Moving files from one server to another can be quite easy using Samba, an open source implementation of Microsoft's file-sharing protocol. Make sure file sharing is enabled on your Windows server, and then share the folders you need to migrate (your document root, for example). On the new server, we'll temporarily grant write access to the document root so we can use graphical tools to do the copying. Launch a terminal program (such as Konsole) and type: sudo chmod 777 /srv/www/htdocs You'll need to enter the root password for the server after the first line. Use the graphical tools built into your Linux distribution to copy the files. For example, in KDE you can use Konqueror to browse to the Windows server and copy the files over to the Apache document root location (/srv/www/htdocs or subfolders of /srv/www/hosts/). Once you've browsed to the Windows server, highlight the IIS folders that you've shared and wish to move, and drag them over to /srv/www/htdocs/ (you can type this path into a second open Konqueror window). At the pop-up menu that appears, choose "Copy here." Note: Depending on the number of files being copied, this can take a while. When you've completed this step, you should reset the file permissions (via sudo chmod 755 /srv/www/htdocs) to keep others from changing these files. Step #5: Configure File System and Web Server Security For instance, if a user is created for Web access, by default that user will also have permissions to log on locally, connect over Windows networking, and possibly even connect directly to an SQL Server database. These permissions must be disabled for that user. Apache, on the other hand, by default stores its own user names, passwords, and permissions. A user created for Apache will only be able to connect via Apache. Keep in mind that it's also possible to make Windows create new users without many permissions, and it's also possible to configure Apache to handle all users from a central repository of users. Another major difference in file permissions comes in how a logged-in user can access a file. When a user logs on to IIS, IIS uses the user's access rights to access any file. So if Joe user needs access to upload a directory, then Joe must be given write permissions to that directory. You'll also need to allow write access for the directory in the IIS console - before any user can upload. Apache, on the other hand, will always run as the user it is configured as (normally nobody, though sometimes /www/ or /apache/). To give Joe access to upload to that same directory, you must set write permission for nobody on that directory. Doing so, however, gives other users complete write access to the Apache directory. Avoiding this situation is a bit complicated. Let's see first what the configuration should be and then subdivide the configuration into components. The example below can be used in any virtual host, directory, or file directive: AuthType Basic
Require group uploaders will require either the user joe or any other user in the group uploaders. The word /valid-user/ is a keyword that means any user as all.
If you again look at the configuration, you can see an interesting tidbit. To set permissions in IIS, you set the general-level access through IIS itself, and user-level access on the files/directories in question. In Apache, you set the general-level access on the file or directory, and the user-level access through Apache's configuration file. Step #6: Configure Virtual Hosts, Virtual Directories, and Other Settings To manually edit httpd.conf, launch a Linux editor as root and open /etc/apache2/httpd.conf. For example in KDE you would launch Konsole and type: sudo kwrite /etc/apache2/httpd.conf. Note that some distributions have a modified version of this file that divides the file into multiple sub-files. This promotes ease in upgrading from one version of a particular Linux distribution to another. For example, if you follow the commands above, SLES 9's highly modified httpd.conf file will be displayed. The main SLES 9 configuration file includes detailed comments explaining where each setting is. On SLES 9 you'll see that to add a new virtual host, you simply need to add a configuration file for it in the vhosts.d directory. To do this, make a copy of the example template with a command like: sudo cp /etc/apache2/vhosts.d/vhost.template Once you've made a copy, open it with your favorite editor (as root). Near the top you'll see <VirtualHost *:80>, which means that this host will listen for any incoming connection on port 80. A few lines down is the most important directive ServerName. It tells Apache which VirtualHost to use when a connection is made. Change this to the first of the virtual hosts you want to migrate (so it says something like ServerName www.mysite.com). Locate the DocumentRoot directive. It indicates which directory to serve this virtual host from. Change this to wherever you copied the files (somewhere in //srv/www/vhosts//, for example, /DocumentRoot /srv/www/vhosts/www.mysite.com/. For practice, you can add an additional directive DirectoryIndex - one that isn't already in the template. Each directive can only be put in a limited number of locations in the configuration file. In this case, DirectoryIndex can be located inside VirtualHost or in any directory entry. To change which document gets loaded by Apache when this virtual host is loaded, simply add a new line under the DocumentRoot directive saying: DirectoryIndex default.htm or whatever the default document was on your IIS machine. If you used multiple default documents in different directories, you can add them in succession, such as: DirectoryIndex defaut.htm default.asp index.php. Replace the rest of the instances of dummy-host.example.com throughout the template with the real paths of your migrated host. Finally, you should test the configuration by directing the Linux machine to load from the new server instead of the IIS machine. You can do this by editing the hosts file (sudo /etc/hosts) and adding a line at the end of the hosts file that says 127.0.0.1 www.mysite.com. Once this is done, any time you visit www.myserver.com, you'll connect to your local machine instead. Before connecting, you'll also need to restart Apache by running sudo /usr/sbin/apache2ctl restart (this command may differ slightly depending on your Linux distribution). As with older versions of IIS, Apache has to be restarted for any changes to take effect because the configuration file must be parsed, a task too time consuming to done for each request; IIS changes settings directly in memory. Launch a Web browser and visit www.mysite.com (or whatever your migrated virtual host is). You should now see your default document (though perhaps not parsed correctly if it's ASP, PHP, or the like) from your virtual host. This completes a very basic Apache setup. There's still a lot left to configure via Apache's configuration files. Depending on your needs, you may want to set up virtual directories or files, set timeouts, tweak connection settings, or change the error pages people get when an error is encountered. You'll probably want to set up PHP, mod_perl, JSP, or Sun Java System Active Server Pages 4.0. For information on configuring every setting that ships with Apache, go to the Apache Documentation Project at http://httpd.apache.org/docs-project/. Information about how to set up different languages or runtime environments should be available at the place you got those systems. Tools to Ease IIS to Apache Migration In summary, migrating from Microsoft IIS to Apache on Linux isn't without its concerns. As with many changes, educating yourself, planning the migration, and choosing the right tools are key to a successful migration. Ultimately, the benefits of a move are the strongest motivators: reduced cost, stability, and security.
LATEST LINUX STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||