Installation Guide for Fragmented Web Servers

Installation Guide for Fragmented Web Servers

Problem

Some web developers may have used an all-in-one server during their first years in web development. One notable example of an all-in-one server is XAMPP. The all-in-one servers may have a database server and HTTP server with an integrated interpreter (usually to execute server-side PHP scripts).

However, bundled servers are not always good for scalability or customizability purposes. Thus, the author created this guide for other developers to set up their "fragmented web servers".

If a server component of that bundled server has newer version, developers would need to wait for a new installer containing all updates. The developer would also need to download large amount of bytes to get installer which may only update one or more components.

There are no problems on using a bundled server especially if the developers are looking for a quick and easy solution or if they are still at beginner level. Yet, the I.T. industry at this era is fast-paced. When the beginner developers are already done with their basic lessons, this guide would prove to be a useful for them to grow further.

  1. HTTP Server Installation
  2. Scripting Language Installation
  3. Database Installation
  4. Website Registration

Prerequisites

The readers of this article are expected to be semi-intermediate or intermediate web developers. The earlier they know about the topic of this article, the better.

In addition, readers are encouraged (but not required) to have a sample website to follow the guide. The website can be simple as having a single page only regardless whether it is a dynamic or static one.

Websites that are made for more than 500 users may be hard to integrate depending on its scalability and required dependencies. It is up to the reader to read complementary information to support their use case.

HTTP Server Installation

HTTP servers are the most essential web server that a website administrator must have. In this section, the reader would install Apache HTTP server. It is on the reader's choice if they would install other available options such as nginx. The installation steps are outlined below.

  1. Download the portable package (in zipped format) of Apache HTTP server from Apache Haus.
  2. Unzip Apache HTTP server to your chosen directory. Label the chosen directory as APACHE_ROOT.
  3. Find the HTTP server configuration file on APACHE_ROOT/conf/httpd.conf and open it.
  4. Uncomment the following modules to enable them: access_compat, rewrite, and headers. Reader can find the modules in the format like this one:LoadModule access_compat_module modules/mod_access_compat.so. Note that filenames may differ depending on the operating system being used.
  5. Optionally, reader may want to change listening port of the HTTP server. Listening on 0.0.0.0:80 allows the machine to listen to all bounded IP address on the computer such as loopback address and local address.
# A line starting with `#` is a comment and server would ignore
# it but useful for documentation to mark or note some things
# Directive below allows listening to all IPv4 addresses bound 
# to reader's computer
Listen 0.0.0.0:80
# Reader may see other directives that are configured by default.
# Directives below are modules available. Some of them activated
# by default.
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule headers_module modules/mod_headers.so
# ... other available modules may be seen
# There are more directives to be added later.
# Replace `PHP_ROOT` with real directory according to the

Sample content of httpd.conf

Scripting Language Installation

A scripting language, such as PHP language, are usually used in web development to make dynamic web pages. In addition, scripts made in this language allow manipulation of data in the database.

In this section, the reader would integrate a server-side script interpreter on Apache HTTP server. PHP interpreter would be used as it is a popular choice based from author's experience.

  1. Download the portable package (in zipped format) of PHP interpreter from different binaries. It is recommended to install the latest version of a thread-safe binary.
  2. Unzip PHP interpreter to your chosen directory. Label the chosen directory as PHP_ROOT.
  3. Find the HTTP server configuration file on APACHE_ROOT/conf/httpd.conf and open it.
  4. Add LoadModule php_module "PHP_ROOT/php8apache2_4.dll" below the list of modules inside the HTTP server configuration file. This step may vary depending on the major version of the chosen PHP interpreter. Change the PHP_ROOT according to the real path of directory done in step 2.
  5. Below the new line of HTTP server configuration file, add PHPIniDir "PHP_ROOT/php.ini" to configure the PHP interpreter. Change the PHP_ROOT according to the real path of directory done in step 2.
  6. Last line to add is AddHandler application/x-httpd-php .php to instruct the HTTP server to treat files ending on . php as files that can be interpreted by the PHP interpreter.
  7. Find the PHP configuration file on PHP_ROOT/php.ini and open it.
  8. Enable the extensions in PHP_ROOT/php.ini that can found around line 900 by removing the ; symbol before the target line. If the developer would like to communicate to MySQL database server, enable extension=pdo_mysql and extension=mysqli. If the developer would like to communicate to PostgreSQL database server, enable extension=pdo_pgsql and extension=pgsql.
