HTTP: Configure an Apache webserver.

Share this link

Installation

Install the “Web Server” package group:

# yum groupinstall -y "Web server"

Add a new rule to the firewall:

# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate the httpd service at boot:

# chkconfig httpd on

Start the httpd service:

# service httpd start

Basic configuration

In the /etc/httpd/conf/httpd.conf fil, several directives should be set:

  • ServerName should receive the FQDN (Full Qualified Domain Name) of your server and the port number used (normally 80),
  • ServerAdmin should contain the email address where all problems should be sent (default: root@localhost),
  • Listen should receive the IP address and port number on which the Apache webserver is listening (default: all IP addresses, represented by the 0.0.0.0 value, and the port number 80),
  • DocumentRoot should define the root directory of your documents (default: /var/www/html).

Note: Be careful when changing the DocumentRoot value, the <Directory “/var/www/html”> directive needs to be updated with the same value and the httpd_sys_content_t SELinux context assigned to the new root directory (see Deploy a basic CGI application for details).

Check the validity of the /etc/httpd/conf/httpd.conf file:

# httpd -t
Syntax OK

or:

# service httpd configtest
Syntax OK

Restart the httpd service:

# service httpd restart

Configuration test

Check the httpd service:

# yum install -y elinks
# elinks http://localhost
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Leave a Reply

RHCSA7: Task of the day

Allowed time: 3 minutes.
Check that you've got no SELinux policy violations.

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a block backstore of 100MB called lv_iscsi with basic authentication, ext4 filesystem and standard firewall configuration.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Archives