I actually have used Apache as my server software program. Apache is solid, well-known, and pretty easy to configure for a basic set up. It is not without a doubt that rather more tough to configure for a greater complex setup, consisting of a couple of websites.

More Linux assets
What is Linux?
What are Linux bins?
Download Now: Linux commands cheat sheet
Advanced Linux commands cheat sheet
Our present day Linux articles
Installation and configuration of the Apache internet server have to be achieved as root. Configuring the firewall additionally desires to be executed as root. Using a browser to view the outcomes of this work have to be carried out as a non-root person. (I use the user pupil on my digital host.)
Installation
Note: I use a virtual machine (VM) the use of Fedora 27 with Apache 2.Four.29. If you've got a special distribution or a specific launch of Fedora, your commands and the places and content material of the configuration files can be distinct. However, the configuration traces you want to adjust are the equal.

The Apache net server is easy to put in. On my CentOS 6.X server, it simply takes a easy yum command. It installs all the essential dependencies if any are lacking. I used the dnf command beneath on certainly one of my Fedora digital machines. The syntax for dnf and yum are the same besides for the name of the command itself.

Dnf -y installation httpd
The VM is a very primary desktop installation I am the use of as a testbed for writing a ebook. Even in this gadget, handiest six dependencies were established in beneath a minute.

All the configuration files for Apache are positioned in /and so forth/httpd/conf and /and so forth/httpd/conf.D. The records for the web sites is positioned in /var/www by using default, but you may trade that in case you want.

Configuration
The number one Apache configuration document is /and many others/httpd/conf/httpd.Conf. It consists of loads of configuration statements that don't need to be modified for a fundamental installation. In fact, just a few adjustments should be made to this record to get a simple website up and strolling. The file may be very large so, as opposed to muddle this text with a variety of unnecessary stuff, I will show handiest those directives that you need to exchange.

First, take a chunk of time and read through the httpd.Conf file to get yourself up to speed with it. One of the things I like about Red Hat variations of most configuration documents is the range of remarks that describe the diverse sections and configuration directives in the files. The httpd.Conf document is no exception, as it is quite nicely commented. Use those remarks to apprehend what the record is configuring.

The first item to trade is the Listen assertion, which defines the IP address and port on which Apache is to listen for web page requests. Right now, you just need to make this website to be had to the nearby device, so use the localhost address. The line need to appear like this when you end:

Listen 127.Zero.Zero.1:80
With this directive set to the IP address of the localhost, Apache will concentrate simplest for connections from the local host. If you want the internet server to concentrate for connections from far flung hosts, you would use the host's outside IP cope with.

The DocumentRoot directive specifies the vicinity of the HTML files that make up the pages of the internet site. That line does not want to be changed as it already points to the standard place. The line need to appear like this:

DocumentRoot "/var/www/html"
The Apache installation RPM creates the /var/www listing tree. If you desired to exchange the area wherein the internet site documents are stored, this configuration item is used to do that. For example, you might need to use a special call for the www subdirectory to make the identity of the website extra explicit. That may look like this:

DocumentRoot "/var/mywebsite/html"
These are the handiest Apache configuration modifications had to create a easy website. For this little exercise, simplest one alternate was made to the httpd.Conf report—the Listen directive. Everything else is already configured to supply a working web server.

One different trade is wanted, however: commencing port 80 in our firewall. I use iptables as my firewall, so I exchange /and so forth/sysconfig/iptables to feature a announcement that permits HTTP protocol. The entire file looks as if this:

# sample configuration for iptables provider
# you can edit this manually or use gadget-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter out
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m nation --country RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m country --kingdom NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
The line I introduced is the third from the bottom, which allows incoming traffic on port 80. Now I reload the altered iptables configuration.

[root@testvm1 ~]# cd /and many others/sysconfig/ ; iptables-repair iptables
Create the index.Html file
The index.Html report is the default file an internet server will serve up while you get admission to the internet site the usage of just the area call and now not a particular HTML report call. In the /var/www/html directory, create a file with the call index.Html. Add the content Hello World. You do not need to add any HTML markup to make this paintings. The sole activity of the web server is to serve up a circulation of text information, and the server has no concept what the date is or a way to render it. It without a doubt transmits the facts stream to the inquiring for host.

After saving the file, set the possession to apache.Apache.

[root@testvm1 html]# chown apache.Apache index.Html
Start Apache
Apache could be very clean to begin. Current versions of Fedora use systemd. Run the following instructions to start it after which to test the repute of the server:

[root@testvm1 ~]# systemctl start httpd
[root@testvm1 ~]# systemctl reputation httpd
● httpd.Service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/gadget/httpd.Provider; disabled; vendor preset: disabled)
   Active: energetic (going for walks) due to the fact Thu 2018-02-08 13:18:fifty four EST; 5s ago
     Docs: man:httpd.Carrier(8)
 Main PID: 27107 (httpd)
   Status: "Processing requests..."
    Tasks: 213 (restrict: 4915)
   CGroup: /system.Slice/httpd.Provider
           ├─27107 /usr/sbin/httpd -DFOREGROUND
           ├─27108 /usr/sbin/httpd -DFOREGROUND
           ├─27109 /usr/sbin/httpd -DFOREGROUND
           ├─27110 /usr/sbin/httpd -DFOREGROUND
           └─27111 /usr/sbin/httpd -DFOREGROUND

Feb 08 thirteen:18:54 testvm1 systemd[1]: Starting The Apache HTTP Server...
Feb 08 13:18:54 testvm1 systemd[1]: Started The Apache HTTP Server.
The instructions can be one of a kind for your server. On Linux structures that use SystemV start scripts, the instructions would be:

[root@testvm1 ~]# carrier httpd start
Starting httpd: [Fri Feb 09 08:18:07 2018]          [  OK  ]
[root@testvm1 ~]# carrier httpd status
httpd (pid  14649) is going for walks...
If you have got a web browser like Firefox or Chrome in your host, you can use the URL localhost at the URL line of the browser to show your web page, easy as it is. You may also use a textual content mode net browser like Lynx to view the internet page. First, set up Lynx (if it is not already set up).

[root@testvm1 ~]# dnf -y install lynx
Then use the subsequent command to show the internet page.

[root@testvm1 ~]# lynx localhost
The end result seems like this in my terminal consultation. I actually have deleted loads of the empty area at the page.

  Hello World

<snip>


Commands: Use arrow keys to transport, '?' for help, 'q' to quit, '<-' to move returned.
  Arrow keys: Up and Down to move.  Right to follow a link; Left to go returned.
 H)elp O)ptions P)rint G)o M)ain display Q)uit /=seek [delete]=records listing
Next, edit your index.Html document and add a bit of HTML markup so it looks like this:

<h1>Hello World</h1>
Now refresh the browser. For Lynx, use the key aggregate Ctrl+R. The outcomes appearance simply a piece exclusive. The textual content is in color, that's how Lynx displays headings in case your terminal helps coloration, and it's far now targeted. In a GUI browser the textual content would be in a big font.

                                   Hello World

<snip>


Commands: Use arrow keys to move, '?' for assist, 'q' to give up, '<-' to go again.
  Arrow keys: Up and Down to move.  Right to observe a link; Left to head lower back.
 H)elp O)ptions P)rint G)o M)ain display screen Q)uit /=search [delete]=records listing