Feb
24
2007

Configuring Apache using YaST, openSUSE 10.2

I configure Apache2 on openSUSE with YaST rather than editing the configuration files directly. If this is your first time installing Apache on openSUSE, I highly recommend it. YaST is a big time-saver for two aspects of Apache configuration: the initial installation and adding, enabling, and disabling server modules. A default server configuration supporting Perl and PHP can be up and running in less than an hour using YaST.

YaST isn’t good at all facets of Apache configuration so some editing of conf files may eventually be needed. If manual editing is required, why not use it exclusively? Because once you go manual, you can’t switch back to YaST when major changes are needed. I like the fact that if I install a new web application that needs several additional Apache modules, I can use YaST to enable them in a couple of minutes, often without having to learn anything about them.

I also like the fact that using YaST to configure Apache will give me a configuration closely matched to thousands of other openSUSE Apache servers. This makes it likely that I will get a functional, robust httpd set up at the start. Then I can incrementally add modules and customizations as needed, testing as I go.

Following is a YaST-based recipe to install a straightforward httpd configuration with Perl, PHP, and mod_userdir enabled. Subversion, WebDAV, and virtual host support are also added (using some conf file editing). Finally, the added bookkeeping steps that allow YaST and hand-edited conf files to co-exist are presented.

Part I: Content-Independent Configuration

