Installation of the Apache HTTP

The Apache installation can be done using various methods, based on the requirement of the infrastructure. For example, if you want to run multiple Apache instances on a single machine, then the Source installation will be used. There are mainly three types of installations done in various web environments:

  • Source
  • Binary
  • RPM/exe

Note

Source is preferred by web administrators, as it can be customized based on system requirements.

Apache HTTP installation on Windows

In this topic, we will discuss the installation of the Apache HTTP as a service. The installation of the Apache HTTP server on the Windows platform is quite simple. Following are the steps to be performed:

  1. The Apache HTTP server can be downloaded from various different sites, but it is always recommended to download it from its official site http://httpd.apache.org/download.cgi. On this site, you can find the stable and beta release details. Download the latest Win32 Binary without crypto (no mod_ssl) (MSI Installer) given in the website. Click on httpd-2.2.X-win32-x86-no_ssl.msi to begin the download. Here 2.2 is the major version and X is the minor version, which changes almost every month. The following screenshot shows the different versions available for the download:
    Apache HTTP installation on Windows

    Note

    We are using httpd-2.2.X-win32-x86-no_ssl.msi for the installation of Apache here and the installation steps will not change with the update of the minor version.

  2. Once you have downloaded the required exe file. (http-2.2.X-win32-x86-no_ssl.exe), double-click on the exe and you will see a welcome screen as a pop-up. Click Next, as shown in the following screenshot:
    Apache HTTP installation on Windows
  3. The next screen shows the License Agreement. Click on I accept, as shown in the following screenshot, it will show the server information screen:
    Apache HTTP installation on Windows
  4. As shown in the following screenshot, you have to enter the following details
    • Server Domain
    • Server name: In a real-time environment, server name is the host name of the machine.
    • Administrator e-mail ID: It is the SMTP address on the local server.
    Apache HTTP installation on Windows
  5. Once you fill in the details shown in the previous screenshot, click on Next. It takes you to the installation screen. Choose Typical, as shown in the following screenshot:

    Note

    In a Typical installation, entire libraries and modules, which are required for installation of Tomcat 7 in Windows, are installed automatically. Also, a Typical installation contains predefined modules, which are necessary for the web server to perform their functionality. This method is recommended for beginners and intermediate users. In a Custom installation, we have the freedom to choose the modules, which are necessary for the application to perform their function properly, the rest of the module can be ignored, hence, taking less space and memory. This method is recommended for those who have a good knowledge of Apache.

    Apache HTTP installation on Windows
  6. In the next screen, the installation directory of the HTTP server is displayed:

    Note

    It is recommended to use D drive for critical websites. The reason being that if the server crashes, Apache can still be recovered without any issue.

    Apache HTTP installation on Windows
  7. After clicking on Next, the installation process starts, as shown in the following screenshot:
    Apache HTTP installation on Windows
  8. Then a screen comes up indicating that it's completed, as shown in the following screenshot:
    Apache HTTP installation on Windows

How to monitor the Apache service

Once Apache is installed, you can start and stop the services in two ways:

  • Apache monitoring service
  • services.msc

By default, Apache comes with a tool called Apache Monitor, through which Apache systems can be monitored. The following screenshot shows the Apache services status as green. It means the server is running. If you want to restart the services, you can use the Restart button to do the same.

How to monitor the Apache service

Another way of recycling Apache is through the services.msc, which can be accessed by clicking Start | Run | services.msc

The services console will open. Click on Apache2.2 services, a services properties console window is displayed. It shows the Start and Stop prompt, and the current status of the server instance, as shown in the following screenshot:

How to monitor the Apache service

Installation of Apache HTTP on Linux (non-DOS environment)

