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.
- Download the portable package (in zipped format) of Apache HTTP server from Apache Haus.
- Unzip Apache HTTP server to your chosen directory. Label the chosen directory as APACHE_ROOT.
- Find the HTTP server configuration file on APACHE_ROOT/conf/httpd.conf and open it.
- 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. - 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.
- 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.
- Unzip PHP interpreter to your chosen directory. Label the chosen directory as PHP_ROOT.
- Find the HTTP server configuration file on APACHE_ROOT/conf/httpd.conf and open it.
- 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. - 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. - 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. - Find the PHP configuration file on PHP_ROOT/php.ini and open it.
- 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, enableextension=pdo_mysql
andextension=mysqli
. If the developer would like to communicate to PostgreSQL database server, enableextension=pdo_pgsql
andextension=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.
- If MySQL database server has been preferred, install the MySQL community server as a service. After that, install the MySQL Workbench separately to view the data.
- If PostgreSQL database server has been preferred, install the PostgreSQL database server. pgAdmin, which is the client application, is already included in the installer.
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.
- 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. - Inside the
<VirtualHost>
tags, define a local variable. The syntax is as follows:Define WEBSITE_ROOT "<path to website root>"
. Note thatWEBSITE_ROOT
can be renamed as much as the reader want. - 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. - 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. - 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.