Exercises to complete:
- Install Apache2
- Enable and start Apache2
- Add a port to firewalld
- Create a simple website
- Check does the website display correctly using IP address
Install Apache2
SLES
To install Apache2 type:
# refresh repositories
sudo zypper ref
# install Apache2
sudo zypper -n in apache2
# enable Apache2 on boot
sudo systemctl enable apache2
# start the Apache2
sudo systemctl start apache2
Debian
To install apache2 type:
# refresh repositories
sudo apt update
# install apache2
sudo apt -y install apache2
# enable apache2 on boot
sudo systemctl enable apache2
# start the apache2
sudo systemctl start apache2
Red Hat
To install apache2 type:
sudo yum install httpd -y
or
sudo dnf install httpd -y
# enable apache2 on boot
sudo systemctl enable httpd
# start the apache2
sudo systemctl start httpd
Allow Apache2 service
SLES
linux:~ # sudo firewall-cmd --add-service=http --permanent
success
linux:~ # sudo firewall-cmd --reload
success
Debian
sudo ufw allow 'WWW'
or
sudo ufw allow 'Apache'
Red Hat
linux:~ # sudo firewall-cmd --add-service=http --permanent
success
linux:~ # sudo firewall-cmd --reload
success
Create a simple webiste
echo 'Linux fundamentals - lab' | sudo tee -a /srv/www/htdocs/index.html
Check does the website display correctly using IP address
curl http://checkip.amazonaws.com
curl http://IP-ADDRESS
Additional modules
Once the Apache server is up and running, additional modules can be enabled for extended functionality.
To check the lsite of additional modules, look in the /etc/apache2/mods-available
directory or /etc/httpd/conf.modules.d
directory.
Suppose you want to install the MySQL authentication module. You can do that by running the following command:
SLES
sudo zypper -n in libapr1-util1-dbd-mysql
Debian
sudo apt install libapr1-util1-dbd-mysql
Red Hat
sudo yum install apache-mod_authn_dbd
or
sudo dnf install apache-mod_authn_dbd
After installation, the module should be turned on using the following command:
sudo a2enmod authn_dbd
Then restart the Apache server to enable activating the changes made:
SLES
sudo systemctl restart apache2
Debian
sudo systemctl restart apache2
Red Hat
sudo systemctl restart httpd