Introduction: Installing Apache2 on Ubuntu Server
Installing Apache2 on a Ubuntu server will give you the power to host your own personal website. You can use this for your own personal use, business, or even web development.
Step 1: Installation
Apache is included in Ubuntu’s default application package repositories,
so there’s no special tools or processes needed to install it. We can simply update and install the package directly from Ubuntu. Start off by logging into your server and updating apt.
sudo apt-get update
This will update the package cache will all the current packages available. Once updated, go ahead and install Apache2.
sudo apt-get install apache2
This installation will install Apache2 as well as any missing dependencies, so make sure to accept any that might come up during the installation process. Once complete, Apache2 is installed, however there is a bit more configuration needed in order to get it going.
Step 2: Adjust the Firewall
Ubuntu has a default firewall called ufw that is pretty restrictive out of the box. We’ll want to open it up to allow communications to flow to/from the Apache web server. Use the following commands to open up the firewall. UFW has a default Apache profile built in.
sudo ufw allow 'Apache Full'
Or you can optionally do it manually by port.
sudo ufw allow 80 sudo ufw allow 443
Step 3: Checking the Server
Once Apache has been installed and the firewall has been opened up, you can check the status of the server for the first time. Use the below command to make sure the service is actually running.
sudo service apache2 status
If the service is running properly, you should see a status of “RUNNING”. If not, issue a “start” command instead of a “status” command to start it up. Now that the server is running, you can hit the server by hostname or IP to view the default Apache website.
Once you have gathered the full hostname or the IP address of the web server, open up your browser and navigate to the URL where the website is listening i.e.
Step 4: Default Config/Log Locations
Apache has a few default locations for storing or reading files. You’ll need to poke around on your server a little bit to really get the hang of things, but the defaults for Ubuntu are usually at the locations below
Web files – /var/www/html/
Configuration Files /etc/apache2/apache2.conf
Logs – /var/logs/apache2