Apache Local Web Server



  1. Configure Apache Web Server Ubuntu 18.04
  2. Apache Local Web Servers
  3. Configure Apache Web Server In Linux

This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQLand emailservers. Configure Apache to share documents from the right folder. Say you want to make your music collection downloadable using your new web server, and all your music files are located in C. Apache is therefore configure by default to only allow access from the PC running the server i.e. Localhost or 127.0.0.1 or::1 But as it is a full version of Apache all you need is a little knowledge of the server you are using.

How To Setup a Home Web Server On Your Windows Computer With Apache [DIY]

A web server can be referred to either the hardware or the software that delivers content (webpages, documents, photos, files, videos etc), which can be accessed through the internet. A web server is what makes it possible to be able to access content e.g webpages, files from any computer, as long as it is connected to the internet and the server is also connected to the internet.

Disclaimer: Before we move on to the steps for creating a home web server on your computer, please be careful and proceed only when you know what you are doing. Running a web server on your computer might be very risky and if you’re not the type of person who knows how to tweak a network connection, assign a static IP address or port forward your Router preferences, you might not want to take the risk and install the home web server on your Windows computer. If possible, seek help from an expert who knows a thing or two regarding websites, Apache and stuff.

Before moving on, make sure you have thoroughly performed a complete system scan and that your computer is free from spyware, virus and trojans.

Things You Will Need

To set up a simple web server on your computer, you will need the following components:

1. A computer running Windows (Windows XP, Windows Vista or Windows 7).
2. Apache 2.2 installed on Windows.
3. Knowledge of tweaking your computer’s network preferences.
4. Knowledge of port forwarding the correct ports from your Router’s settings.
5. Mapping your computer’s IP address with a domain name.
6. An always “ON” internet connection, Broadband preferred.

Watch the Screencast

The following video tutorial illustrates all the steps required to install a home web server on your Windows computer. If you don’t like to follow all the written steps that follows next, just watch the following video tutorial and perform the actions as described.

http://www.youtube.com/watch?v=3ouZPy40w_E

Step 1: Assign a Static IP Address to Your Computer

For the home web server to function properly, you will need to assign a static IP address to your computer from Windows network and sharing center or control panel. This can be done manually but I recommend using portforward.com’s free tool for assigning static IP addresses to your computer, if you are not comfortable doing it manually. (related guide: find your computer’s IP address )

After assigning a static IP address, open windows command prompt and type ipconfig to see your computer’s IP configuration, which should look something like this

You are done with the IP settings, now it’s time to configure Apache.

Step 2: Configuring Apache On Windows – Installing the Home Server

1. First, disable Windows firewall completely before trying to install Apache on your computer. You should also close other applications, IM programs and other client side applications that may interfere with Apache’s working.

2. Download Apache 2.2 windows MSI installer and Install Apache 2.2 on your Windows computer. During installation enter the following credentials:

  • Network domain: localhost
  • Server Name: localhost
  • Administrator’s email address: any email address of your choice

Remember to choose the selection “for all users, on port 80, as a service”.

3. When Apache has finished installing, open Windows Explorer, go to your computer’s hard drive and create a new folder where you would be hosting all the files of your website, hosted from your own computer. For the sake of this tutorial, let us assume that you create the root folder in E:webserver.

4. Navigate to the Apache installation directory at C:Program FilesApache Software FoundationApache2.2conf and open the httpd text file with Notepad or any other text editor of your choice.

4. Hit Control + F and do a search for DocumentRoot, switch to the second value and change it to the location of the folder you created in step 2.

5. Scroll down and find <Directory “C:Program files…”. Change the value to the location of the same custom folder you created in step 2.

6. Scroll down a bit and find Allow override. Change it’s value to All

7. Save the file as httpd.conf in the same directory. Remember to save as “All files” and not as a text document.

8. You are done configuring Apache on Windows for the home web server to function properly. Now right click the system tray icon and select “Restart all services”.

9. Next, point your browser to http://localhost and you should see the following screen

That means, Apache has been successfully installed on your computer and you are all set to deploy websites, files and other documents from your web server to the internet.

Step 3: Creating Directories and Files in your Home Web server

1. Go to your webserver’s root directory ( E:webserver) and drop some sample files, folders. You will serve these files to your website visitors i.e you will allow people to download files from your computer via this home made web server.

Local

2. You can create as many folders as you want and drop index.html files in each folder. These folders work the same way as any FTP directory, representing the folder and directory structure of a website. (related: hosting static websites )

3. When you are done creating the sample files and directories, refresh the localhost page and you should see the folder and file structure being updated. An example is shown below:

