Going Beyond Packages: A Deep Dive into Apache Installation Using Source Code

Webserver:                Nowadays we all are using websites for many cases. The common man does not know about the backend of the...



Webserver:
               Nowadays we all are using websites for many cases. The common man does not know about the backend of the websites.
              The primary function of a web server is to store, process, and deliver web pages to clients. Using the HTTP (HyperText Transport Protocol) client and server will communicate.
               The web server is the first level of the website. When the user searches something like "photo" it will go to the webserver and take the content from the database and shows it to the user. which may include images, style sheets, scripts, and text content.



There were some webservers widely used all over the world. There are Apache, Nginx, Apache Tomcat...etc

Apache webserver:
            Apache webserver is mostly used all over the world. Apache webserver using the protocol(HTTP, HTTPS) communicate client to server.
            Apache HTTP uses port 80,443 to communicate with the server. 80 was the default port for HTTP, and 443 was the default port for HTTPS.
           We Can Install the Apache using source code or Yum package manager(For RedHat, Centos).
   
Using Source code Installation There were Six steps have to follow.

1. Download 
            Download the required packages and source code from repositories
2. Extract
           Extract the source code using the tar and zip command
3. Configure
           Configure the apache using ./configure --prefix=PREFIX
           PREFIX must be replaced with the filesystem path under which the server should be installed. If PREFIX is not specified, it defaults to /usr/local/apache2
4. Compile and install:
            Make and make install cmd use to compile and install apache
5. Customize:
             vim /etc/systemd/system/httpd.service
6. Test:
            To check if httpd running or not using commands if working then check in the browser.

Installation process:

1. Run the below command which is used to install all the required packages for the  source code compilation of apache
       
      [root@linuxhelp1 ~]# yum groupinstall " Development Tools"  -y

Where "y" is the option for yes to install packages continue in installation. Using the "y" option it cannot ask yes or no

2: install pcre and pcre-devel packages it is also required for the apache installation

PCRE-Perl Compatible Regular Expressions

[root@linuxhelp1 ~]# yum install expat-devel pcre pcre-devel openssl-devel -y

3: Download the apache source code along with apr and apr-util from the apache website or git repository


Apache httpd - https://github.com/apache/httpd/releases

Apr - https://github.com/apache/apr/releases

Apr-util - https://github.com/apache/apr-util/releases

To get an apache source code from the repository use the "Wget" command to get the source code 


[root@linuxhelp1 ~]# wget https://github.com/apache/httpd/archive/2.4.28.tar.gz -O httpd-2.4.28.tar.gz

[root@linuxhelp1 ~]# wget https://github.com/apache/apr/archive/1.6.2.tar.gz -O apr-1.6.2.tar.gz

[root@linuxhelp1 ~]# wget https://github.com/apache/apr-util/archive/1.6.0.tar.gz -O apr-util-1.6.0.tar.gz

4: Extract the downloaded source code

[root@linuxhelp1 ~]# tar -xzf httpd-2.4.28.tar.gz
[root@linuxhelp1 ~]# tar -xzf apr-1.6.2.tar.gz
[root@linuxhelp1 ~]# tar -xzf apr-util-1.6.0.tar.gz

5: We need to place the apr,apr-util directory inside the srclib directory  it is located under the HTTPD directory

[root@linuxhelp1 ~]# mv apr-1.6.2 httpd-2.4.28/srclib/apr
[root@linuxhelp1 ~]# mv apr-util-1.6.0 httpd-2.4.28/srclib/apr-util

6: change the directory to httpd-2.4.28( which version u installed u can go to that directory)

[root@linuxhelp1 ~]# cd httpd-2.4.28

Compilation of Apache source:

step7: To build a configure script, execute the following buildconf script file as follows.

[root@linuxhelp1 httpd-2.4.28]# ./buildconf 

Step8: Run the configuration command 
           We  Can change the default Apache installation directory path

Here path will be /usr/local/apache2 directory path. 

[root@linuxhelp1 httpd-2.4.28]# ./configure --enable-ssl --enable-so --with-mpm=event --with-included-apr --prefix=/usr/local/apache2

Step9: Execute the make command to prepare the files for the installation of Apache.

[root@linuxhelp1 httpd-2.4.28]# make

step10: Execute the make install command to install Apache in its appropriate directory.

[root@linuxhelp1 httpd-2.4.28]# make install

Step 11Now the Apache is successfully installed on the server from its source code. Next, run the httpd -v command to check Apache's version. An error may appear as shown below.

[root@linuxhelp1 httpd-2.4.28]# httpd -v
bash: httpd: command not found…

step12: To remove that error, create an HTTPD command manually. Create a script file for the httpd command under /etc/profile.d/ directory. Enter the following line in the file and save it.

[root@linuxhelp1 httpd-2.4.28]# vim /etc/profile.d/httpd.sh
pathmunge /usr/local/apache2/bin

Step13: The file has been created, now log out from the current session and re-login to reload the profile. Check the Apache version by running the following command

[root@linuxhelp1 ~]# httpd -v
Server version: Apache/2.4.28 (Unix)
Server built:   Oct 13 2017 23:23:07

Step14: Create an init script for managing the httpd service. To create an httpd file under /etc/init.d/ directory using vim editor, make the following changes in the file. Save and exit the file.

[root@linuxhelp1 ~]# vim /etc/systemd/system/httpd.service

[Unit]
Description=The Apache HTTP Server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop
PIDFile=/usr/local/apache2/logs/httpd.pid
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Step15: reload the system daemon

[root@linuxhelp1 ~]# systemctl daemon-reload

Step16: start and enable and check the status of the apache httpd service 

[root@linuxhelp1 ~]# systemctl start httpd
[root@linuxhelp1 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /etc/systemd/system/httpd.service.
[root@linuxhelp1 ~]# systemctl status httpd

Step17: switch to the browser and type the localhost IP now load the webpage using the Apache webserver.

It will show the apache welcome page.

Thus we conclude the installation and configuration of Apache from its Source Code on CentOS 7.


----------------------------------------!!!! Happy Learning with Techiev !!!!!!!!----------------------------------

-------------------------Subscribe our Youtube Channel by clicking the below link---------------------- ----------------------------!!https://www.youtube.com/@techieview729!!---------------------





           

         
                         





     



        
      
Name

AWS,19,Devops,30,linux,11,
ltr
item
Techie View: Going Beyond Packages: A Deep Dive into Apache Installation Using Source Code
Going Beyond Packages: A Deep Dive into Apache Installation Using Source Code
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6z8mwgrfIlvgZ4-0PykKrUhpvCRb4YmmaNMl7rplC6KXgM2UyOpaC_gPxG7siNkGKy_FEIbRXA3lNBcXhGLYs4qg14uAmxFufz1qmIkM4pshXbuIjFZ41X32bQd4XugrPB504V1ctngr4/s640/apache-web-server-logo.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6z8mwgrfIlvgZ4-0PykKrUhpvCRb4YmmaNMl7rplC6KXgM2UyOpaC_gPxG7siNkGKy_FEIbRXA3lNBcXhGLYs4qg14uAmxFufz1qmIkM4pshXbuIjFZ41X32bQd4XugrPB504V1ctngr4/s72-c/apache-web-server-logo.png
Techie View
https://www.techiev.com/2020/07/installing-apache-using-source-code.html
https://www.techiev.com/
https://www.techiev.com/
https://www.techiev.com/2020/07/installing-apache-using-source-code.html
true
7013663511659419322
UTF-8
Loaded All Posts Not found any posts VIEW ALL View Full Article Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy