Linux – Apache Part 1: Instalation and configuration

Our own www server is sometimes needed when building webapp, it is also used in internal like in external networks.

Here is as simple recipe for it:

#set proper hostname
hostnamectl set-hostname nasz_hostname

vim /etc/hosts
#add this line to file
ip.address hostname.domain hostname

apt-get install apache2 apache2-doc apache2-utils

#disable default vhost
a2dissite 000-default.conf

#create your own vhost conf
vim /etc/apache2/sites-available/
<VirtualHost *:80> 
     DocumentRoot /var/www/
     ErrorLog /var/www/ 
     CustomLog /var/www/ combined

mkdir -p /var/www/
mkdir /var/www/
service apache2 reload

This configuration is proper for local use.

But if your server will be available outside your network then make those also:

vim /etc/apache2/conf-enabled/security.conf
#disable server signature
ServerSignature Off
ServerTokens Prod
vim /etc/apache2/apache2.conf
#disable directory listing and symlinks
<Directory /var/www/>
        #Options Indexes FollowSymLinks
        Options -Indexes
        AllowOverride All
        Require all granted
#add security module
apt-get install libapache2-modsecurity
/etc/init.d/apache2 restart

#remamber that you need to proper configure security module, which is not covered here

Next parts:

Linux – Apache Part 2: Enable SSL

Linux – Apache Part 3: PHP

Linux – Apache Part 4: MySQL and MariaDB Database


Leave a Reply

Your email address will not be published. Required fields are marked *