Absolute Basics of Apache
Apache is the world’s most common web server and it runs on just about anything, Linux, Unix, Mac OS X, Windows, BSD, you name it and it’s typically the web server of choice in the Linux world. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. It is free in cost and is licensed under the Apache license, one of man open source licenses.
Web servers hand out HTML files and other web content using the HTTP protocol from a specific directory known in a directory tree known as the document root. The document root typically contains the default web site that is used on a server. The default document root directory varies depending on the distribution of linux you are using. I believe [citation needed ] Fedora’s document root for apache is /var/www/html. While currently openSuse’s is /srv/www/ and Ubuntu/Debian’s is /var/www. The default document in these directories is named index.html.
Nearly all configuration options for Apache are set in a single large configuration file, by default this file is located at /etc/httpd/conf/httpd.conf. (Where it is located on your distribution’s install of Apache will vary slightly). Each line in the httpd.conf file is called a directive. Below are some of the common directives:
Directive
Listen 80 Specificies that the Apache daemon will listen for HTTP requests on Port 80
ServerName server1.class.com Specifies that the name of the local server is server1.class.com
DocumentRoot “/var/www/html” Specifies that the document root directory is /var/www/html on the local machine
DirectoryIndex index.html Specifies that the index.html file in the document root will be sent to the clients who request an html document at that machine
ErrorLog /var/log/httpd/error_log Specifies that all Apache deamon messages will be written to that particular file
MaxClients 150 Sets the maximum number of simultaneous requests to 150
User apache Specifies that the apache daemon will run as “apache” local user account
Group apache Like above, this specifies the group for the user.
And for the last example, below specifies that all hosts are allowed to access HTML files and other content from /var/www/html directory expect for the computer at 192.168.1.50
<Directory /var/www/html>
Order allow,deny
Deny from 192.168.1.50
</Directory>
Installing
Installing Apache nowadays is quite simple due to repositories.
- On Ubuntu sudo apt-get install apache2
- On Debian sudo apt-get install apache2
- On openSuse (as root): zypper in apache2
- On Fedora (as root:) yum install apache2
If the apache2 doesn’t work just try ‘apache’. I specified 2 in case your repo’s have both an older and newer versions of apache.
The default settings in the httpd.conf file are sufficient for most simple web servers, thus for a beginner home server you just need to copy the files to your directory root, including your index.html file. You will need to ensure the Apache daemon is started by typing:
/etc/rc.d/init.d/httpd start
If you can the HTML content in your directory root for Apache you don’t need to restart the daemon, but if you make changes to the httpd.conf file you will need to restart Apache to activate whatever changes you have made like so:
/etc/rc.d/init.d/httpd restart
Related Posts
Tags: Apache, web server