کد:
http://articles.techrepublic.com.com/5100-10878_11-6180622.html
Takeaway: Doing things in Linux can present a large learning curve to a Windows-savvy network administrator. Jack Wallen shows the easy way to set up an Apache Web server under Linux.

This article is also available as a TechRepublic download.

Linux is increasingly becoming a popular alternative to Microsoft Windows for network administrators wanting to provide services for their organization. Learning a new OS like Linux can present some challenges to a long time Windows administrator however. This is the beginning of a series of articles aimed at the IT administrator new to Linux wanting to set up various servers. This first article will describe the steps to setting up an Apache server as a Web server for your organization.
Environment

For this series, I will be setting up the services on an OpenSuSE 10.2 based machine with a GNOME Desktop Environment. This environment will remain constant through the series for simplicity. So part of the article will be dedicated to understanding where things are in GNOME 2.16.
The installation of OpenSuSE 10.2 was a fresh install on an older 1.5 GHz processor with roughly 256 MB of RAM. Even on this slower machine, the system was snappy. Since the system will be used primarily as a server environment, the somewhat sluggish GUI is tolerable.
The installation spanned the entire five disks (downloaded from the OpenSuSE Web site). The installation of the full range of tools and packages took some time to complete, but the end result made for a fairly easy setup. I won't go through the installation of the OS in this article.
First steps

Much to the chagrin of many Linux users, I am going to log into my SuSE 10.2 machine as root. I don't do this often, but it saves me from having to enter the root password every time I want to perform an administration task. This is okay for setting up a service like httpd, but once you are done setting up said service, log out. Until you do log out, let's work as root.
The first thing you'll want to do is to select Computer, as seen in Figure A.
Figure A

The new GNOME 2.16 menu is quite a change from the usual cascading menu. From the menu, select Control Center, as seen in Figure B.
Figure B

The Control Center is grouped in both Groups and Common Tasks. Select Administrator Settings from the Common Tasks section to open the YaST Admin Tool. You'll see this in Figure C.
Figure C

It should be obvious that Network Services is your next destination. Select Network Services to reveal a listing of the various Network Services that can be configured from within YaST, as in Figure D.
Figure D

A nice collection of GUI tools to help you configure your Linux server. Now you can start administering Apache. Press the HTTP Server button to open up the Apache Configuration tool, as shown in Figure E.
Figure E

You are now ready to begin your quest to set up the Apache server. From the main configuration window, you'll notice a number of options. One of those options is the Firewall Details. By default, the http daemon is enabled, and the port (80) are open in the firewall. From this screen, you can't do much with editing the firewall; you can only enable or disable the http port. If you press the Firewall Details button, a new window appears (as shown in Figure F) which allows you to select the interface assigned to the firewall.
Figure F

Only one interface is available on this server. From the main window, there are four tabs. The default tab is the Listen Ports and Addresses tab. From this tab, you can handle the action above, add additional ports for Apache to listen to, and view access and error logs.
One of the first issues I ran into was YaST not reading the access and/or error logs for Apache. By opening up a console and issuing the command less /var/log/apache2/access_log,I was able to read the log file. In order to successfully be able to read the Apache log files, go back to the YaST Control Center (shown in Figure C) and select Miscellaneous | View System Log. The View System Log window will open (as shown in Figure G), defaulting to /var/log/messages. If you click on the drop-down, you will not see the Apache logs listed. What you will need to do is type out /var/log/apache2/access_log, and the log will appear as it is in Figure G.
Figure G

After you have typed out the log you want to view, it will appear in the drop-down the next time you need it. Server modules

As we all know, Apache would be fairly useless without modules. Today's Web site denizens have grown used to the increasingly robust content available. With that in mind, let's take a look at the Server Modules tab within YaST's Apache2 configuration window.
Figure H shows the main window for the Server Module configuration. There are two configurations within this window: toggle a modules status (enable/disable), or add a module. Obviously, everyone's HTTP needs are going to vary, so you'll have to go through the module listing to decide what you need. If the module isn't listed, press the Add Module button for a new window, allowing you to select from a good number of modules, ranging from auth_alias to version. When you add a new module, it will be appended to the bottom of the module listing, and its status will be enabled.
Figure H

You can change the listing of the modules by selecting one of the headings: Name, Status, or Description. Once you add a module or change the status of a module, you will need to reload Apache2 so the server will be made aware of the new module. To reload the service, simply press the Finish button at the bottom right of the YaST window. Once the service is reloaded, the YaST window will disappear.
Apache hosts

The next tab is the Apache Main Host tab. From this window, the servers Apache information is listed (and can be edited). Like all of the YaST GUI tools, this tool edits the httpd.conf file directly. But from this window, that will be made quite obvious. As you can see in Figure I, the listing in the GUI window already should look familiar to those of you who have taken a crack at editing an Apache conf file. The good news for those of you who haven't -- this makes it very easy.
Figure I

As the instructions say, if you opt to use Server Resolution, the default server will not be served. Most of the defaults should work for you. Of course, there are special needs where you might have to edit one of the various entries. One entry you'll definitely have to edit is the Server Administrator e-mail entry. To do this, highlight the entry and press the Edit button, enter the administrators e-mail, and press OK.
There is one really cool feature here called Server Resolution. What this enables you to do is set up virtual hosting based on either IP Address or HTTP headers. Let's set up a virtual site using IP Address routing.
Press the Add button and a new window with a drop-down list will appear. Select Server Resolution and press OK. Now move on to the New Host tab. From in this tab, you will press the Add button, and a new window will appear (Figure J).
Figure J

I've already entered the text for the new virtual host. The information necessary is pretty obvious, but you will want to determine how the virtual host will be determined. I opted to determine requests by IP address. Select the appropriate check box and press the Change VirtualHost ID button. The VirtualHost ID window will allow you to choose one of the IP addresses configured on your machine. If you have only one network-attached device, you will be given two addresses: the address of the configured device, and the loopback address (127.0.0.1). Obviously, the loopback address is only going to be good for that machine. That's not such a bad thing if you are using the virtual host for testing purposes. The one problem you might face is if your firewall will not allow traffic on the loopback device. So we'll configure ours on the 192.168.1.25 address to avoid the issue.
The next screen contains site-specific details such as CGI Options, SSL Support, Directory Options, and Enable Public HTML. Chose the options your virtual site will need and press Next. You are finally ready to finish the setup. Press finish to apply the changes and restart Apache. Voila! Virtual hosting made GUI.
The last thing you want to do is make sure you actually have an index.html (or some referencing file) in the directory you are hosting your virtual site. Without the index.html file, your browser will not find the virtual site.
Final thoughts

Until recently, setting up an Apache server was left for those who knew how to edit .conf files. Fortunately, the gang at Novell (and SuSE of course) helped the newer Linux fans set up that Web site with as much ease as pointing and clicking. With a user-friendly GUI in front of the action, things just keep getting easier




موضوعات مشابه: