How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04
Step 1 — Installing Apache and Updating the Firewall
The Apache web server is among the most popular web servers in the world. It’s well-documented and has been in wide use for much of the history of the web, which makes it a great default choice for hosting a website.
Install Apache using Ubuntu’s package manager,
sudo apt update sudo apt install apache2
Since this is a
sudo command, these operations are executed with root privileges. It will ask you for your regular user’s password to verify your intentions.
Once you’ve entered your password,
apt will tell you which packages it plans to install and how much extra disk space they’ll take up. Press
Y and hit
ENTER to continue, and the installation will proceed.
Adjust the Firewall to Allow Web Traffic
Next, assuming that you have followed the initial server setup instructions and enabled the UFW firewall, make sure that your firewall allows HTTP and HTTPS traffic. You can check that UFW has an application profile for Apache like so:
sudo ufw app list
OutputAvailable applications: Apache Apache Full Apache Secure OpenSSH
If you look at the
Apache Full profile, it should show that it enables traffic to ports
sudo ufw app info "Apache Full"
OutputProfile: Apache Full Title: Web Server (HTTP,HTTPS) Description: Apache v2 is the next generation of the omnipresent Apache web server. Ports: 80,443/tcp
Allow incoming HTTP and HTTPS traffic for this profile:
sudo ufw allow in "Apache Full"
You can do a spot check right away to verify that everything went as planned by visiting your server’s public IP address in your web browser (see the note under the next heading to find out what your public IP address is if you do not have this information already):
You will see the default Ubuntu 18.04 Apache web page, which is there for informational and testing purposes. It should look something like this: