Apache is preinstalled on our Linux Dedicated Plans to help you set up websites on your server.
Background
The Apache HTTP Server Project is an effort to develop and maintain an
open-source HTTP server for modern operating systems including UNIX and
Windows NT. The goal of this project is to provide a secure, efficient
and extensible server that provides HTTP services in sync with the
current HTTP standards.
Apache has been the most popular web
server on the Internet since April of 1996. The November 2005 Netcraft
Web Server Survey found that more than 70% of the web sites on the
Internet are using Apache, thus making it more widely used than all
other web servers combined.
The Apache HTTP Server is a project of the Apache Software Foundation.
Installation
Installation
of Apache should be done using Yum. You also need to have root
credentials. To install Apache, execute this command:
[root$server ~]# yum install httpd
Yum
will perform the installation and all you have to do is edit the Apache
configuration file. Once Apache is installed, you will need to ensure
that Apache is currently running:
[root$server ~]# service httpd start
Next, ensure that Apache starts at boot time:
[root$server ~]# chkconfig --level 3 httpd on
Configuration
The first file to edit is /etc/hosts. Open up the file with your favorite text editor:
[root$server ~]# vi /etc/hosts
You
should see something similar to this (do not remove the following line,
or various programs that require network functionality will fail):
127.0.0.1 localhost.localdomain localhost
You
need to add a line including your IP address, domain name and your host
name. Here is an example for reference (do not remove the following
line, or various programs that require network functionality will fail):
127.0.0.1 localhost.localdomain localhost
192.168.1.1 example.com example
Save the file and move on to the next one, /etc/sysconfig/network:
[root$server ~]# vi /etc/sysconfig/network
You should see something similar to this:
NETWORKING=yes
HOSTNAME=localhost.localdomain
Edit the file to use your domain name:
NETWORKING=yes
HOSTNAME=example.com
/etc/httpd/conf/httpd.conf
is the next file that needs to be edited. This is the main Apache
configuration file. Open the file in vi:
[root$server ~]# vi /etc/httpd/conf/httpd.conf
The first line we need to change is the Listen line:
Listen: Allows you to bind Apache to specific IP addresses and/or ports, in addition to the default. See also the directive.
Change
this to Listen on specific IP addresses as shown below to prevent
Apache from glomming onto all bound IP addresses (0.0.0.0)
Listen 12.34.56.78:80
Listen 80
Edit the Listen line to include you IP address and port number:
Listen 63.134.254.2:80
The next line to look for is the ServerAdmin line:
ServerAdmin:
Your address, where problems with the server should be e-mailed. This
address appears on some server-generated pages, such as error
documents. e.g. admin@your-domain.com
ServerAdmin root@localhost
Edit the ServerAdmin to include you email address:
ServerAdmin admin@example.com
Now look for the ServerName line:
ServerName
gives the name and port that the server uses to identify itself. This
can often be determined automatically, but we recommend you specify it
explicitly to prevent problems during startup.
If this is not
set to valid DNS name for your host, server-generated redirections will
not work. See also the UseCanonicalName directive.
If your host
doesn't have a registered DNS name, enter their IP address here. You
will have to access it by its address anyway, and this will make
redirections work in a sensible way.
ServerName new.host.name:80
Edit the ServerName line to include your domain name and port:
ServerName mydomain.com:80
This should be the minimum to get the server ready to serve pages to the Internet. Restart Apache using the following command:
[root$server ~]# service httpd restart
Open up your web browser and point to your IP address and then your domain name to verify that Apache is working.
Article ID: 987, Created: July 13, 2009 at 11:24 PM, Modified: July 13, 2009 at 11:24 PM