Apache Webserver on Ubuntu


Install and run...
  1. apt-get install apache2
  2. Set up vhost files.
  3. Set up modules you want.
  4. service apache2 status|start|stop|restart

More? See HTTPD - Apache2 Web Server

Apache Webserver on SuSE Linux

It is unfortunate that the Apache webserver is installed and configured with dramatic difference across even modern Linux platforms. Here’s what I’m seeing for SuSE 10 right now (at work; at home I have 10.1 and we’ll see how different that is). It is quite literally a pain in the kazoo as compared to what I experienced 5 or 6 years ago on RedHat 7.1. However, I don’t dare go against the grain because there are benefits to doing things the right way on your platform.

See docs at http://httpd.apache.org/docs/2.2/.


Install and run...

I followed an article by my old friend, Kevin Millecam, (Google “apache linux millecam”) a little bit before it started deviating from what I could relate to. Kevin wrote this article to rave reviews a few years ago—back before SuSE 10. What is even more useful, once I get to it, is the coverage of PHP and MySQL. I have so far climbed the PHP mountain, although not really since SuSE’s Apache2 simply came already installed with it. (I mean, when I loaded my box in January 2006, I specifically asked for Apache2 to get installed during the initial installation because I knew that sooner or later I would need to use it.

I found in SuSE 10 that Yast doesn’t mention Apache by name, but instead calls it the http server. Okay, I’m clever enough to guess that “http server’ refers to the Apache web server because the Apache Software Foundating is bigger than just their webserver. And, Yast is handy in expert mode once you get there, for setting up Apache in the respective boot levels, but that is all it does for you.

Where’s my stuff?

RedHat installs Apache across /var/local and /usr/local which is where you’d install it if you were compiling it for yourself from Apache sources.

SuSE comes with Apache 2 and if you let Yast take care of the problem for you, it gets installed who knows where. I haven’t found all the places it goes, but I can tell you that it isn’t in /usr/local presumably because SuSE considers it system software.

It has been asserted to me that Yast can configure things like Document Roots. I was looking forward to this since the last time I messed with those, for my Apache server running on NetWare (whence you are reading this very document), I failed to perform the configuration correctly (and, my hand was being held by Novell’s Apache guy too). However, I did not find this to be true in the version of Yast installed on my SuSE 10. On SuSE 10.1, it happens under Yast for http server.

What’s more, I haven’t yet figured out how to muck with /etc/apache2/httpd.conf directly because that file now asks one not to muck with it. So, I’m still looking for how and where to do that. There are very unclear suggestions in that file, but some refer to files that don’t exist on my SuSE host. (But, more on this topic in the next section.)

Disconcertingly, path ~/public_html is useless to the Apache server on my host—a very convenient phenomenon that Kevin’s article had led me to believe would work. I would love to be able to put my stuff there.

Yast or not to Yast?

At work, I’ve found that SuSE 10’s Yast doesn’t provide for as much cool configuration as the SuSE 10.1/2 I have at home (I installed 10.1, but some things have been upgraded to 10.2, something I didn’t do on purpose, but happened already prior to my installation of 10.1 or as part of an automatic upgrade I tried to set up and which may have worked).

In particular, I find that at work I have to modify /etc/sysconfig/apache2 by hand to get APACHE_CONF_INCLUDE_FILES set to /etc/apache2/mod_userdir.conf in support of using ~/public_html use as a document root.

As you might guess, at work now (10.0) I restarted the dæmon with the change just described and it now works. I hate having to learn a new way to do things each release. There should be a best practices and then we’re done.


Populating the document root...

At this point, I can only say that /srv/www/htdocs is where I found what is displayed when, from a browser on any host here at my work, you type http://taliesin.vintela.com/. This is not to say that this path isn’t an eminently wonderful place for a webserver’s documents to go, it just seems very specific to SuSE.

I placed the following PHP content there and got what I was looking for once I did it. I called the document, info.php and reached it thus: http://taliesin.vintela.com/info.php

	<?php phpinfo(); ?>

This magically causes a page from php.net to come up with system information on it (quite useful).

PHP works, therefore, if not where I would prefer to see it (on ~/public_html where Kevin put his).


Virtual hosts...

In Apache, the term virtual host refers to being able to host more than one web site or domain name on the same server. This seems obvious, but you have to think about it.

It is possible to assign one IP address per domain or, more frequently, overload the one IP address you have with several domains, what Apache calls name-based hosting.


Setting up a subdomain using vhost files

Imagine a new subdomain, deck added to windofkeltia.com. Create a virtual hosts file with the following for the new subdomain.

    <VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName deck.windofkeltia.com
        DocumentRoot /home/websites/windofkeltia.com/deck
        ErrorLog /home/websites/log/windofkeltia.log
        <Directory /home/websites/windofkeltia.com>
            AllowOverride all
            Options Indexes FollowSymLinks MultiViews
        </Directory>
    </VirtualHost>

    <VirtualHost *:443>
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
        SSLCertificateFile      /etc/ssl/STAR_zzt_net.crt
        SSLCertificateKeyFile   /etc/ssl/STAR_zzt_net.key
        SSLCertificateChainFile /etc/ssl/cacertfiles.cabundle
        ServerAdmin [email protected]
        ServerName deck.windofkeltia.com
        DocumentRoot /home/websites/windofkeltia.com/deck
        ErrorLog /home/websites/log/windofkeltia.log
        CustomLog /home/websites/log/windofkeltia.log combined
        <Directory /home/websites/windofkeltia.com>
            AllowOverride all
            Options  Indexes FollowSymLinks MultiViews
        </Directory>
</VirtualHost>

Use of CNAME for subdomains

The following illustrates the addition of "deck .... @" to CNAME entries to enable the subdomain addition addressed in the earlier section.


New for Apache 2.4

Changes that significantly affect the otherwise simplicty and habits of running a webserver.

  1. vhost files must have names ending in .conf; nothing else will do.
  2. In order not to get "You don't have permission to access / on this server" You must fix /etc/apache2.conf from:
    # These were the factory settings:
    <Directory />
           Options FollowSymLinks
           AllowOverride None
           Require all denied
    </Directory>
    

    to:

    # To fix the problem: You don't have permission to access / on this server,
    # These settings from:
    # http://stackoverflow.com/questions/10873295/error-message-forbidden-you-dont-have-permission-to-access-on-this-server
    <Directory />
            #Options FollowSymLinks
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Require all granted
            #a note lower down reminded readers that these settings are obsolete
            #Order deny,allow
            #Allow from all
    </Directory>