Step 4: Configuring Your Router For Port Forwarding

Open your web browser and type in 192.168.1.1 to access your Router’s preferences. In case the router asks for a password, enter the correct username and password combination ( 99% cases the combination is admin/admin)

Most wireless routers have a simple setup for port forwarding but in my case, the situation was slightly different. My Internet service provider is BSNL, Router is from Siemens and the Port forwarding page was hidden from the main navigation area.

In order to access the hidden port forwarding setup in LinkSys, Siemens or routers provided by BSNL (India) enter 192.168.1.1/main.html and it may open up your Router’s advanced settings page.

Click “Advanced setup” from the left sidebar and then choose NAT > DMZ Host. Next, enter your computer’s internal IP address under “DMZ Host IP address” and save the changes. You might need to restart/reboot the router for the changes to take effect.

If your router has a different setting, check out Portforward.com and learn how to port forward the “80” port from a specific router to the internet.

Step 5: Testing a Beta Run Of Your Home Web Server

Now that you have successfully port-forwarded your router or modem, it’s time to test your home web server and open a sample local website stored in your computer from any other computer you might have.

Go to whatsmyip.org to find out your computer’s external IP address. Once you have obtained the external IP of your computer, enter the same in the browser (of any computer) and your web server should show up.

Caution: Do not ask any random online friend to test your web server. Passing on your computer’s external IP address to anyone is not at all recommended. Careful !

Troubleshooting: If you are unable to open/test the web server because opening the external IP address keeps opening your router’s login page over and over again, use a proxy website like anonymouse.org

Once you have tested your home web server within your friends and a fewer group of people, it’s time to map the web server with a domain name.

Final Step: Mapping Your Web Server With a Domain Name

Passing out your computer’s or home server’s IP address to anyone can be risky. So what we will do now is register a free domain name at www.no-ip.com and map our home server’s external IP address with this domain name.

Once the domain mapping is in place, all you have to do is share the same domain name with your friends or with whoever you want to share the home server and it should work just as fine.

Visitors, friends or colleagues who have the address (or domain name) of your web server can browse through files, download them and use it the same way as they browse any other website on the internet. The only condition is that your computer must be connected to the internet and Apache should be installed and running as it normally should.

Turning Off The Home server

There are three ways to take your home server down, in case you’re down with it and want to switch off all the experiments:

1. Login to your No-Ip account and delete the hostname. Once the hostname is deleted, the domain name would notpoint back to your computer’s external IP address and visitors trying to access your server would get a “Time out error”

Configure Apache Web Server Ubuntu 18.04

2. Change your computer’s internal as well as external IP address. Better still, assign a dynamic Ip address to your computer.

3. Uninstall Apache completely from the system and move all the server’s files to some other location.

Of all the above solutions, I would prefer the first option of deleting the hostname because it has the advantage of “plug and play” over it’s counterparts. Later, you can turn on the same web server by mapping another domain name to your computer’s external IP address.

Over To You

Have you ever experimented by creating a home web server on your windows, linux or MAC computers ? Tell us how you did it, what problems you faced and the outcomes in the comments below.

1. Introduction of Web Server (Apache Web Server)

A web server generally hosts the web content, and responds to requests for this content from web browsers such as Internet explorer, Google chrome and Firefox. The example of web server are apache web server, IIS web server, Nginx webserver and litespeed web server.

Technically, a web server is a daemon that speaks the https(s) protocol, a text-based protocol for sending and receiving object over a network connection. The http protocol is sent over the wire in clear text, using port 80/TCP by default (though other ports can be used).

There is also a TLS/SSL encrypted version of the protocol called https that uses port 443/TCP by default.

This article will discuss more on the most popular web server, Apache httpd server.

2. What is apache web server (Apache HTTPD) ?

Apache web server or Apache http server is one of the most widely used on the Internet. It is developed and maintained by Apache Software Foundation, Apache is an open source software available for free.

Beside Apache, IIS and Nginx also among the most common web servers in use today.

Based on survey by [news.netcraft.com] in June 2016, Apache Web server regained the lead from Microsoft IIS with a large increase.

Meanwhile, the portal [trends.builtwith.com/web-server] reported (July 18, 2016) the web server statistics shows that from the entire internet web, there are 46% web server running in Apache, 29% in Microsoft IIS and 19% in Nginx.

3. Apache Web Server packages in RHEL and CentOS Linux

In Red Hat Enterprise Linux 7 and CentOS 7, there is a group of package called “Web Server”. It includes the following software :