The Apache HTTP installation in a non-DOS environment is different, as compared to a Windows environment. In the previous section, Installation of the Apache HTTP, we have discussed about binary files. In this installation, we will discuss the Source installation. Following are the steps involved in Source installation:

  1. Download the Apache httpd server from the Apache official site. http://httpd.apache.org/download.cgi. The following screenshot shows the file to be downloaded (httpd-2.2.X.tar.gz where 2.2 is the major version and X is the minor version):
    Installation of Apache HTTP on Linux (non-DOS environment)
  2. Once the download is complete, the source file is stored in the home directory of the user (in our case it's /root). The source file comes in the form of tar.gz. Run the following command to unzip the source. First create a folder httpd and then extract the content in the httpd directory.
    tar -zxvf httpd-2.2.X.tar.gz
    

    Note

    We have extracted the httpd-2.2.19.tar.gz in the /opt directory.

    Installation of Apache HTTP on Linux (non-DOS environment)
  3. You can check the directory using the following command. The result displayed is similar to the following screenshot:
    ls -ltrh
    
    Installation of Apache HTTP on Linux (non-DOS environment)
  4. Then access the extracted directory using the following command. The result is similar to the following screenshot:
    cd httpd-2.2.19
    ls -ltrh
    
    Installation of Apache HTTP on Linux (non-DOS environment)
  5. After the verification of the directory, it's time to install the Apache HTTP server on Linux. By default, the execution permission is not set to true on the source folder. For that, we have to run the chown command to make it true.
    [root@localhost httpd-2.2.19]# chown 0755 configure
    

By default Apache Portable Runtime (APR) is not installed in the 2.2 version, we have to install it. Let's discuss APR and its utilities in detail.

Note

/configure with included APR is enabled from the version 2.2.3.

Apache Portable Runtime

Apache Portable Runtime is an open source project, which is supported by the Apache Foundation software. The main goal of this project is to provide the developer with an API, through which they can code and predict the identical behavior, regardless of different platforms. It eliminates the requirement of additional code dependency for different operating systems. For more information on this project, please visit http://apr.apache.org/.

Tomcat 7 uses APR to provide the capability of scalability, performance, and best collaboration with native technologies.

The Apache Portable Runtime project is again divided into three subprojects, to enhance and simplify the capability of this project. The following figure shows the different subprojects for APR:

Apache Portable Runtime

APR is a portable runtime library, through which Apache integrates with other native technologies. It is also helpful in resolving the problem of threads and processes. For more information on APR, please visit http://apr.apache.org/docs/apr/trunk/index.html.

Apache Portable Runtime Utility (APR-util) is a companion library for APR. To install this utility, the GCC++ package should be installed to the OS (http://apr.apache.org/docs/apr-util/trunk/).

APR-iconv is a portable implementation of the iconv() library (http://apr.apache.org/docs/apr-iconv/trunk/).

Installation of APR/APR-util

APR/APR-util comes with the source of the Apache package, and they can be found in the following directories as shown in the following screenshot:

  • APR: Installdir/srclib/apr
  • APR-util: Instaldir/srclib/apr-util

As we have extracted the source in /opt/httpd-2.2.19, the source directory is also found in the same directory.

Installation of APR/APR-util

Let's start with the installation of APR, followed by the installation of APR-util.

The APR installation can be done in three steps using three commands. The steps are as follows:

  1. Enter the source directory of apr and apr-util, then configure the code using the following commands:
    [root@localhost srclib]# cd /opt/httpd-2.2.19/srclib/apr
    [root@localhost apr]# ./configure --prefix=/opt/httpd/apr-httpd/
    [root@localhost apr-util]# /configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
    Make
    Make install
    

    Note

    The APR/APR-util installation should be done first, if we are compiling the source code of Apache manually. If we miss installing APR/APR-util, then at the make command execution for Apache, source will produce an error.

  2. You can configure Apache using the following command. The following screenshot shows the output of the command when executed:
    [root@localhost httpd-2.2.19]#./configure --with-included-apr --prefix=/opt/apache-2.2.19
    
    Installation of APR/APR-util
    Installation of APR/APR-util
  3. The previous screenshot describes the progress of the configure command. Once the command is executed, it will get the return code 0 otherwise you will see an error on the screen. Then, run the make command on the server to compile the code. The following figure shows the output of the make command:
    [root@localhost httpd-2.2.X]#make
    
    Installation of APR/APR-util

    Tip

    It is very important to check the output of the make command, as it gives an error most of the times.

    Installation of APR/APR-util
  4. The previous and the following screenshots show the completion without any error. To proceed with the installation of make, we have to run the following command:
    [root@localhost httpd-2.2.X]#make install
    
    Installation of APR/APR-util
  5. The previous command installs the Apache HTTP on the server, as shown in the following screenshot. It shows the completion on the server. If you view the previous screenshot, you will find that it creates the directory structure, files, manpage and htdocs, as shown in the next screenshot:
    Installation of APR/APR-util
  6. After the make install is complete, the directory structure of the Apache HTTP server is created in the current path of the installation. Let's quickly see how the directory looks. The following screenshot shows the directory structure of the Apache HTTP server. In 90 percent of cases, Apache administrators work on the conf, modules, and htdocs directories for performing day-to-day operations.
    Installation of APR/APR-util
  7. Before we end the installation, it is necessary to start the services of HTTP to verify the instance is properly installed. The best way to check the configuration is by running the configtest script. This script comes by default with Apache httpd, only in a non-DOS environment. The script can be found in APACHE_HOME/bin.
[root@localhost bin]# ./apachectl configtest
Syntax OK
  • Then restart Apache using the following command:
[root@root@localhost bin]# ./apachectl start
  • Once you start Apache, it's very important to verify the instance status. You can verify the system using the ps command:
ps -ef |grep httpd
Installation of APR/APR-util

The previous screenshot shows the status of the HTTP process, this means the HTTP server is running properly.

Note

We can directly install the Apache package in Debain Linux (Ubuntu), using the apt-get command. The following command shows the syntax for the installation:

sudo apt-get install apache2

Also, you can install the Apache using the yum utility. This utility is used mainly in CentOS using the command:

yum -y install httpd

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.246.193