Apache Installation

From T5C

Jump to: navigation, search

The Apache web server is a critical part of the LAMP stack, receiving and responding to client requests. In this article, we will cover the installation and initial configuration of the Apache HTTP daemon on CentOS Linux.

[edit] Installing via yum

Installing the Apache web server in CentOS Linux using the yum package managemen tool is as easy as a single line at the command prompt:

 yum -y install httpd

That's it! This will download and install Apache, resolving any dependencies that may arise. This will install version 2 of the Apache HTTPD daemon.

[edit] Initial Configuration

Before starting our web server, we need to make some minor changes to it's configuration file so it can be secured and tuned for optimal performance. We will open the file for editing with the vi editor like this:

 vi /etc/httpd/conf/httpd.conf

Once in vi, find the line that contains the line:

 ServerAdmin root@localhost

and change it to specify your e-mail address as the real server admin's address:

 ServerAdmin webmaster@oss.cayey.upr.edu

Then find the line:

 ServerTokens OS

and change it to:

 ServerTokens Prod

This will hide dangerous details about your web server from would-be hackers trying to find vulnerabilities in your system. A second step in this direction is to find the line:

 ServerSignature On

and change it to:

 ServerSignature Off

So it's even more difficult for hackers to know what server you're running.

Finally, you need to comment out the following lines by placing a pound sign (#) as the very first character of each line:

 LoadModule proxy_module modules/mod_proxy.so
 LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
 LoadModule proxy_http_module modules/mod_proxy_http.so
 LoadModule proxy_connect_module modules/mod_proxy_connect.so

will become:

 #LoadModule proxy_module modules/mod_proxy.so
 #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
 #LoadModule proxy_http_module modules/mod_proxy_http.so
 #LoadModule proxy_connect_module modules/mod_proxy_connect.so

Now your server will not function as a web proxy, which can make it a target for numerous remote attacks.

Once you've made these changes to the configuration file, you can save them and exit vi (:wq) and we are now ready to start the HTTP daemon.

 service httpd start

You can now open the Firefox web browser and navigate to:

 http://yourservername

to see the default Apache welcome page. Congratulations! You have successfully setup your Apache server. To publish web pages or other types of files, simply put them in the following directory:

 /var/www/html

To remove the default welcome page and have your own homepage displayed when someone enters your domain name, name your homepage file:

 index.html

Finally, to have the http daemon start automatically when the server boots, enter the following command:

 chkconfig httpd on

and the daemon will start at each server boot.