How to Create a Web Server With Apache On Debian

how to create web server with apache on.

Creating a Web Server With Apache On Debian

Creating a Web Server With Apache On Debian

The web comes from the term World Wide Web (WWW) which was first introduced by CERN in Switzerland. The web is a page or document written with certain programming language codes such as HTML, PHP, ASP, JavaScript, and others. This time we will learn how to create a Web Server with Apache and configure it on Debian.


What is Apache

Apache is a type of web server that is popular and most widely used in the world. Managed by the Apache Software Foundation, Apache was launched in 1995 and has continued to improve over the years since.


Just like a web server in general, Apache is a web server software that connects the server with the user (browser). If you access a website via a URL in a browser then the website display appears, it could be the work of Apache.


Apache was originally developed to be an open-source web server for modern operating systems such as UNIX. In addition, the development also aims to provide a type of web server that can be easily developed, safe, effective, and efficient. Now Apache is widely used by many large companies such as Linkedin, Adobe, General Electric, IBM, also used by control panel service providers as their web browsers. In addition, currently, Apache is the most widely used web server of the total websites on the internet.


If you look at the current conditions, many control panel service providers (especially cPanel) use Apache as a web server. Similar to various kinds of web servers today, Apache is one of the main drivers so that websites can connect with visitors (users).


Why Use Apache?

Apache is a popular web server. This is because Apache is the oldest web server compared to other web servers. Apache also provides many powerful features including dynamically loadable modules, strong media support, and extensive integration with other popular software. In addition, Apache has several other features offered by SSL, such as .htaccess, HTTP/2, Lua, PHP, Perl, IPv6, FTP, Bandwidth throttling, WebDAV, Load balancing, and so on.


Creating a Web Server With Apache On Debian

1. Installing Apache

Apache is available in Debian's default software repositories, making it possible to install it using conventional package management tools. To install your apache package just use the command:

~#apt-get install apache2

Installing Apache

To check if apache is running use the command

~#sudo systemctl status apache2

systemctl status apache2

If you want to stop, start or restart the Apache service use the command line:

~#sudo systemctl stop apache2.service

~#sudo systemctl start apache2.service

~#sudo systemctl restart apache2.service


If you want to make TCP ports 80 (www) and 443 (https) on Debian 10 work. Type the following command:

~#sudo ufw allow www

~#sudo ufw allow https

~#sudo ufw status

 

Example output:

Status: active
 
To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)


Test it by typing in your server IP or domain name:


To configure apache Edit the following file using a text editor like vi/vim, nano, emacs and so on:

~#sudo nano /etc/apache2/mods-available/mpm_prefork.conf


Updated admin config file for EC2 with 2 GB ram and 1 vCPU to run multiple WP sites:

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of requests a server process serves
 
<IfModule mpm_prefork_module>
	StartServers		  4
	MinSpareServers		  20
	MaxSpareServers		  40
	MaxRequestWorkers	  200
	MaxConnectionsPerChild    2500
</IfModule>
 
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

The settings above should be adjusted according to your needs. Finally, disable Apache event module and enable httpd prefork, run:

~#sudo a2dismod mpm_event

~#sudo a2enmod mpm_prefork


To activate the new configuration, you need to run:

~#sudo systemctl restart apache2.service


To go to the web server directory you can use the command

~#cd /var/www/html


2. Installing MariaDB

MariaDB Server is one of the most popular database servers in the world. It is created by the original developers of MySQL and is guaranteed to remain open source. Leading users include Wikipedia, WordPress.com, and Google. To install it just use the command:

~#sudo apt-get install mariadb-server

Installing MariaDB

To secure your MariaDB, run the command:

~#sudo mysql_secure_installation

  • it allows you to increase the security of your MariaDB installation in the following ways:
  • You can set a password for the root account.
  • Remove the root account which is accessible from outside localhost.
  • Delete the anonymous user account.
  • Delete the test database, which is accessible to anonymous users by default.

secure your MariaDB

3. Installing PHP

PHP is the last part to create a web server that allows to generate dynamic web pages. To install it, run the command:

~#sudo apt install php libapache2-mod-php

Installing PHP

Then if you want to install a PHP module that allows MySQL access and GD lib also use the command:

~#sudo apt install php-mysql php-gd


One can get a list of all PHP modules using a combination of the apt-cache command and the grep command:

~#apt-cache search php | egrep 'module' | grep default


Example output:

libapache2-mod-php - server side, script language embedded in HTML (apache module 2) (default)
php-bcmath - Bcmath module for PHP [default]
php-bz2 - bzip2 module for PHP [default]
php-curl - CURL module for PHP [default]
php-dev - File for PHP module development (default)
php-enchant - Enchant module for PHP [default]
php-gd - GD module for PHP [default]
php-gmp - GMP module for PHP [default] ]
php-imap - IMAP module for PHP [default]
php-interbase - Interbase module for PHP [default]
php-intl - Internationalization module for PHP [default]
php-json - JSON module for PHP [default]
php-ldap - LDAP module for PHP [default]
php-mbstring - MBSTRING module for PHP [default]
php-mysql - MySQL module for PHP [default]
php-odbc - ODBC module for PHP [default]
php-pgsql - PostgreSQL module for PHP [default]
php-pspell - pspell module for PHP [default]
php-readline - readline module for PHP [default]
php-recode - recode module for PHP [default]
php-snmp - SNMP module for PHP [default]
php-soap - SOAP module for PHP [default]
php-sqlite3 - SQLite3 module for PHP [default]
php -sybase - Sybase module for PHP [default]
php-tidy - neat module for PHP [default]
php-xml - DOM, SimpleXML, WDDX, XML, and XSL modules for PHP [default]
php-xmlrpc - XMLRPC-EPI module for PHP [default]
php-zip - Zip module for PHP [default]


Hopefully, this article about How to Create a Web Server With Apache On Debian gives you a little insight. Also, read an article about How to create a Windows 10 recovery disc from another computer that you may need to know. Thank you.

Previous Post Next Post