This document was created for students in my college Linux Administration class (at Tonysako.com). This document contains the commands demonstrated in the videos for installing and starting a Linux web server running on a VirtualBox VM. This document is also available as a PDF.
- Start Linux server (VM)
- Make sure you are in the root account
- Use
yum
to install the Apache web server which is in thehttpd
package. The command for installing the package is:
yum install httpd
- Start the web server (httpd daemon) using systemctl command:
systemctl start httpd
- Use the
systemctl
command to set the web server to start automatically when the system boots
systemctl enable httpd
- Add a rule to the firewall configuration file(s) to allow the web traffic using
firewall-cmd --permanent --add-service=http
You can also add a firewall rule to allow https at this time. However using https requires adding a certificate server and issuing security certificates, so you won’t be able to test it until those steps are also completed.
firewall-cmd --permanent --add-service=https
- Reload the firewall so that it will read the new rules from the configuration files.
firewall-cmd --reload
- Add a port forwarding rule to Virtual Box to forward web traffic into the Linux virtual machine by following these steps:
- Shutdown the Linux VM. (Shutting down is a good idea any time you make changes the to Virtual Box settings for a virtual machine.)
- In Virtual Box, select the Linux VM and then click the Settings button.
- Select the Network category.
- Ensure that the Adapter 1 tab is selected and the Attached to: option is set to NAT.
- Click the triangle by Advanced to display the Advanced Network options. This will expand the network options.
- Click the Port Forwarding button. This will display the Port Forwarding Rules dialog box.
- Click on the green + icon (upper right) to add a new port forwarding rule.
- Set the Host IP to 127.0.0.1 and the Host Port to 8000. (You can use a different Host Port if you wish, just remember what you set it to.)
- Set the Guest IP to 10.0.2.15 and the Guest Port to 80
- Click OK. This will save the new port forwarding rule, close the Port Forwarding Rules dialog box, and return you to the Virtual Box Settings.
- Click OK to save the new settings
- Start the Linux VM. The web server should now be running and ready for an acceptance test.