Part 1 installs a functional (but empty) httpd server with all modules and parameters properly configured. Connections to the site-specific content are discussed in Part 2.

  1. OpenSUSE scatters Apache conf files among /etc/apache2 and its conf.d, sysconfig.d and vhosts.d sub-directories. Keep a copy of the original conf files to determine what YaST has done and add source code control repositories to manage manually edited files:
    • cd /etc/apache2
    • mkdir ORIG; cp -p *.conf ORIG
    • mkdir RCS
    • Repeat for the three “.d” subdirectories.
  2. Start YaST/ Network Services/ HTTP Server:
    • Turn on php, perl, python and/or ruby in a special configuration page that only appears once (one can still turn these on/off later, but it’s easier to do here).
    • Accept defaults in the Server Wizard (5 pages), except choose Start When Booting on page 5.
    • Click Advanced Configuration.
    • In the Server Modules tab, enable dav, dav_fs, info, rewrite and status.
    • Needed to Add Module for dav_svn but the YaST screen would not accept input, so I hit Finish (will add in Step 3).
    • The server starts. http://localhost just says “It works!” instead of the normal Apache welcome page. Didn’t like this so I copied index.html from an old SUSE 10.0 installation.
    • Read the comments in all of the /etc/apache2/conf.d/*.conf files, some of which are controlled by IfDefine blocks. For my installation, I learned I needed to add the SVN_DOC and SVN_VIEWCVS flags (next step).
  3. Start YaST/ System/ sysconfig Editor:
    • Select Network, WWW, Apache2.
    • Highlight APACHE_MODULES. Add dav_svn into the Modules line. Note: Don’t hand-edit dav_svn into /etc/apache2/sysconfig.d/loadmodule.conf, as YaST will just remove it next time it runs.
    • Highlight APACHE_SERVER_FLAGS. Type “SVN_DOC SVN_VIEWCVS” into the text field.
    • Finish.
  4. A diff of ORIG/default-server.conf with the one YaST created shows that YaST removed the mod_userdir section, changed indents, and added ServerName and ServerAdmin. Thus I chose the original distribution .conf as my starting point:
    • mv default-server.conf{,.YAST}
    • cp ORIG/default-server.conf .
    • ci -l default-server.conf
    • Edit with a text editor and copy the ServerName and ServerAdmin directives from the YaST version into default-server.conf.
    • ci -l default-server.conf
  5. Restart YaST/ Network Services/ HTTP Server:
    • Select the Server Modules tab and verify that the dav_svn module appears.
    • Exit or Abort.
    • Note: from this point forward, if YaST/HTTP Server is re-run and Finish is clicked, default-server.conf and /etc/sysconfig/apache2 will be overwritten. Capture a snapshot before running or retrieve original from RCS archive afterward.
  6. Check the syntax of all configuration files and reload httpd:
    rcapache2 restart-hup
  7. Browse http://localhost/server-info and server-status. Verify all desired modules are present and running.
  8. Browse //localhost/manual and localhost/svn-manual to see documentation.

The content-independent phase of installation is complete.

Part II: Serving Local Site Content

To prepare for Part 2, load all content files that are outside of the server document root (e.g. Subversion repositories, WebDAV directories, and user public_html areas). I keep my Subversion repositories under /home/wwwrun/svn, giving them the same owner and group as the httpd process.

  1. Verify that browsing a http://localhost/~<username> directory works.
  2. Subversion repository configuration goes in the /etc/apache2/conf.d/subversion.conf file. I piggybacked the WebDAV configuration into this file rather than creating a separate file: subversion.conf. Also, I add Basic Auth to ViewVC in subversion.viewvc.conf (see earlier blog entry for an explanation).
  3. Use htpasswd2 to create the basic authentication password file.
  4. Create a /var/lock/apache2 directory (user wwwrun, group www).
  5. rcapache2 configtest
  6. rcapache2 restart-hup
  7. Browse http://localhost/svn/<reponame>. Username and password are requested and the repository appears. Run RapidSVN from a Windows machine to verify connectivity.
  8. Edit /srv/viewvc/viewvc.conf to add root or root_parents, default root, and mailto.
  9. Browse http://localhost/viewvc , username and password are requested, then the ViewVC page appears. Click on the “ViewVC Help” hyperlink and the documentation appears.
  10. Using Konqueror, browse webdav://localhost/fs and a folder view of the WebDAV folder appears.
  11. See this blog entry for details of connecting to WebDAV via WindowsXP.

All of my local Subversion, WebDAV, and web page content is now available via Apache.

Part III: Virtual Hosts

Finally I’ll add virtual hosts for my various development, prototype, and staging areas. The YaST HTTP Server GUI offers a screen to do this, but I chose to start with the as-delivered file just as with default-server.conf.

  1. Create a new conf file in /etc/apache2/vhosts.d (e.g. LLvhost.conf in my case). I copied the vhost.template as the starting point.
  2. I defined four virtual servers:
    • localhost – contains only a ServerName statement to serve as the default server.
    • llxxx – three name-based servers that have document roots in various code development sub-directories. Each of these gets a separate set of error and access log files.
  3. Uncomment the NameVirtualHost *:80 line in /etc/apache2/listen.conf.
  4. Add the three name-based server names to /etc/hosts as synonyms for localhost.
  5. rcapache2 configtest
  6. rcapache2 restart-hup
  7. Browse http://llxxx and the virtual host content appears. Verify that log information appears in the correct file pair in /var/log/apache2.

Part IV: Configuration Control and Maintenance

The Apache server installation is now complete. But adding source code control is necessary to safely re-run YaST/ Network Services/ HTTP Server Configuration in the future. Whenever HTTP Server Configuration is ended with Save or Finish, any of the conf files may be overwritten, obliterating prior manual edits. Source code control allows us to manage and resolve this conflict.

Using the unaltered conf files in the ORIG directories as references, perform a diff of all of the conf files to learn which have been customized. Any altered conf files that were hand-edited should be placed under configuration control (e.g. CVS, Subversion, RCS). Consider controlling the YaST-altered files as well.

I maintain five files in RCS: default-server.conf, mod_userdir.conf, subversion.conf, subversion.viewvc.conf, LLvhost.conf. After saving any new HTTP Server Configuration session, I use rcsdiff to learn what changes have been made to these files. Review the changes and either restore the last version from RCS or check in a new revision as appropriate.

posted in Apache, opensuse, Subversion, SUSE, SysAdmin, YaST by Bozzie

4 Comments to "Configuring Apache using YaST, openSUSE 10.2"

  1. Maximus wrote:

    I would like to see a continuation of the topic

  2. Ivan wrote:

    I am running OpenSUSE 11.0 and I can’t see the “HTTP Server” icon on “Network Services” on YaST using GNOME. I can’t find it anywhere else either.

  3. Bozzie wrote:

    If the apache package isn’t installed, the configuration icon will not appear.

    Start up the package manager (YaST, Software, Software Management). Set the Filter to “Patterns” and scroll down to Server Functions. Check the “Web and LAMP Server” box and click Accept.

  4. Webman wrote:

    Is it possible to make Apache2 start automatically at boot (same applies to Mysql and pure-ftpd) ?!

    Thanks

 
Powered by Wordpress and MySQL. Theme by openark.org