LoadModule php_module "PHP_ROOT/php8apache2_4.dll"
PHPIniDir "PHP_ROOT/php.ini"
AddHandler application/x-httpd-php .php

Sample content of httpd.conf

; For this file, a line starting with `;` is a comment and
; server would ignoreit but useful for documentation to mark
; or note some things.
; Reader may see other configurations that exist by default.
; Assuming that this configuration is around line 900+...
; Notice that some extensions are enabled by default. Some are
; disabled. It would be best to double check the extensions.
; In this sample configuration, developers may use a MySQL
; database, PostgreSQL database, and/or SQLite database.
extension=mysqli
;extension=oci8_12c
;extension=oci8_19
;extension=odbc
;extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
;extension=shmop

Sample content of php.ini

Database Installation

After the installation of HTTP server and scripting language, database servers must be installed to store user data and other secured data such as passwords and access tokens. Depending on the chosen database server, the database may store either structured data, unstructured data, or both.

In this section, the reader would install database server to be used for saving the data of a system or application. A GUI-based database client may also be installed to view the data in native desktop environment. It depends on the preference of the developer.

Website Registration

After the installation of different servers, it is time to make the website accessible to every one.

In this section, the reader would register the website in the Apache HTTP server configuration.

  1. After the step 5 in configuring the server language installation, add these tags: <VirtualHost *:80></VirtualHost>. These tags define "virtually" hosted websites. The authors think of virtual hosts as "renters" and HTTP servers as the "shared building" in which they live. This allows multiple websites to be hosted on a single instance of Apache HTTP Server.
  2. Inside the <VirtualHost> tags, define a local variable. The syntax is as follows: Define WEBSITE_ROOT "<path to website root>". Note that WEBSITE_ROOT can be renamed as much as the reader want.
  3. Following the declaration of variable, document root must be declared on a next line and inserting this directive: DocumentRoot "${WEBSITE_ROOT}". This indicates which files the client (or browser) will access.
  4. After the specifying the document root, path of the error log must be specified by inserting this directive: ErrorLog "${WEBSITE_ROOT}/error.log". This indicates where to write server errors from the Apache HTTP server. Readers can customize the error log location.
  5. Lastly, use this directive: <Directory "${WEBSITE_ROOT}">Require all granted</Directory>. This allows everyone to access the website.

There are many directives that can affect server behavior. It is best to research about them. See the reference for the module that provides the specific directive.

<VirtualHost *:80>
Define WEBSITE_ROOT "<path to website root>"
DocumentRoot"${WEBSITE_ROOT}"
ErrorLog"${WEBSITE_ROOT}/error.log"
<Directory "${WEBSITE_ROOT}">
Requireall granted
OptionsIndexes Includes FollowSymlinks
AllowOverrideAll
</Directory>
</VirtualHost>

Sample content of httpd.conf

Space for Improvements

There are more advanced configurations left as an exercise for the reader. The author recommends the readers to read the documentation for each tool they use to further their expertise. This is the best bridge available between the source code that explains the exact process and video tutorials that usually provide an overview for beginners.

Note that the instructions available in this article is a result of several years of experience that the author gained in setting up the servers. It is a difficult path especially for someone is learning these concepts without any supervision or mentorship.

Should there be some corrections, updates, or improvements, please contact the authorand send the details that need to be corrected, updated, or improved upon.

References

Some portions in this article were based on third-party work(s) for educational purposes. They are copyright of the respective groups, organizations, companies, or persons that have been attributed below. Note that these works may have been shared under different licenses and may have notices (e.g. disclaimer of warranties) in the linked licenses. Should a work has no existing license(s), a link to the work have been still provided.

Disclaimer: Otherwise noted, the views or interests expressed in this site are my views, and does not necessarily reflect the view or interest of any entity I have a connection to; whether it is an organization, or someone I have worked with. In addition, trademarks (that may be mentioned in different pages) are the property of their respective owners and should not be interpreted as indicating endorsement, affiliation, or sponsorship, unless stated otherwise.

logo

Copyright © 2024 Kenneth Trecy Tobias.

Website's code(not texts such as containing my personal information) are under MIT license.

Socials

LinkedIn GitHub