A default dependency of the httpd package is the httpd-tools package. This package includes tools to manipulate password maps and databases, tools to resolve IP address in log files to hostnames, and apache benchmark tool (ab). ab tool is very useful to perform a stress-test to the apache web server.

If you use Apache for your development server or Linux administrator who manages the corporate website in the apache web server, know how to setup and configure Apache will be important.

4. Install Apache Web Server Linux

This article explains the steps to install and configure Apache web server in RHEL 7 / CentOS 7 linux.

Please login to your CentOS 7 server to run below command :

a. How to install Apache web server only :

b. Apache web server installation from apache group packages :

c. How to start, stop and restart Apache Linux web server :
The following steps shows how to start, stop and restart the apache is for RHEL 7 and CentOS 7 operating system. The command will differ slightly in other linux distributions.

Web

d. To start Apache service:

e. To stop Apache service:

f. To restart Apache service :

g. How to enable Apache web server at boot :

5. Configure Apache http Server In Linux

5.1. Overview of apache httpd conf file :

The httpd.conf is the primary configuration file in Apache Web Server in RHEL and CentOS. It is located at /etc/httpd/conf folder. It is a text file and consist of directives, containers and comments.

Example of directives in httpd.conf :

Example of containers :

Containers enclose one or more directives.

Example of comments :

5.2 Configure Apache httpd.conf configuration file

There are a few apache configuration need to alter before you can start running the apache web server. All the main configuration file is in httpd.conf file :

Modify below directives and matches the value to your web server environment :

ServerAdmin email address
This is where your problem with the server should be e-mailed. This address appears on some server-generated pages, such as error documents.

For example:

DocumentRoot directory-path
The top level directory for Apache server content. The apache user requires read access to any files and read and execute access to the directory and any of its sub-directories. Do not place a slash at the end of the directory path.

For example:

ServerName FQDN[:port]
Specifies the fully qualified domain name or IP address of the httpd server and an optional port on which the server listens. The FQDN must be resolvable to an IP address.

If you do not specify a FQDN, the server performs a reverse-name lookup on the IP address. If you do not specify a port, the server uses the port corresponding to the incoming request.

For example:

AllowOverride Directive
In Apache 2.4, AllowOverride is set to None by default. When AllowOverride is set to None , then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.

When AllowOverride directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files.

htaccess is short for Hypertext Access, is a configuration file for use on web servers running the Apache Web Server software. Most of the developers today use htaccess to configure the details of the blog or website without needed to alter the server config files.

For Example :

If you run a single web site, above configuration is sufficient for your apache web server.

To apply the new configuration, restart or reload the Apache web service :

or

Access the web server ip address :

If you run multiple websites, you can configure Apache virtual Host as mentioned on 5.3 below :

Apache Local Web Server

5.3 Configure Apache Virtual Hosts

Apache virtual hosts allow a single httpd web server to serve content for multiple domains or websites. Virtual host is defined in a Virtual Host container. The multiple virtual containers for multiple domains is specify in the VirtualHost directive.

Where to specify VirtualHost directive ?
Virtual hosts are configured using the <virtualhost> block inside the main configuration.

For ease of administration, i would recommend this virtual host blocks are not defined inside /etc/httpd/conf/httpd.conf. Instead, please create new separate configuration files in /etc/httpd/conf.d/.

Create separate configuration file to specify <virtualhost> block:

Web

For Example :

The document root specifies in each containers or virtualhost blocks is applicable to this virtual host and overrides any DocumentRoot directive elsewhere in the configuration.

Upload sample index.html or index.php into both document root (/var/www/html/website1 and /var/www/html/website2).

To apply the new configuration, restart or reload the Apache web service :

or

6. Configure Firewalld to allow access to Apache http Server In Linux

By default, port 80 is blocked. Allow HTTP service in firewalld (host-based firewall for centOS 7). HTTP uses 80/TCP and HTTPS uses 443/TCP.

Finally, you can access both virtual URL will return you different contain :

Apache Local Web Servers

Related Posts

Configure Apache Web Server In Linux

  • How to Install Apache Httpd Web Server on Linux

    Apache Httpd is a common web server that was used in World Wide Web. It…

  • How to Install Apache Httpd Server on RHEL 6

    In this post, i will show on how to install Apache Httpd server on Redhat…

  • How to Install Nginx Web Server on CentOS 6.3

    Nginx or “engine x” is a free, open-source HTTP server and one of the alternative…

  • How to Install FTP Server Linux using ProFTPd

    Proftpd is one of the most popular FTP server, secure and reliable for the Linux…

  • How to List Available Apache httpd Web Server Package and Info on CentOS 6.2

    In this post, i will show on how to list available Apache httpd web server…