Setting up the Apache server

Before we check out the various features of the Apache configuration file provided by HTML5 Boilerplate, let us set up a local Apache server, so that we can see these features in action.

Installing Apache

We will look at the installations of Apache on Mac, Windows, and Linux.

Mac

You do not have to do anything special; Apache is already installed. But to use it for this project, ensure you copy all the files to the website's folder in your home folder (/~<username>). Edit the /etc/apache2/httpd.conf file to change the following highlighted code:

<Directory /usr/share/web>
AllowOverride None
        Options MultiViewsFollowSymlinks
        Order allow,deny
        Allow from all
        Header Set Cache-Control no-cache
</Directory>

To the following:

<Directory /usr/share/web>
AllowOverrideAll
        Options MultiViewsFollowSymlinks
        Order allow,deny
        Allow from all
        Header Set Cache-Control no-cache
</Directory>

You will also need to change this entry in /etc/apache2/<username>.conf the same way.

Windows

You need to download and install Apache on Windows; it can be downloaded from httpd.apache.org/docs/2.2/platform/windows.html. Note that you need to add the following code snippet to conf/httpd.conf, located within the folder where the Apache application is found:

<Directory "/apache/htdocs/">
AllowOverride All
Options None
Order deny, allow
</Directory>

Linux

If you are using Ubuntu, there is a friendly documentation available at https://help.ubuntu.com/8.04/serverguide/C/httpd.html. To enable .htaccess files, used to configure your Apache server, you need to edit /etc/apache2/sites-available/default from the following code snippet:

<Directory /var/www/>
Options Indexes FollowSymLinksMultiViews
AllowOverride None
   Order allow,deny
allow from all
   # Uncomment this directive is you want to see apache2's
   # default start page (in /apache2-default) when you go to /
   #RedirectMatch ^/$ /apache2-default/
</Directory>

To the following code snippet:

<Directory /var/www/>
Options Indexes FollowSymLinksMultiViews
AllowOverrideAll
   Order allow,deny
allow from all
   # Uncomment this directive is you want to see apache2's
   # default start page (in /apache2-default) when you go to /
   #RedirectMatch ^/$ /apache2-default/
</Directory>

Configuring Apache

Our folder for HTML5 Boilerplate contains a file called .htaccess. As the filename starts with a ., it is likely that .htaccess won't show up when you list your files in Finder/Windows Explorer or other file manager utilities, as shown in the following screenshot:

Configuring Apache

But if you enable the hidden files to appear on your OS, you will be able to see this file.

All that is required now is to move our site files (including the .htaccess file) to the server we just set up. Apache looks for a .htaccess file on all folders (unless told not to by a configuration setting) and so having our .htaccess file in the parent folder of our site is just fine.

Using a .htaccess file for testing is not a bad idea in general. However, if you want to make your site really zippy, it is best to put the configuration directly on the Apache server's main configuration file (httpd.conf). Unfortunately, not all hosting providers allow this.

If you do have access to the Apache server's main configuration file (httpd.conf), you should copy the configurations from HTML5 Boilerplate's .htaccess file and put them within httpd.conf inside a Directory tag, as shown in the following code snippet:

<Directory /path/to/website/root>
[htaccess rules]
</Directory>

You should then remove the .htaccess file as the directives are already on the server's main configuration file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset