What is apache server?
All the configuration files for Apache are located in /etc/httpd/conf and /etc /httpd/conf. d . The data for websites you'll run with Apache is located in /var/www by default, but you can change that if you wants.
Apache HTTP Server VS other web services :
Beside Apache web server, there are many other popular options. Each web server application has been created for a different purpose. While Apache web server is the most widely used, it has quite a few alternatives and rivals.
what is a webserver?
A webserver is software run by your website hosting provider so that visitors can view the web pages on your site. Many WordPress hosting providers use Apache.
The software performs a similar role to a restaurant host. When you arrive at a restaurant, the host greets you, checks your booking information, and takes you to your table. In a similar way, the webserver checks for the web page you have requested.
A webserver does more. It also acts like a restaurant server when it fetches the page and serves it for your viewing pleasure.
And it performs the role of the restaurant’s maitre d’ by handling communications with the website, handling your requests, and making sure that other modules are ready to serve you.
Finally, a webserver is also like the busboy clearing tables. It cleans the memory, cache and modules and clears them for new website visitors.
Why do we install Apache server? There are a variety of reasons why developer or DevOps professionals locally install the Apache Web Server on a Windows 10 machine. They can use the Apache HTTP server for testing, or to simulate a production HTTP server that acts as static file cache for Apache Tomcat or Jetty.
Step 1: Installing Apache :
update your local package index :
Sudo apt update.
Sudo apt install apache2.
Step 2: Adjusting Firewall :
Check the available ufw application profiles :
Sudo ufw app list.
Available Applications ;
Sudo ufw allow Apache :
Verify the change :
Sudo ufw Status :
Status : active
To Action From
openSSH Allow Anywhere.
Apache Allow Anywhere.
openSSH (v6) Allow Anywhere.
Apache (v6) Allow Anywhere.
Step 3 : Checking your web server.
sudo systemctl status apache2
Output● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since Tue 2018-04-24 20:14:39 UTC; 9min ago Main PID: 2583 (apache2) Tasks: 55 (limit: 1153) CGroup: /system.slice/apache2.service ├─2583 /usr/sbin/apache2 -k start ├─2585 /usr/sbin/apache2 -k start └─2586 /usr/sbin/apache2 -k start
Step 4 :Setting up virtual Hosts (Recommanded) ;
sudo mkdir /var/www/your_domain
sudo chown -R $USER:$USER /var/www/your_domain
html> <head> <title>Welcome to Your_domain!</title> </head> <body> <h1>Success! The your_domain virtual host is working!</h1> </body> </html>
Save and close the file when you are finished.
sudo a2ensite your _domain .conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl restart apache2.
What is Apache file path?
, Apache resides at / u s r /local/apache2 in the Unix file system or "c:/Program Files/Apache Group/Apache2" in the Windows file system. (Note that forward slashes should always be used as the path separator in Apache, even for Windows.)
We can quickly find the location or path to the main server configuration folders and files of Apache Web Server (HTTPD) with the following steps:
httpd -V– The Apache Web Server comes with
apachectlcli tool which can act as a front end to the server binary (
httpd). Executing one of these commands in your terminal will dump the compile time settings of the server.
- Look for the following settings –
SERVER_CONFIG_FILEis an absolute path like
/private/etc/apache2/httpd.conf, then that’s the location of your main server configuration settings and
/private/etc/apache2is the folder that should contain other configuration files.
SERVER_CONFIG_FILEis a relative path (eg:
apache2.conf) then join that with
HTTPD_ROOTwhich points to the server root (eg:
/etc/apache2). The final path, i.e.,
/etc/apache2/apache2.confis the location of your main server configuration file.
Step 2 will give you the main server configuration file and the folder in the path with the name
httpd will be the place that’ll contain all other configuration files as well. It is different from the server root which can be a different path specified by the
HTTPD_ROOT value (as we’ll see below).
Here’s a sample dump from one of my servers:
$ apachectl -V Server version: Apache/2.4.29 [[other stuff]] Server compiled with.... [[other redacted settings]] -D HTTPD_ROOT="/etc/apache2" -D SERVER_CONFIG_FILE="apache2.conf"
Here’s another dump from my macOS machine where you’ll notice the server root is a different path from the main configuration folder:
$ apachectl -V Server version: Apache/2.4.51 (Unix) -D HTTPD_ROOT="/usr" -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"